19 #include <boost/regex.hpp>
23 #define STYLE_VAR_TEXT "$style" // the text of the style variable
24 #define TEXT_VAR_TEXT "$text" // the text of the text variable
25 #define STYLE_VAR "\\" STYLE_VAR_TEXT // the name of the style variable as regexp
26 #define TEXT_VAR "\\" TEXT_VAR_TEXT // the name of the text variable as regexp
38 typedef std::vector<std::string> StringVector;
39 typedef std::vector<int> IndexVector;
40 typedef std::map<std::string, IndexVector> SubstitutionIndexes;
65 TextStyle(
const std::string &s =
"",
const char **vars = 0);
74 std::string
output(
const std::string &text,
const std::string &style =
"");
81 std::string
output(SubstitutionMapping &subst_map);
88 std::string
subst_style(
const std::string &style =
"");
116 void update(
const std::string &inner);
123 void update(
const std::string &text,
const std::string &style);
void update(const TextStyle &inner)
as compose, but acts on this instance
Definition: textstyle.cpp:172
TextStyle compose(const TextStyle &inner)
substitutes $text with the string representation of inner e.g., if this is $text and inner is $text t...
Definition: textstyle.cpp:152
bool containsStyleVar() const
Definition: textstyle.cpp:178
C++ class: doctemplate.h.
Definition: bufferedoutput.cpp:13
StringVector parts
contains all the string parts of this TextStyle.
Definition: textstyle.h:48
Represents a formatting template where there can be some variables (starting with $...
Definition: textstyle.h:36
bool empty() const
Definition: textstyle.cpp:185
SubstitutionIndexes substitutions
contains the indexes of parts where to substitute $vars.
Definition: textstyle.h:51
const std::string & toString() const
Definition: textstyle.h:93
std::map< std::string, std::string > SubstitutionMapping
map for substitutions
Definition: textstyle.h:28
boost::regex var_exp
the regular expression to find variable occurrences
Definition: textstyle.h:43
TextStyle(const std::string &s="", const char **vars=0)
Definition: textstyle.cpp:23
void build_vectors()
The parts vector contains the string repr split in parts: those that constant parts and those that re...
Definition: textstyle.cpp:68
std::string output(const std::string &text, const std::string &style="")
substitutes $text with text and $style with style
Definition: textstyle.cpp:110
std::string subst_style(const std::string &style="")
substitutes $style with style
Definition: textstyle.cpp:146
bool invalid
whether to rebuild the vectors
Definition: textstyle.h:54