#include <textstyle.h>
Public Member Functions | |
| TextStyle (const std::string &s="", const char **vars=0) | |
| std::string | output (const std::string &text, const std::string &style="") |
| substitutes $text with text and $style with style | |
| std::string | output (SubstitutionMapping &subst_map) |
| for each i substitutes: subst_map[i].first occurrence with subst_map[i].second | |
| std::string | subst_style (const std::string &style="") |
| substitutes $style with style | |
| const std::string & | toString () const |
| TextStyle | compose (const TextStyle &inner) |
| substitutes $text with the string representation of inner e.g., if this is $text and inner is $text this will return $text | |
| void | update (const TextStyle &inner) |
| as compose, but acts on this instance | |
| void | update (const std::string &inner) |
| as compose, but acts on this instance | |
| void | update (const std::string &text, const std::string &style) |
| as output, but acts on this instance | |
| bool | containsStyleVar () const |
| bool | empty () const |
Private Types | |
| typedef std::vector< std::string > | StringVector |
| typedef std::vector< int > | IndexVector |
|
typedef std::map< std::string, IndexVector > | SubstitutionIndexes |
Private Member Functions | |
| void | build_vectors () |
| The parts vector contains the string repr split in parts: those that constant parts and those that represent $text and $style variables. | |
Private Attributes | |
| boost::regex | var_exp |
| the regular expression to find variable occurrences | |
| std::string | repr |
| StringVector | parts |
| contains all the string parts of this TextStyle. | |
| SubstitutionIndexes | substitutions |
| contains the indexes of parts where to substitute $vars. | |
| bool | invalid |
| whether to rebuild the vectors | |
) that will be replaced with specific elements, e.g., the actual style for the formatting, the text to format, etc.
| srchilite::TextStyle::TextStyle | ( | const std::string & | s = "", |
|
| const char ** | vars = 0 | |||
| ) |
| s | the representation | |
| vars | an array of string representing the variables in this TextStyle (e.g., {"linenum", "infilename", "infile", "outfile", 0}), the last element must be 0 |
| void srchilite::TextStyle::build_vectors | ( | ) | [private] |
The parts vector contains the string repr split in parts: those that constant parts and those that represent $text and $style variables.
For instance, if repr == "<span class=\"$style\">$text</span>", then we have:
Then style_substitutions contains the index(es) of parts corresponding to $style variable occurrences that will be substituted with values and text_substitutions is the same but for $text occurrences. Thus, in this case:
substitutes $text with the string representation of inner e.g., if this is $text and inner is $text this will return $text
| inner |
| bool srchilite::TextStyle::containsStyleVar | ( | ) | const |
| bool srchilite::TextStyle::empty | ( | ) | const |
| std::string srchilite::TextStyle::output | ( | SubstitutionMapping & | subst_map | ) |
for each i substitutes: subst_map[i].first occurrence with subst_map[i].second
| subst_map |
| string srchilite::TextStyle::output | ( | const std::string & | text, | |
| const std::string & | style = "" | |||
| ) |
substitutes $text with text and $style with style
First substitute in the vector parts the values for $text and $style and return a string with the substituted values.
| text | ||
| style |
| text | ||
| style |
| string srchilite::TextStyle::subst_style | ( | const std::string & | style = "" |
) |
substitutes $style with style
| style |
| const std::string& srchilite::TextStyle::toString | ( | ) | const [inline] |
| void srchilite::TextStyle::update | ( | const std::string & | text, | |
| const std::string & | style | |||
| ) |
as output, but acts on this instance
| text | ||
| style |
| void srchilite::TextStyle::update | ( | const std::string & | inner | ) |
as compose, but acts on this instance
| inner |
| void srchilite::TextStyle::update | ( | const TextStyle & | inner | ) |
as compose, but acts on this instance
| inner |
1.5.9