Classes | |
class | string_map_variable_set |
class | invalid_utf8_exception |
Functions for converting Unicode wide-char strings to UTF-8 encoded strings, back and forth. More... | |
class | utf8_iterator |
Typedefs | |
typedef std::map< std::string, t_string > | string_map |
Enumerations | |
enum | { REMOVE_EMPTY = 0x01, STRIP_SPACES = 0x02 } |
Functions | |
bool | isnewline (const char c) |
bool | portable_isspace (const char c) |
bool | notspace (const char c) |
std::string & | strip (std::string &str) |
Remove whitespace from the front and back of the string 'str'. | |
std::string & | strip_char (std::string &str, const char c) |
Removes character 'c' from the first and last position of the string 'str'. | |
std::vector< std::string > | split (std::string const &val, char c, int flags) |
std::vector< std::string > | paranthetical_split (std::string const &val, const char separator, std::string const &left, std::string const &right, int flags) |
Splits a string based either on a separator where text within paranthesis is protected from splitting (Note that one can use the same character for both the left and right paranthesis. | |
std::string | 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. | |
std::string | interpolate_variables_into_string (const std::string &str, const variable_set &variables) |
int | apply_modifier (const int number, const std::string &amount, const int minimum) |
std::string & | escape (std::string &str, const std::string &special_chars) |
Prepends a configurable set of characters with a backslash. | |
std::string & | escape (std::string &str) |
Prepend all special characters with a backslash. | |
std::string & | unescape (std::string &str) |
Remove all escape characters (backslash). | |
bool | string_bool (const std::string &str, bool def) |
static bool | is_username_char (char c) |
bool | isvalid_username (const std::string &username) |
Check if the username is valid. | |
bool | word_completion (std::string &text, std::vector< std::string > &wordlist) |
Try to complete the last word of 'text' with the 'wordlist'. | |
static bool | is_word_boundary (char c) |
bool | word_match (const std::string &message, const std::string &word) |
Check if a string contains a word. | |
bool | wildcard_string_match (const std::string &str, const std::string &match) |
Match using '*' as any number of characters (including none), and '?' as any one character. | |
std::string | join (std::vector< std::string > const &v, char c) |
std::vector< std::string > | quoted_split (std::string const &val, char c, int flags, char quote) |
std::pair< int, int > | parse_range (std::string const &str) |
std::vector< std::pair< int, int > > | parse_ranges (std::string const &str) |
static int | byte_size_from_utf8_first (unsigned char ch) |
std::string | wstring_to_string (const wide_string &src) |
std::string | wchar_to_string (const wchar_t c) |
wide_string | string_to_wstring (const std::string &src) |
utf8_string | capitalize (const utf8_string &) |
Returns a version of the string with the first letter capitalized. | |
utf8_string | uppercase (const utf8_string &) |
Returns an uppercased version of the string. | |
utf8_string | lowercase (const utf8_string &) |
Returns a lowercased version of the string. | |
void | truncate_as_wstring (std::string &str, const size_t size) |
Truncates a string. |
typedef std::map< std::string, t_string > utils::string_map |
Definition at line 82 of file string_utils.hpp.
anonymous enum |
REMOVE_EMPTY | REMOVE_EMPTY : remove empty elements. |
STRIP_SPACES | STRIP_SPACES : strips leading and trailing blank spaces. |
Definition at line 51 of file string_utils.hpp.
int utils::apply_modifier | ( | const int | number, | |
const std::string & | amount, | |||
const int | minimum | |||
) |
Definition at line 347 of file string_utils.cpp.
References div100rounded(), and value.
Referenced by unit::add_modification(), attack_type::apply_modification(), and gamestatus::modify_turns().
static int utils::byte_size_from_utf8_first | ( | unsigned char | ch | ) | [static] |
utf8_string utils::capitalize | ( | const utf8_string & | s | ) |
Returns a version of the string with the first letter capitalized.
Definition at line 807 of file string_utils.cpp.
References utils::utf8_iterator::substr(), and wchar_to_string().
Referenced by help::generate_ability_topics(), and help::generate_weapon_special_topics().
std::string & utils::escape | ( | std::string & | str | ) |
std::string & utils::escape | ( | std::string & | str, | |
const std::string & | special_chars | |||
) |
Prepends a configurable set of characters with a backslash.
Definition at line 360 of file string_utils.cpp.
References pos.
Referenced by preprocessor_data::preprocessor_data().
std::string utils::interpolate_variables_into_string | ( | const std::string & | str, | |
const variable_set & | variables | |||
) |
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.
If 'symbols' is NULL, then game event variables will be used instead.
Definition at line 335 of file string_utils.cpp.
References do_interpolation().
Referenced by unit::add_modification(), playsingle_controller::before_human_turn(), vconfig::expand(), gamestatus::gamestatus(), generate_name(), unit::generate_traits(), gamemap::location::location(), play_game(), unit::read(), terrain_label::read(), gamestatus::set_start_ToD(), dfool::evaluator::value(), vgettext(), and vngettext().
static bool utils::is_username_char | ( | char | c | ) | [static] |
static bool utils::is_word_boundary | ( | char | c | ) | [static] |
bool utils::isnewline | ( | const char | c | ) |
Definition at line 130 of file string_utils.cpp.
Referenced by gui::textbox::append_text(), gui::textbox::handle_event(), portable_isspace(), t_translation::read_builder_map(), and t_translation::read_game_map().
bool utils::isvalid_username | ( | const std::string & | username | ) |
Check if the username is valid.
Check if the username contains only valid characters.
(all alpha-numeric characters plus underscore and hyphen)
Definition at line 415 of file string_utils.cpp.
References is_username_char().
Referenced by preferences::add_friend(), preferences::add_ignore(), and server::process_login().
std::string utils::join | ( | std::vector< std::string > const & | v, | |
char | c | |||
) |
Definition at line 534 of file string_utils.cpp.
Referenced by add_relation(), font::del_tags(), help::generate_about_text(), mp::ui::handle_key_event(), events::map_command_handler< events::console_handler >::help_command(), help::help_button::join(), font::nullify_markup(), remove_relation(), gui::floating_textbox::tab(), unit::write(), write_game(), and preferences::manager::~manager().
utf8_string utils::lowercase | ( | const utf8_string & | s | ) |
Returns a lowercased version of the string.
Definition at line 849 of file string_utils.cpp.
References boost::foreach_detail_::end(), utils::utf8_iterator::substr(), and wchar_to_string().
Referenced by server::process_login().
bool utils::notspace | ( | const char | c | ) |
Definition at line 147 of file string_utils.cpp.
References portable_isspace().
Referenced by strip().
std::vector< std::string > utils::paranthetical_split | ( | std::string const & | val, | |
const char | separator, | |||
std::string const & | left, | |||
std::string const & | right, | |||
int | flags | |||
) |
Splits a string based either on a separator where text within paranthesis is protected from splitting (Note that one can use the same character for both the left and right paranthesis.
In this mode it usually makes only sense to have one character for the left and right paranthesis.) or if the separator == 0 it splits a string into an odd number of parts:
parenthetical_split("a(b)c{d}e(f{g})h",0,"({",")}") should return a vector of <"a","b","c","d","e","f{g}","h">
Definition at line 229 of file string_utils.cpp.
References ERR_GENERAL, REMOVE_EMPTY, strip(), and STRIP_SPACES.
Referenced by image::locator::load_image_sub_file(), preferences::manager::manager(), dfool::arithmetic_evaluator::parse_tokens(), and dfool::evaluator::value().
std::pair< int, int > utils::parse_range | ( | std::string const & | str | ) |
Definition at line 592 of file string_utils.cpp.
References a, b, and unit_map::end().
Referenced by parse_location_range(), and parse_ranges().
std::vector< std::pair< int, int > > utils::parse_ranges | ( | std::string const & | str | ) |
Definition at line 604 of file string_utils.cpp.
References parse_range(), and split().
Referenced by unit::internal_matches_filter(), and terrain_filter::match_internal().
bool utils::portable_isspace | ( | const char | c | ) |
Definition at line 137 of file string_utils.cpp.
References isnewline().
Referenced by preprocessor_data::get_chunk(), config::hash(), notspace(), and preprocessor_data::read_word().
std::vector< std::string > utils::quoted_split | ( | std::string const & | val, | |
char | c, | |||
int | flags, | |||
char | quote | |||
) |
Definition at line 553 of file string_utils.cpp.
References REMOVE_EMPTY, strip(), and STRIP_SPACES.
Referenced by gui::menu::fill_items(), help::generate_contents_links(), preprocessor_streambuf::lineno_string(), help::parse_config_internal(), help::section_is_referenced(), and help::topic_is_referenced().
std::vector< std::string > utils::split | ( | std::string const & | val, | |
char | c, | |||
int | flags | |||
) |
Definition at line 176 of file string_utils.cpp.
References REMOVE_EMPTY, strip(), and STRIP_SPACES.
Referenced by unit::ability_active(), unit::ability_affects_adjacent(), halo::add(), unit_type_data::unit_type_map_wrapper::add_advancefrom(), terrain_builder::add_constraints(), add_font_to_fontlist(), terrain_builder::add_images_from_config(), about::add_lines(), unit::add_modification(), add_relation(), terrain_builder::add_rotated_rules(), cutter::add_sub_image(), attack_type::apply_modification(), unit_type::build_full(), unit_type::build_help_index(), gui::menu::create_help_strings(), events::menu_handler::custom_command(), gui2::decode_colour(), default_generate_map(), font::del_tags(), events::menu_handler::do_search(), draw_background(), mp::wait::leader_preview_pane::draw_contents(), dialogs::campaign_preview_pane::draw_contents(), dialogs::unit_preview_pane::draw_contents(), gui::menu::draw_row(), formula_ai::evaluate(), exploder_point::exploder_point(), exploder_rect::exploder_rect(), unit_animation::fill_initial_animations(), frame_builder::frame_builder(), game_display::game_display(), mp::ui::gamelist_updated(), cave_map_generator::generate_chambers(), generate_name(), help::generate_topic_text(), help::generate_topics(), preprocessor_data::get_chunk(), unit::get_modification_advances(), get_tip_of_day(), unit::internal_matches_filter(), preferences::is_friend(), preferences::is_ignored(), gui::menu::style::item_size(), theme::label::label(), language_def::language_def(), server::load_config(), game_config::load_config(), font::load_font_config(), image::locator::load_image_sub_file(), main(), preferences::manager::manager(), game_events::manager::manager(), terrain_filter::match_internal(), attack_type::matches_filter(), gamemap::location::matches_range(), theme::object::modify_location(), unit_type::not_living(), font::nullify_markup(), terrain_builder::parse_config(), gamemap::location::parse_directions(), parse_location_range(), parse_ranges(), pick_one(), play_game(), formula_ai::play_turn(), playmp_controller::process_oos(), progressive_< T >::progressive_(), progressive_string::progressive_string(), random_generate_map(), random_generate_scenario(), unit::read(), gui2::read_flags(), read_player(), read_rect(), remove_relation(), font::render_text(), unit::resistance_filter_matches(), mp::connect::side::resolve_random(), resolve_rect(), about::set_about(), gui::button::set_label(), gamestatus::set_start_ToD(), about::show_about(), mp::connect::side::side(), attack_type::special_active(), terrain_builder::start_animation(), theme::status_item::status_item(), string2rgb(), team::team_info::team_info(), map_editor::terrain_palette::terrain_palette(), unit_animation::unit_animation(), unit_race::unit_race(), leader_list_manager::update_leader_list(), dfool::distance_evaluator::value(), and dfool::evaluator::value().
bool utils::string_bool | ( | const std::string & | str, | |
bool | def | |||
) |
Definition at line 396 of file string_utils.cpp.
Referenced by unit::ability_affects_self(), unit::add_modification(), preferences::adjust_gamma(), unit::advance_to(), unit_abilities::affects_side(), preferences::allow_observers(), ai::analyze_potential_recruit_combat(), ai::analyze_potential_recruit_movements(), preferences::animate_map(), preferences::ask_delete_saves(), attack::attack(), unit_type::build_full(), unit_type::build_help_index(), calculate_healing(), unit::can_recruit(), preferences::chat_timestamping(), ai::choose_move(), clear_shroud_unit(), preferences::compress_saves(), game_events::conditional_passed(), gui2::tformula< T >::convert(), preferences::countdown(), mp::create::create(), preferences::delete_saves(), preferences::display_manager::display_manager(), ai::do_move(), unit_abilities::effect::effect(), unit::end_turn(), extract_summary_data_from_save(), extract_summary_from_config(), preferences::flip_time(), preferences::fullscreen(), mp::wait::generate_menu(), reports::generate_report(), dialogs::unit_types_preview_pane::get_details(), unit::get_modification_advances(), get_player_info(), preferences::grid(), unit_ability_list::highest(), preferences::iconize_list(), preferences::idle_anim(), unit::incapacitated(), play_controller::init(), game_events::internal_conditional_passed(), unit::internal_matches_filter(), unit::invisible(), unit_movement_type::is_flying(), gamestatus::is_start_ToD(), hotkey::hotkey_item::load_from_config(), dialogs::load_game_dialog(), unit_ability_list::lowest(), preferences::manager::manager(), config::matches(), preferences::message_bell(), preferences::mouse_scroll_enabled(), unit::movement_cost(), preferences::music_on(), unit::overlaps(), gamemap::overlay(), cave_map_generator::place_items(), sound::play_music_config(), playsingle_controller::play_scenario(), unit::read(), wesnothd::banned::read(), gui2::read_flags(), read_player(), statistics::read_stats(), events::menu_handler::recall(), unit::redraw_unit(), mp::connect::side::resolve_random(), preferences::save_replays(), preferences::set_fullscreen(), gamestatus::set_start_ToD(), preferences::show_ai_moves(), preferences::show_combat(), preferences::show_floating_labels(), show_intro_part(), preferences::show_side_colours(), preferences::show_standing_animations(), preferences::show_tip_of_day(), mp::connect::side::side(), preferences::skip_mp_replay(), preferences::sort_list(), preferences::sound_on(), team::team(), team::team_info::team_info(), preferences::turbo(), preferences::turn_bell(), preferences::turn_dialog(), preferences::UI_sound_on(), events::menu_handler::unit_list(), battle_context::unit_stats::unit_stats(), leader_list_manager::update_leader_list(), preferences::upload_log(), settings::use_fog(), preferences::use_map_settings(), settings::use_random_start_time(), settings::use_shroud(), and wml_menu_item::wml_menu_item().
wide_string utils::string_to_wstring | ( | const std::string & | src | ) |
Definition at line 785 of file string_utils.cpp.
References utils::utf8_iterator::end(), ERR_GENERAL, and push_back().
Referenced by gui::textbox::append_text(), gui2::ttext_box::calculate_char_offset(), gui2::ttext_::copy_selection(), gui2::ttext_box::delete_selection(), gui::textbox::handle_event(), gui2::ttext_box::insert_char(), markov_prefixes(), gui2::ttext_::paste_selection(), gui::textbox::set_text(), and truncate_as_wstring().
std::string & utils::strip | ( | std::string & | str | ) |
Remove whitespace from the front and back of the string 'str'.
Definition at line 153 of file string_utils.cpp.
References notspace().
Referenced by paranthetical_split(), server::process_command(), quoted_split(), and split().
std::string & utils::strip_char | ( | std::string & | str, | |
const char | c | |||
) |
Removes character 'c' from the first and last position of the string 'str'.
Definition at line 168 of file string_utils.cpp.
void utils::truncate_as_wstring | ( | std::string & | str, | |
const size_t | size | |||
) |
Truncates a string.
If the string send has more than size utf-8 characters it will be truncated to this size. No assumptions can be made about the actual size of the string.
[in] | str | String which can be converted to utf-8. |
[out] | str | String which contains maximal size utf-8 characters. |
size | The size to truncate at. |
Definition at line 882 of file string_utils.cpp.
References string_to_wstring(), and wstring_to_string().
Referenced by terrain_label::check_text_length(), dialogs::load_game_dialog(), and chat_message::truncate_message().
std::string & utils::unescape | ( | std::string & | str | ) |
Remove all escape characters (backslash).
Definition at line 383 of file string_utils.cpp.
References pos.
Referenced by font::draw_text().
utf8_string utils::uppercase | ( | const utf8_string & | s | ) |
Returns an uppercased version of the string.
Definition at line 826 of file string_utils.cpp.
References boost::foreach_detail_::end(), and wchar_to_string().
std::string utils::wchar_to_string | ( | const wchar_t | c | ) |
Definition at line 778 of file string_utils.cpp.
References wstring_to_string().
Referenced by gui::textbox::add_text_line(), capitalize(), lowercase(), and uppercase().
bool utils::wildcard_string_match | ( | const std::string & | str, | |
const std::string & | match | |||
) |
Match using '*' as any number of characters (including none), and '?' as any one character.
Definition at line 499 of file string_utils.cpp.
Referenced by archive_dir(), wesnothd::ban_manager::is_ip_banned(), server::process_command(), and server::process_login().
bool utils::word_completion | ( | std::string & | text, | |
std::vector< std::string > & | wordlist | |||
) |
Try to complete the last word of 'text' with the 'wordlist'.
[in] | 'text' | Text where we try to complete the last word of. |
[out] | 'text' | Text with completed last word. |
[in] | 'wordlist' | A vector of strings to complete against. |
[out] | 'wordlist' | A vector of strings that matched 'text'. |
Definition at line 433 of file string_utils.cpp.
References chars_equal_insensitive().
Referenced by mp::ui::handle_key_event(), and gui::floating_textbox::tab().
bool utils::word_match | ( | const std::string & | message, | |
const std::string & | word | |||
) |
Check if a string contains a word.
Check if a message contains a word.
Definition at line 485 of file string_utils.cpp.
References is_word_boundary(), and boost::foreach_detail_::next().
Referenced by game_display::add_chat_message(), and mp::ui::process_message().
std::string utils::wstring_to_string | ( | const wide_string & | src | ) |
Definition at line 724 of file string_utils.cpp.
References ERR_GENERAL, and push_back().
Referenced by gui::textbox::add_text_line(), gui2::ttext_::copy_selection(), gui2::ttext_box::delete_selection(), unit_race::generate_name(), gui::textbox::handle_event(), gui2::ttext_box::insert_char(), gui::textbox::text(), truncate_as_wstring(), and wchar_to_string().
Generated by doxygen 1.5.5 on 23 May 2008 for The Battle for Wesnoth | Gna! | Forum | Wiki | CIA | devdocs |