The Battle for Wesnoth  1.15.0-dev
Namespaces | Macros | Functions
string_utils.hpp File Reference
#include "gettext.hpp"
#include "serialization/string_utils.hpp"
Include dependency graph for string_utils.hpp:

Go to the source code of this file.

Namespaces

 utils
 
 utils::detail
 

Macros

#define VGETTEXT(msgid, ...)   vgettext_impl(GETTEXT_DOMAIN, msgid, __VA_ARGS__)
 Handy wrappers around interpolate_variables_into_string and gettext. More...
 
#define VNGETTEXT(msgid, msgid_plural, count, ...)   vngettext_impl(GETTEXT_DOMAIN, msgid, msgid_plural, count, __VA_ARGS__)
 

Functions

bool utils::might_contain_variables (const std::string &str)
 Determines if a string might contain variables to interpolate. More...
 
std::string utils::interpolate_variables_into_string (const std::string &str, const string_map *const symbols)
 Function which will interpolate variables, starting with '$' in the string 'str' with the equivalent symbols in the given symbol table. More...
 
std::string utils::interpolate_variables_into_string (const std::string &str, const std::map< std::string, std::string > *const symbols)
 
std::string utils::interpolate_variables_into_string (const std::string &str, const variable_set &variables)
 
t_string utils::interpolate_variables_into_tstring (const t_string &str, const variable_set &variables)
 Function that does the same as the above, for t_stringS. More...
 
std::string utils::format_conjunct_list (const t_string &empty, const std::vector< t_string > &elems)
 Format a conjunctive list. More...
 
std::string utils::format_disjunct_list (const t_string &empty, const std::vector< t_string > &elems)
 Format a disjunctive list. More...
 
std::string vgettext_impl (const char *domain, const char *msgid, const utils::string_map &symbols)
 Implementation functions for the VGETTEXT and VNGETTEXT macros. More...
 
std::string vngettext_impl (const char *domain, const char *singular, const char *plural, int count, const utils::string_map &symbols)
 

Macro Definition Documentation

◆ VGETTEXT

#define VGETTEXT (   msgid,
  ... 
)    vgettext_impl(GETTEXT_DOMAIN, msgid, __VA_ARGS__)

Handy wrappers around interpolate_variables_into_string and gettext.

These should cover most usecases. If you're not sure whether you want these macros or their implementation functions, use these. The only time you should need to use the implementation functions directly is to pass a different textdomain than the current value of GETTEXT_DOMAIN.

Definition at line 103 of file string_utils.hpp.

Referenced by ad_hoc_addon_fetch_session(), gui2::dialogs::preferences_dialog::add_hotkey_callback(), unit::add_modification(), events::chat_handler::add_whisper_received(), events::chat_handler::add_whisper_sent(), gui2::chatbox::add_whisper_sent(), gui2::build_window_impl(), events::chat_handler::change_logging(), mp::game_info::check_addon_version_compatibility(), events::map_command_handler< chat_command_handler >::command_failed_need_arg(), addons_client::connect(), ng::connect_engine::connect_engine(), gui2::dialogs::addon_manager::delete_addon(), addons_client::delete_remote_addon(), gui2::dialogs::depcheck_confirm_change::depcheck_confirm_change(), deprecate_wml_key_warning(), deprecated_message(), deprecated_renamed_wml_key_warning(), unit::describe_builtin_effect(), attack_type::describe_modification(), events::map_command_handler< chat_command_handler >::dispatch(), addons_client::do_check_before_overwriting_addon(), events::console_handler::do_control(), events::console_handler::do_controller(), events::console_handler::do_droid(), events::chat_command_handler::do_friend(), events::console_handler::do_idle(), events::chat_command_handler::do_ignore(), events::chat_command_handler::do_info(), events::chat_command_handler::do_register(), events::chat_command_handler::do_remove(), events::menu_handler::do_search(), events::chat_command_handler::do_set(), events::console_handler::do_unit(), addons_client::download_addon(), gui2::dialogs::game_load::evaluate_summary_string(), gui2::dialogs::addon_manager::execute_default_action(), utils::format_conjunct_list(), utils::format_disjunct_list(), mp::game_info::game_info(), ng::configure_engine::game_name_default(), gui2::dialogs::generate_user_description(), events::map_command_handler< chat_command_handler >::help(), mp::initial_level_config(), addons_client::install_addon(), gui2::dialogs::label_settings::label_settings(), editor::context_manager::load_map(), gui2::dialogs::mp_lobby::make_game_row_data(), missing_mandatory_wml_key(), gui2::missing_widget(), ng::side_engine::new_config(), gui2::dialogs::file_dialog::on_dir_create_cmd(), gui2::dialogs::file_dialog::on_file_delete_cmd(), gui2::dialogs::statistics_dialog::on_primary_list_select(), wb::manager::options_dlg(), gui2::parse_linked_group_definitions(), gui2::dialogs::mp_change_control::pre_show(), gui2::dialogs::game_version::pre_show(), gui2::dialogs::addon_manager::pre_show(), gui2::dialogs::title_screen::pre_show(), turn_info::process_network_data(), gui2::chatbox::process_room_join(), gui2::chatbox::process_room_part(), gui2::dialogs::file_dialog::process_submit_common(), ng::flg_manager::resolve_random(), gui2::chatbox::room_window_open(), events::menu_handler::save_map(), editor::map_context::save_map(), editor::map_context::save_scenario(), gui2::unit_preview_pane::set_displayed_type(), gui2::unit_preview_pane::set_displayed_unit(), location_palette_item::set_item_id(), editor::editor_map::set_starting_position_labels(), preferences::show_wesnothd_server_search(), SYNCED_COMMAND_HANDLER_FUNCTION(), irdya_date::to_string(), play_controller::hotkey_handler::toggle_accelerated_speed(), mp_ui_alerts::turn_changed(), gui2::dialogs::mp_create_game::update_details(), gui2::dialogs::mp_lobby::update_gamelist_header(), addons_client::upload_addon(), gui2::chatbox::whisper_window_open(), playsingle_controller::hotkey_handler::whiteboard_toggle(), and editor::wrap_exc().

◆ VNGETTEXT

#define VNGETTEXT (   msgid,
  msgid_plural,
  count,
  ... 
)    vngettext_impl(GETTEXT_DOMAIN, msgid, msgid_plural, count, __VA_ARGS__)

Function Documentation

◆ vgettext_impl()

std::string vgettext_impl ( const char *  domain,
const char *  msgid,
const utils::string_map symbols 
)

Implementation functions for the VGETTEXT and VNGETTEXT macros.

DO NOT USE DIRECTLY unless you really know what you're doing. See https://github.com/wesnoth/wesnoth/issues/2716 for more info.

Referenced by utils::might_contain_variables().

◆ vngettext_impl()

std::string vngettext_impl ( const char *  domain,
const char *  singular,
const char *  plural,
int  count,
const utils::string_map symbols 
)