ContRap-Core
Public Member Functions | Protected Attributes

crp::XMLStreamParser Class Reference

Class XMLStreamParser is a stream based XML parser for text strings. More...

#include <xmlparser.h>

Public Member Functions

 XMLStreamParser (const std::string &text)
 Starts parsing of a string.
 ~XMLStreamParser ()
 Stops parsing.
bool next_start_tag ()
 Moves to the next start tag.
bool next_end_tag ()
 Moves to the next end tag.
bool is_at_end ()
 Returns true if the parser has no more tokens left to parse.
const std::string & get_tag () const
 Returns the name of the current tag.
const std::map< std::string,
std::string > & 
get_attributes () const
 Returns the attributes of the current tag.
const std::string & get_text () const
 Returns the current text.

Protected Attributes

StringTokenizer tokenizer
 String tokenizer which parses the string.
std::string tag
 Current tag.
std::map< std::string,
std::string > 
attributes
 Current attributes.
std::string text
 Text.

Detailed Description

Class XMLStreamParser is a stream based XML parser for text strings.


Constructor & Destructor Documentation

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

Starts parsing of a string.

Parameters:
textString to parse
crp::XMLStreamParser::~XMLStreamParser ( )

Stops parsing.


Member Function Documentation

const std::map<std::string, std::string>& crp::XMLStreamParser::get_attributes ( ) const [inline]

Returns the attributes of the current tag.

Returns:
Attributes of the current tag
const std::string& crp::XMLStreamParser::get_tag ( ) const [inline]

Returns the name of the current tag.

Returns:
Name of the current tag
const std::string& crp::XMLStreamParser::get_text ( ) const [inline]

Returns the current text.

Returns:
Current text
bool crp::XMLStreamParser::is_at_end ( )

Returns true if the parser has no more tokens left to parse.

Returns:
True if there is nothing more to parse
bool crp::XMLStreamParser::next_end_tag ( )

Moves to the next end tag.

This operation only changes the tag name regardless of which tags the parser passes until the end tag is reached.

Returns:
True on success
bool crp::XMLStreamParser::next_start_tag ( )

Moves to the next start tag.

When the parser reaches the next start tag it reads its attributes and the text, which follows immediately after the tag. The parameters can be queried by calling to one of the query methods.

Returns:
True on success

Field Documentation

std::map<std::string, std::string> crp::XMLStreamParser::attributes [protected]

Current attributes.

std::string crp::XMLStreamParser::tag [protected]

Current tag.

std::string crp::XMLStreamParser::text [protected]

Text.

String tokenizer which parses the string.


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