The Battle for Wesnoth  1.17.12+dev
Classes | Namespaces | Macros | Functions | Variables
string_utils.cpp File Reference
#include "formula/string_utils.hpp"
#include "variable.hpp"
#include "config.hpp"
#include "log.hpp"
#include "gettext.hpp"
Include dependency graph for string_utils.cpp:

Go to the source code of this file.


class  utils::string_map_variable_set< T >




#define GETTEXT_DOMAIN   "wesnoth-lib"
#define ERR_NG   LOG_STREAM(err, log_engine)
#define WRN_NG   LOG_STREAM(warn, log_engine)


static bool two_dots (char a, char b)
static std::string do_interpolation (const std::string &str, const variable_set &set)
std::string utils::interpolate_variables_into_string (const std::string &str, const string_map *const symbols)
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 utils::format_timespan (std::time_t time, bool detailed=false)
 Formats a timespan into human-readable text for player authentication functions. 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)
int edit_distance_approx (const std::string &str_1, const std::string &str_2)
 Approximately calculates the distance between two strings. More...


static lg::log_domain log_engine ("engine")
std::string(* utils::detail::evaluate_formula )(const std::string &formula) = nullptr

Macro Definition Documentation


#define ERR_NG   LOG_STREAM(err, log_engine)

Definition at line 27 of file string_utils.cpp.

Referenced by do_interpolation().


#define GETTEXT_DOMAIN   "wesnoth-lib"

Definition at line 17 of file string_utils.cpp.


#define WRN_NG   LOG_STREAM(warn, log_engine)

Definition at line 28 of file string_utils.cpp.

Referenced by do_interpolation().

Function Documentation

◆ do_interpolation()

static std::string do_interpolation ( const std::string &  str,
const variable_set set 

◆ edit_distance_approx()

int edit_distance_approx ( const std::string &  str_1,
const std::string &  str_2 

Approximately calculates the distance between two strings.

Inspired in the Levenshtein distance, but made simpler to avoid using recursion and wasting resources.

The consequence is that the function gets "lost" after two consecutive differences.

str_1First string to compare
str_2Second string to compare

Definition at line 360 of file string_utils.cpp.

References i.

Referenced by events::map_command_handler< chat_command_handler >::dispatch().

◆ two_dots()

static bool two_dots ( char  a,
char  b 

Definition at line 30 of file string_utils.cpp.

Referenced by do_interpolation().

◆ 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 for more info.

Definition at line 340 of file string_utils.cpp.

References translation::dsgettext(), utils::interpolate_variables_into_string(), and wfl::msg().

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 

Variable Documentation

◆ log_engine

lg::log_domain log_engine("engine")