# opentl::core::parser::XMLParser Class Reference

class to fully scan a xml document More...

Inherited by opentl::core::parser::COLLADAParser, and opentl::core::parser::FootprintParser.

List of all members.

## Classes
struct | TagInfo
struct | Token
struct | XMLTag
## Public Types
## Public Member Functions
XMLTag * | find (XMLTag *tag, const char *elemname, const char *n="", const char *v="")
XMLTag * | find (XMLTag *tag, std::string elemname, std::string n="", std::string v="")
std::vector< XMLParser::XMLTag * > | findall (XMLTag *tag, std::string elemname, std::string n, std::string v)
std::vector< XMLParser::XMLTag * > | findall (XMLTag *tag, const char *elemname, const char *n="", const char *v="")
int | getFilesize (const char *filename)
bool | getnexttoken (char *buffer, int &pos, Token &token, int length)
XMLTag * | getRootTag ()
bool | isWhitespace (char c)
std::string | itoa (int number)
void | output (XMLParser::XMLTag *tag, int depth)
void | output ()
int | parseFile (std::string filename)
bool | toBool (const std::string &s)
double | toDouble (const std::string &s)
int | toInt (const std::string &s)
void | trim (char *str)
| XMLParser ()
virtual | ~XMLParser ()
## Protected Attributes
int | m_lineNr
XMLTag * | m_root

## Detailed Description

class to fully scan a xml document

Author:
  Thomas Friedlhuber <friedlhu@in.tum.de>

## Member Enumeration Documentation

enum opentl::core::parser::XMLParser::TAGSTATE

possible states for tag during parsing process

Enumerator:

  COMMENT |
  BEGIN |
  NEWTAG |
  READNAME |
  READATTRIBUTE |
  READVALUE |
  PRECLOSEDTAG |
  READARRAY |
  READELEMENTS |
  REOPENTAG |
  NAMECORRECT |

enum opentl::core::parser::XMLParser::TOKENTYPE

possible states for token during parsing process

Enumerator:

  EMPTY |
  OPENTAG |
  OPENTAGSLASH |
  CLOSETAG |
  CLOSETAGSLASH |
  EQUALCHAR |
  NAME |
  STRVALUE |
  ARRAYVALUE |
  COMMENTBEGIN |
  COMMENTEND |

## Constructor & Destructor Documentation

opentl::core::parser::XMLParser::XMLParser | ( |  | ) |

constructor

virtual opentl::core::parser::XMLParser::~XMLParser | ( |  | ) | `[virtual]`

deconstructor

## Member Function Documentation

XMLTag* opentl::core::parser::XMLParser::find | ( | XMLTag * | tag,
|  | const char * | elemname,
|  | const char * | n = `""`,
|  | const char * | v = `""` |
| ) |  |  |

search for a tag

Parameters:

  | tag | pointer to tag the search should start
  | elemname | name of search tag
  | n | attribute name of search tag
  | v | attribute value of search tag

Returns:
  the first tag founded

XMLTag* opentl::core::parser::XMLParser::find | ( | XMLTag * | tag,
|  | std::string | elemname,
|  | std::string | n = `""`,
|  | std::string | v = `""` |
| ) |  |  |

search for a tag

Parameters:

  | tag | pointer to tag the search should start
  | elemname | name of search tag
  | n | attribute name of search tag
  | v | attribute value of search tag

Returns:
  the first tag founded

std::vector<XMLParser::XMLTag*> opentl::core::parser::XMLParser::findall | ( | XMLTag * | tag,
|  | std::string | elemname,
|  | std::string | n,
|  | std::string | v |
| ) |  |  |

search for a sequence of tags

Parameters:

  | tag | pointer to tag the search should start
  | elemname | name of search tag
  | n | attribute name of search tag
  | v | attribute value of search tag

Returns:
  all tags founded

std::vector<XMLParser::XMLTag*> opentl::core::parser::XMLParser::findall | ( | XMLTag * | tag,
|  | const char * | elemname,
|  | const char * | n = `""`,
|  | const char * | v = `""` |
| ) |  |  |

search for a sequence of tags

Parameters:

  | tag | pointer to tag the search should start
  | elemname | name of search tag
  | n | attribute name of search tag
  | v | attribute value of search tag

Returns:
  all tags founded

int opentl::core::parser::XMLParser::getFilesize | ( | const char * | filename | ) |

get filesize of a file

Parameters:

  | filename | name of file

Returns:
  filesize

bool opentl::core::parser::XMLParser::getnexttoken | ( | char * | buffer,
|  | int & | pos,
|  | Token & | token,
|  | int | length |
| ) |  |  |

search for the next token

Parameters:

  | buffer | buffer including tokens
  | pos | read position in buffer
  | token | structure to store token result
  | length | length of buffer

Returns:
  false if a parsing error occured else true

XMLTag* opentl::core::parser::XMLParser::getRootTag | ( |  | ) |

bool opentl::core::parser::XMLParser::isWhitespace | ( | char | c | ) |

determine if a character is a whitespace

Parameters:

  | c | character to check

Returns:
  true if whitespace else false

std::string opentl::core::parser::XMLParser::itoa | ( | int | number | ) |

converts an integer number to a string value

Parameters:

  | number | integer number

Returns:
  string value

void opentl::core::parser::XMLParser::output | ( | XMLParser::XMLTag * | tag,
|  | int | depth |
| ) |  |  |

print tag values to screen

Parameters:

  | tag | corresponding tag
  | depth | xml parsing depth of tag

void opentl::core::parser::XMLParser::output | ( |  | ) |

print parsing result to screen

int opentl::core::parser::XMLParser::parseFile | ( | std::string | filename | ) |

parse a xml file

Parameters:

  | filename | name of file

Returns:
  1 = OK

bool opentl::core::parser::XMLParser::toBool | ( | const std::string & | s | ) |

convert a string value to an bool value

Parameters:

  | s | string value

Returns:
  bool value

double opentl::core::parser::XMLParser::toDouble | ( | const std::string & | s | ) |

convert a string value to a double number

Parameters:

  | s | string value

Returns:
  double value

int opentl::core::parser::XMLParser::toInt | ( | const std::string & | s | ) |

convert a string value to an integer number

Parameters:

  | s | string value

Returns:
  integer value

void opentl::core::parser::XMLParser::trim | ( | char * | str | ) |

remove white spaces on the left and right side of a string

Parameters:

  | str | string

## Member Data Documentation

int opentl::core::parser::XMLParser::m_lineNr`[protected]`

current line number of parsing process

XMLTag* opentl::core::parser::XMLParser::m_root`[protected]`

document root xml tag