19#include <boost/regex.hpp>
23#define STYLE_VAR_TEXT "$style"
24#define TEXT_VAR_TEXT "$text"
25#define STYLE_VAR "\\" STYLE_VAR_TEXT
26#define TEXT_VAR "\\" TEXT_VAR_TEXT
28typedef std::map<std::string, std::string> SubstitutionMapping;
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 =
"");
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);
Represents a formatting template where there can be some variables (starting with $,...
Definition: textstyle.h:36
bool containsStyleVar() const
Definition: textstyle.cpp:178
boost::regex var_exp
the regular expression to find variable occurrences
Definition: textstyle.h:43
void update(const TextStyle &inner)
as compose, but acts on this instance
Definition: textstyle.cpp:172
const std::string & toString() const
Definition: textstyle.h:93
StringVector parts
contains all the string parts of this TextStyle.
Definition: textstyle.h:48
SubstitutionIndexes substitutions
contains the indexes of parts where to substitute $vars.
Definition: textstyle.h:51
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 invalid
whether to rebuild the vectors
Definition: textstyle.h:54
std::string subst_style(const std::string &style="")
substitutes $style with style
Definition: textstyle.cpp:146
std::string output(const std::string &text, const std::string &style="")
substitutes $text with text and $style with style
Definition: textstyle.cpp:110
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
bool empty() const
Definition: textstyle.cpp:185
C++ class: doctemplate.h.
Definition: bufferedoutput.cpp:13
std::map< std::string, std::string > SubstitutionMapping
map for substitutions
Definition: textstyle.h:28