ContRap-Core
|
Class XMLTextLayout is a layout class to print XML formatted strings to console or to a text file. More...
#include <xmltextlayout.h>
Public Member Functions | |
XMLTextLayout (const std::string &text) | |
Creates a new layout instance from a formatted message. | |
~XMLTextLayout () | |
Cleans up the memory. | |
bool | set_text (const std::string &text) |
Sets the formatted text string and layouts the contents. | |
bool | layout () |
Creates a layout from scratch using the current text. | |
const LayoutBox & | get_root () const |
Returns the root box of the layout. | |
void | add_layout (const std::string &descriptor) |
Adds a layout descriptor in the following format tag:V|H <E>... | |
std::string | to_string () |
Prints the layout to a string. | |
Protected Member Functions | |
void | layout (StringTokenizer &tokenizer, LayoutBox &parent) |
Recursive layout functions. | |
void | layout_matrix (StringTokenizer &tokenizer, LayoutBox &parent) |
virtual bool | enter (const std::string &tag, std::map< std::string, std::string > &attributes, bool end) |
Event functions are called on entering, parsing and leaving tags. | |
virtual bool | content (const std::string &tag, std::map< std::string, std::string > &attributes, const std::string &value, int count) |
virtual bool | leave (const std::string &tag, std::map< std::string, std::string > &attributes) |
Protected Attributes | |
LayoutBox | root |
Root box. | |
std::stack< LayoutBox * > | stack |
Stack of boxes. | |
std::map< std::string, XMLPool > | layouts |
Structure for the layout of different objects. |
Class XMLTextLayout is a layout class to print XML formatted strings to console or to a text file.
crp::XMLTextLayout::XMLTextLayout | ( | const std::string & | text | ) |
Creates a new layout instance from a formatted message.
text | XML-formatted string |
crp::XMLTextLayout::~XMLTextLayout | ( | ) |
Cleans up the memory.
void crp::XMLTextLayout::add_layout | ( | const std::string & | descriptor | ) |
Adds a layout descriptor in the following format tag:V|H <E>...
|<C1>...<CN><L>.... The dots stay for symbol descriptors. V or H stands for vertical or horizontal basis layout. VG T M B P Vertical glyph with the symbol T at the top M in the middle and B at the bottom. If the box has a height two then only T and B are used. If the box has a height one then P is used. HG L M R P Horizontal glyph
descriptor | Layout descriptor |
virtual bool crp::XMLTextLayout::content | ( | const std::string & | tag, |
std::map< std::string, std::string > & | attributes, | ||
const std::string & | value, | ||
int | count | ||
) | [protected, virtual] |
Reimplemented from crp::XMLParser.
virtual bool crp::XMLTextLayout::enter | ( | const std::string & | tag, |
std::map< std::string, std::string > & | attributes, | ||
bool | end | ||
) | [protected, virtual] |
Event functions are called on entering, parsing and leaving tags.
A false returned by an event function results in an error break.
Reimplemented from crp::XMLParser.
const LayoutBox& crp::XMLTextLayout::get_root | ( | ) | const [inline] |
Returns the root box of the layout.
bool crp::XMLTextLayout::layout | ( | ) |
Creates a layout from scratch using the current text.
void crp::XMLTextLayout::layout | ( | StringTokenizer & | tokenizer, |
LayoutBox & | parent | ||
) | [protected] |
Recursive layout functions.
void crp::XMLTextLayout::layout_matrix | ( | StringTokenizer & | tokenizer, |
LayoutBox & | parent | ||
) | [protected] |
virtual bool crp::XMLTextLayout::leave | ( | const std::string & | tag, |
std::map< std::string, std::string > & | attributes | ||
) | [protected, virtual] |
Reimplemented from crp::XMLParser.
bool crp::XMLTextLayout::set_text | ( | const std::string & | text | ) |
Sets the formatted text string and layouts the contents.
text | Text to layout |
Reimplemented from crp::XMLParser.
std::string crp::XMLTextLayout::to_string | ( | ) |
Prints the layout to a string.
std::map<std::string, XMLPool> crp::XMLTextLayout::layouts [protected] |
Structure for the layout of different objects.
LayoutBox crp::XMLTextLayout::root [protected] |
Root box.
std::stack<LayoutBox*> crp::XMLTextLayout::stack [protected] |
Stack of boxes.