ContRap-Core
Public Member Functions | Protected Member Functions | Protected Attributes

crp::XMLTextLayout Class Reference

Class XMLTextLayout is a layout class to print XML formatted strings to console or to a text file. More...

#include <xmltextlayout.h>

Inheritance diagram for crp::XMLTextLayout:
crp::XMLParser

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 LayoutBoxget_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, XMLPoollayouts
 Structure for the layout of different objects.

Detailed Description

Class XMLTextLayout is a layout class to print XML formatted strings to console or to a text file.


Constructor & Destructor Documentation

crp::XMLTextLayout::XMLTextLayout ( const std::string &  text)

Creates a new layout instance from a formatted message.

Parameters:
textXML-formatted string
crp::XMLTextLayout::~XMLTextLayout ( )

Cleans up the memory.


Member Function Documentation

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

Parameters:
descriptorLayout 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.

Returns:
Root box of the layout
bool crp::XMLTextLayout::layout ( )

Creates a layout from scratch using the current text.

Returns:
True if the layout was successful
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.

Parameters:
textText to layout
Returns:
True if no errors occured

Reimplemented from crp::XMLParser.

std::string crp::XMLTextLayout::to_string ( )

Prints the layout to a string.

Returns:
String with the layout

Field Documentation

std::map<std::string, XMLPool> crp::XMLTextLayout::layouts [protected]

Structure for the layout of different objects.

Root box.

std::stack<LayoutBox*> crp::XMLTextLayout::stack [protected]

Stack of boxes.


The documentation for this class was generated from the following file: