Go to the documentation of this file.
9 #ifndef EAGINE_STR_VAR_SUBST_HPP
10 #define EAGINE_STR_VAR_SUBST_HPP
13 #include "config/basic.hpp"
47 variable_substitution_options = {}) -> std::string&;
59 variable_substitution_options = {}) -> std::string;
69 const std::string& str,
70 span<const std::string> strings,
71 variable_substitution_options = {}) -> std::string;
81 const std::string& str,
82 const std::map<std::string, std::string, str_view_less>& dictionary,
83 variable_substitution_options = {}) -> std::string;
92 _dict.emplace(std::move(name), std::move(value));
102 auto operator()(
const std::string& str)
const -> std::string {
107 std::map<std::string, std::string, str_view_less> _dict{};
112 #if !EAGINE_LINK_LIBRARY || defined(EAGINE_IMPLEMENTING_LIBRARY)
113 #include <eagine/str_var_subst.inl>
116 #endif // EAGINE_STR_VAR_SUBST_HPP
basic_string_span< const char > string_view
Alias for const string views.
Definition: string_span.hpp:116
static auto translate(std::shared_ptr< generator > gen, std::array< float, 3 > d) noexcept
Constructs instances of translated_gen modifier.
Definition: translated.hpp:41
Common code is placed in this namespace.
Definition: eagine.hpp:21
char leading_sign
The variable reference leading sign.
Definition: str_var_subst.hpp:27
auto subst_variables(const std::string &str) const -> std::string
Uses the stored variables to do substitution in the given string.
Definition: str_var_subst.hpp:97
basic_callable_ref< Sig, is_noexcept_function_v< Sig > > callable_ref
Alias for callable object references.
Definition: callable_ref.hpp:191
auto 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.
Class storing a map of variable names to values, doing string substitution.
Definition: str_var_subst.hpp:87
char closing_bracket
The variable reference closing (right) bracket.
Definition: str_var_subst.hpp:33
bool keep_untranslated
Keep the untranslated variable references in the format string.
Definition: str_var_subst.hpp:24
char opening_bracket
The variable reference opening (left) bracket.
Definition: str_var_subst.hpp:30
auto set(std::string name, std::string value) -> string_variable_map &
Set the value of a variable with name.
Definition: str_var_subst.hpp:91
auto 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.
Options for string variable substitution customization.
Definition: str_var_subst.hpp:22
auto operator()(const std::string &str) const -> std::string
Uses the stored variables to do substitution in the given string.
Definition: str_var_subst.hpp:102