Classes | |
class | eagine::fixed_size_string< N > |
String with maximum fixed-size internal storage. More... | |
class | eagine::format_string_and_list< N > |
Helper class used in implementation of string variable substitution. More... | |
struct | eagine::variable_substitution_options |
Options for string variable substitution customization. More... | |
class | eagine::string_variable_map |
Class storing a map of variable names to values, doing string substitution. More... | |
class | eagine::basic_string_path |
Basic class storing paths made of string elements. More... | |
class | eagine::basic_string_span< C, P, S > |
Specialization of memory::basic_span for character string containers. More... | |
struct | eagine::basic_str_view_less< Str, Spn > |
Comparator template for standard string - string span comparisons. More... | |
class | eagine::basic_c_str< C, P, S > |
Helper template for getting zero-terminated strings from string spans. More... | |
Typedefs | |
using | eagine::string_span = basic_string_span< char > |
Alias for mutable string spans. | |
using | eagine::string_view = basic_string_span< const char > |
Alias for const string views. | |
using | eagine::str_view_less = basic_str_view_less< std::string, string_view > |
Comparator template for standard string - string_view comparisons. | |
Functions | |
template<span_size_t N> | |
static auto | eagine::make_fixed_size_string (const char(&str)[N]) noexcept |
Creates a fixed_size_string from a C-string literal. | |
template<span_size_t N1, span_size_t N2> | |
static auto | eagine::operator+ (const fixed_size_string< N1 > &s1, const fixed_size_string< N2 > &s2) noexcept |
Concatenation operator for fixed_size_string. | |
template<int I> | |
static auto | eagine::to_fixed_size_string (int_constant< I >, std::enable_if_t<(I >=0) &&(I< 10)> *=nullptr) noexcept |
Converts a single-digit decimal number into fixed_size_string. | |
template<int I> | |
static auto | eagine::to_fixed_size_string (int_constant< I >, std::enable_if_t<(I > 9)> *=nullptr) noexcept |
Converts a multi-digit decimal number into fixed_size_string. | |
template<int I> | |
static auto | eagine::to_fixed_size_string (int_constant< I >, std::enable_if_t<(I< 0)> *=nullptr) noexcept |
Converts a negative decimal number into fixed_size_string. | |
template<span_size_t N> | |
static auto | eagine::operator% (format_string_and_list< N > &&fsal, std::string &&val) noexcept -> format_string_and_list< N+1 > |
Operator for adding variable name and value for string formatting. More... | |
static auto | eagine::format (std::string &&fmt_str) noexcept -> format_string_and_list< 0 > |
Function taking a format string, returning an object for variable specification. | |
auto | eagine::substitute_variables_into (std::string &dst, string_view src, const callable_ref< optionally_valid< string_view >(string_view)> &translate, variable_substitution_options={}) -> std::string & |
Substitutes variable values by using translate, from src into dst. More... | |
auto | eagine::substitute_variables (string_view src, const callable_ref< optionally_valid< string_view >(string_view)> &translate, variable_substitution_options={}) -> std::string |
Substitutes variable values by using translate, from src. More... | |
auto | eagine::substitute_variables (const std::string &str, span< const std::string > strings, variable_substitution_options={}) -> std::string |
Substitutes variable values by using translate, from src into dst. More... | |
auto | eagine::substitute_variables (const std::string &str, const std::map< std::string, std::string, str_view_less > &dictionary, variable_substitution_options={}) -> std::string |
Substitutes variable values by using translate, from src. More... | |
template<typename C , typename T , typename A , typename P1 , typename P2 , typename S1 , typename S2 > | |
auto | eagine::string_replace (std::basic_string< C, T, A > &str, memory::basic_span< const C, P1, S1 > from, memory::basic_span< const C, P2, S2 > to) -> std::basic_string< C, T, A > & |
Replaces all occurrences of from with to in the given string. | |
template<typename C , typename T , typename A , typename P1 , typename P2 , typename S1 , typename S2 > | |
auto | eagine::string_replace (std::basic_string< C, T, A > &str, span< const std::tuple< basic_string_span< const C, P1, S1 >, basic_string_span< const C, P2, S2 >>> dict) -> std::basic_string< C, T, A > & |
Replaces all occurrences of the string specifed in the dictionary. | |
template<typename C , typename P , typename S > | |
static constexpr auto | eagine::std_view (memory::basic_span< C, P, S > spn) noexcept -> std::basic_string_view< std::remove_const_t< C >> |
Converts a basic_span of characters to string_span. | |
template<typename C , typename P , typename S > | |
static constexpr auto | eagine::to_string (memory::basic_span< C, P, S > spn) -> std::basic_string< std::remove_const_t< C >> |
Converts a basic_span of characters to standard string. | |
template<typename C , typename T , typename A , typename P , typename S > | |
static constexpr auto | eagine::assign_to (std::basic_string< C, T, A > &str, memory::basic_span< const C, P, S > spn) -> auto & |
Assigns the contents of a span of characters to a standard string. | |
template<typename C , typename T , typename A , typename P , typename S > | |
static constexpr auto | eagine::append_to (std::basic_string< C, T, A > &str, memory::basic_span< const C, P, S > spn) -> auto & |
Appends the contents of a span of characters to a standard string. | |
template<typename C , typename P , typename S > | |
static constexpr auto | eagine::c_str (memory::basic_span< C, P, S > s) -> std::enable_if_t< std::is_convertible_v< memory::basic_span< C, P, S >, basic_string_span< C, P, S >>, basic_c_str< C, P, S >> |
Functions that construct a basic_c_str from a basic_string_span. | |
|
inlinestaticnoexcept |
Operator for adding variable name and value for string formatting.
auto eagine::substitute_variables | ( | const std::string & | str, |
const std::map< std::string, std::string, str_view_less > & | dictionary, | ||
variable_substitution_options | = {} |
||
) | -> std::string |
Substitutes variable values by using translate, from src.
This function takes the format string src
, finds variable references using substitution options and substitutes the variables with their values using the dictionary map and returns the resulting string.
auto eagine::substitute_variables | ( | const std::string & | str, |
span< const std::string > | strings, | ||
variable_substitution_options | = {} |
||
) | -> std::string |
Substitutes variable values by using translate, from src into dst.
This function takes the format string src
, finds numeric variable references using substitution options and substitutes the variables with their values the strings span and returns the resulting string.
auto eagine::substitute_variables | ( | string_view | src, |
const callable_ref< optionally_valid< string_view >(string_view)> & | translate, | ||
variable_substitution_options | = {} |
||
) | -> std::string |
Substitutes variable values by using translate, from src.
This function takes the format string src
, finds variable references using substitution options and substitutes the variables with their values using the translation function and returns the resulting string.
Referenced by eagine::string_variable_map::operator()(), and eagine::string_variable_map::subst_variables().
auto eagine::substitute_variables_into | ( | std::string & | dst, |
string_view | src, | ||
const callable_ref< optionally_valid< string_view >(string_view)> & | translate, | ||
variable_substitution_options | = {} |
||
) | -> std::string & |
Substitutes variable values by using translate, from src into dst.
This function takes the format string src
, finds variable references using substitution options and substitutes the variables with their values using the translation function into dst
.