#include <xml.h>
Public Types | |
enum | { START_DOCUMENT, END_DOCUMENT, START_TAG, END_TAG, TEXT, CDSECT, ENTITY_REF, IGNORABLE_WHITESPACE, PROCESSING_INSTRUCTION, COMMENT, DOCDECL, UNKNOWN } |
possible xml events More... | |
Public Member Functions | |
xmlParser_c (std::istream &is) | |
xmlParser_c (void) | |
~xmlParser_c (void) | |
std::string | getInputEncoding (void) |
void | defineEntityReplacementText (std::string entity, std::string value) |
int | getDepth (void) |
std::string | getPositionDescription (void) |
bool | isWhitespace (void) |
std::string | getText (void) |
return the text of the current text node. | |
const char * | getTextCharacters (int *poslen) |
std::string | getName (void) |
get the name of the current tag | |
std::string | getPrefix (void) |
bool | isEmptyElementTag (void) |
int | getAttributeCount (void) |
get the number of attributes in the current tag | |
std::string | getAttributeName (int index) |
get the name of one of the attributes | |
std::string | getAttributePrefix (int index) |
std::string | getAttributeValue (int index) |
get the value of one of the attributes | |
std::string | getAttributeValue (std::string name) |
get the value of the given attribut. | |
int | getEventType (void) |
int | next (void) |
go to the next xml event, and return the event type | |
int | nextToken (void) |
int | nextTag (void) |
void | prevTag (void) |
void | require (int type, std::string name) |
check, if the parser is in a certain state. | |
std::string | nextText (void) |
void | skipSubTree (void) |
skip the complete tree until the close of the current tag. | |
void | exception (std::string desc) |
throws XmlPullParserException with the current line and col. | |
Private Member Functions | |
void | commonInit (void) |
void | initBuf (void) |
std::string | state (int eventType) |
std::string * | ensureCapacity (std::string *arr, int required) |
void | nextImpl () |
common base for next and nextToken. | |
int | parseLegacy (bool push) |
void | parseDoctype (bool push) |
precondition: <! consumed | |
void | parseEndTag () |
int | peekType () |
std::string | get (int pos) |
void | push (int c) |
void | parseStartTag (bool xmldecl) |
Sets name and attributes. | |
void | pushEntity () |
result: isWspace; if the setName parameter is set, the name of the entity is stored in "name" | |
void | pushText (int delimiter, bool resolveEntities) |
types: '<': parse to any token (for nextToken ()) '"': parse to quote ' ': parse to whitespace or '>' | |
void | read (char c) |
int | read () |
int | peekbuf (int pos) |
Does never read more than needed. | |
std::string | readName () |
void | skip () |
Private Attributes | |
std::string | unexpected_eof |
std::string | illegal_type |
int | LEGACY |
int | XML_DECL |
std::string | version |
bool | standalone |
bool | processNsp |
bool | relaxed |
std::map< std::string, std::string > | entityMap |
int | depth |
std::vector< std::string > | nspStack |
std::vector< std::string > | elementStack |
int * | nspCounts |
int | nspSize |
std::string | encoding |
char * | srcBuf |
int | srcPos |
int | srcCount |
int | srcBuflength |
int | line |
int | column |
char * | txtBuf |
int | txtPos |
int | txtBufSize |
int | type |
std::string | text |
bool | isWspace |
bool | skipNextTag |
std::string | Ns |
std::string | prefix |
std::string | name |
bool | degenerated |
int | attributeCount |
std::vector< std::string > | attributes |
std::istream & | reader |
int | peek [2] |
A separate peek buffer seems simpler than managing wrap around in the first level read buffer. | |
int | peekCount |
bool | wasCR |
bool | unresolved |
bool | token |
As this parser is taken from an other project I don't understand it completely I only comment the functions that I used...
anonymous enum |
xmlParser_c::xmlParser_c | ( | std::istream & | is | ) |
References commonInit(), and initBuf().
xmlParser_c::xmlParser_c | ( | void | ) |
References commonInit(), and initBuf().
void xmlParser_c::commonInit | ( | void | ) | [private] |
References attributeCount, column, degenerated, depth, encoding, entityMap, LEGACY, line, name, Ns, nspCounts, nspSize, peekCount, relaxed, skipNextTag, srcCount, srcPos, standalone, START_DOCUMENT, type, unresolved, version, and XML_DECL.
Referenced by xmlParser_c().
void xmlParser_c::defineEntityReplacementText | ( | std::string | entity, | |
std::string | value | |||
) |
std::string* xmlParser_c::ensureCapacity | ( | std::string * | arr, | |
int | required | |||
) | [private] |
void xmlParser_c::exception | ( | std::string | desc | ) |
throws XmlPullParserException with the current line and col.
You may use this, if you have encounteted a faulty XML, e.g missing attribute or what not.
References column, line, state(), and type.
Referenced by assembly_c::assembly_c(), gridType_c::gridType_c(), parseDoctype(), parseEndTag(), parseLegacy(), parseStartTag(), problem_c::problem_c(), pushEntity(), puzzle_c::puzzle_c(), separation_c::separation_c(), separationInfo_c::separationInfo_c(), solution_c::solution_c(), state_c::state_c(), and voxel_c::voxel_c().
int xmlParser_c::getAttributeCount | ( | void | ) | [inline] |
get the number of attributes in the current tag
References attributeCount.
Referenced by puzzle_c::puzzle_c().
std::string xmlParser_c::getAttributeName | ( | int | index | ) |
std::string xmlParser_c::getAttributePrefix | ( | int | index | ) |
std::string xmlParser_c::getAttributeValue | ( | std::string | name | ) |
get the value of the given attribut.
If the attribut doesn't exist an empty string is returned
std::string xmlParser_c::getAttributeValue | ( | int | index | ) |
get the value of one of the attributes
Referenced by gridType_c::gridType_c(), problem_c::problem_c(), puzzle_c::puzzle_c(), separation_c::separation_c(), solution_c::solution_c(), and voxel_c::voxel_c().
int xmlParser_c::getDepth | ( | void | ) |
int xmlParser_c::getEventType | ( | void | ) | [inline] |
References type.
std::string xmlParser_c::getInputEncoding | ( | void | ) |
std::string xmlParser_c::getName | ( | void | ) | [inline] |
get the name of the current tag
References name.
Referenced by problem_c::problem_c(), puzzle_c::puzzle_c(), separation_c::separation_c(), solution_c::solution_c(), and state_c::state_c().
std::string xmlParser_c::getPositionDescription | ( | void | ) |
std::string xmlParser_c::getPrefix | ( | void | ) | [inline] |
References prefix.
std::string xmlParser_c::getText | ( | void | ) |
return the text of the current text node.
Only call when you are actually in a text node.
Referenced by assembly_c::assembly_c(), problem_c::problem_c(), puzzle_c::puzzle_c(), separation_c::separation_c(), separationInfo_c::separationInfo_c(), state_c::state_c(), and voxel_c::voxel_c().
const char * xmlParser_c::getTextCharacters | ( | int * | poslen | ) |
void xmlParser_c::initBuf | ( | void | ) | [private] |
References nspCounts, nspSize, srcBuf, srcBuflength, txtBuf, and txtBufSize.
Referenced by xmlParser_c().
bool xmlParser_c::isEmptyElementTag | ( | void | ) |
bool xmlParser_c::isWhitespace | ( | void | ) |
int xmlParser_c::next | ( | void | ) |
go to the next xml event, and return the event type
Referenced by assembly_c::assembly_c(), problem_c::problem_c(), pushText(), puzzle_c::puzzle_c(), separation_c::separation_c(), separationInfo_c::separationInfo_c(), state_c::state_c(), and voxel_c::voxel_c().
void xmlParser_c::nextImpl | ( | void | ) | [private] |
common base for next and nextToken.
Clears the state, except from txtPos and whitespace. Does not set the type variable
Clears the state, except from txtPos and whitespace. Does not set the type variable
References attributeCount, degenerated, depth, END_DOCUMENT, END_TAG, ENTITY_REF, IGNORABLE_WHITESPACE, isWspace, name, Ns, parseEndTag(), parseLegacy(), parseStartTag(), peekType(), prefix, pushEntity(), pushText(), START_TAG, TEXT, text, token, type, and XML_DECL.
int xmlParser_c::nextTag | ( | void | ) |
std::string xmlParser_c::nextText | ( | void | ) |
int xmlParser_c::nextToken | ( | void | ) |
void xmlParser_c::parseDoctype | ( | bool | push | ) | [private] |
precondition: <! consumed
References exception(), push(), read(), and unexpected_eof.
Referenced by parseLegacy().
void xmlParser_c::parseEndTag | ( | void | ) | [private] |
References depth, elementStack, exception(), name, Ns, prefix, read(), readName(), relaxed, and skip().
Referenced by nextImpl().
int xmlParser_c::parseLegacy | ( | bool | push | ) | [private] |
References attributeCount, attributes, CDSECT, column, COMMENT, DOCDECL, encoding, exception(), isWspace, line, parseDoctype(), parseStartTag(), peekbuf(), PROCESSING_INSTRUCTION, push(), read(), relaxed, standalone, txtPos, unexpected_eof, version, and XML_DECL.
Referenced by nextImpl().
void xmlParser_c::parseStartTag | ( | bool | xmldecl | ) | [private] |
Sets name and attributes.
References attributeCount, attributes, degenerated, depth, elementStack, exception(), getAttributeName(), name, Ns, nspCounts, nspSize, peekbuf(), prefix, pushText(), read(), readName(), relaxed, RESIZE_BUFFER, skip(), txtPos, and unexpected_eof.
Referenced by nextImpl(), and parseLegacy().
int xmlParser_c::peekbuf | ( | int | pos | ) | [private] |
Does never read more than needed.
Referenced by parseLegacy(), parseStartTag(), peekType(), and pushText().
int xmlParser_c::peekType | ( | void | ) | [private] |
References END_DOCUMENT, END_TAG, ENTITY_REF, LEGACY, peekbuf(), START_TAG, and TEXT.
Referenced by nextImpl().
void xmlParser_c::prevTag | ( | void | ) |
void xmlParser_c::push | ( | int | c | ) | [private] |
References isWspace, txtBuf, txtBufSize, and txtPos.
Referenced by parseDoctype(), parseLegacy(), and pushEntity().
void xmlParser_c::pushEntity | ( | void | ) | [private] |
result: isWspace; if the setName parameter is set, the name of the entity is stored in "name"
result: isWspace; if the setName parameter is set, the name of the entity is stored in "name"
References ENTITY_REF, entityMap, exception(), name, parseInt(), push(), read(), relaxed, token, txtPos, type, unexpected_eof, and unresolved.
Referenced by nextImpl().
void xmlParser_c::pushText | ( | int | delimiter, | |
bool | resolveEntities | |||
) | [private] |
types: '<': parse to any token (for nextToken ()) '"': parse to quote ' ': parse to whitespace or '>'
types: '<': parse to any token (for nextToken ()) '"': parse to quote ' ': parse to whitespace or '>'
References next(), and peekbuf().
Referenced by nextImpl(), and parseStartTag().
int xmlParser_c::read | ( | void | ) | [private] |
Referenced by parseDoctype(), parseEndTag(), parseLegacy(), parseStartTag(), and pushEntity().
void xmlParser_c::read | ( | char | c | ) | [private] |
std::string xmlParser_c::readName | ( | void | ) | [private] |
Referenced by parseEndTag(), and parseStartTag().
void xmlParser_c::require | ( | int | type, | |
std::string | name | |||
) |
check, if the parser is in a certain state.
type is one of the even type enum, name is used when a tag name is required, e.g
require(xmlParser_c::START_TAG, "puzzle")
Referenced by assembly_c::assembly_c(), gridType_c::gridType_c(), problem_c::problem_c(), puzzle_c::puzzle_c(), separation_c::separation_c(), separationInfo_c::separationInfo_c(), solution_c::solution_c(), state_c::state_c(), and voxel_c::voxel_c().
void xmlParser_c::skip | ( | void | ) | [private] |
Referenced by parseEndTag(), and parseStartTag().
void xmlParser_c::skipSubTree | ( | void | ) |
skip the complete tree until the close of the current tag.
Skip sub tree that is currently parser positioned on.
The stream must be at the beginning of a tag, otherwise an exception will be thrown
NOTE: parser must be on START_TAG and when funtion returns parser will be positioned on corresponding END_TAG.
Referenced by gridType_c::gridType_c(), problem_c::problem_c(), puzzle_c::puzzle_c(), separation_c::separation_c(), and solution_c::solution_c().
std::string xmlParser_c::state | ( | int | eventType | ) | [private] |
References CDSECT, COMMENT, DOCDECL, END_DOCUMENT, END_TAG, ENTITY_REF, IGNORABLE_WHITESPACE, PROCESSING_INSTRUCTION, START_DOCUMENT, START_TAG, and TEXT.
Referenced by exception().
int xmlParser_c::attributeCount [private] |
Referenced by commonInit(), getAttributeCount(), nextImpl(), parseLegacy(), and parseStartTag().
std::vector< std::string > xmlParser_c::attributes [private] |
Referenced by parseLegacy(), and parseStartTag().
int xmlParser_c::column [private] |
Referenced by commonInit(), exception(), and parseLegacy().
bool xmlParser_c::degenerated [private] |
Referenced by commonInit(), nextImpl(), and parseStartTag().
int xmlParser_c::depth [private] |
Referenced by commonInit(), nextImpl(), parseEndTag(), and parseStartTag().
std::vector< std::string > xmlParser_c::elementStack [private] |
Referenced by parseEndTag(), and parseStartTag().
std::string xmlParser_c::encoding [private] |
Referenced by commonInit(), and parseLegacy().
std::map< std::string, std::string > xmlParser_c::entityMap [private] |
Referenced by commonInit(), and pushEntity().
std::string xmlParser_c::illegal_type [private] |
bool xmlParser_c::isWspace [private] |
Referenced by nextImpl(), parseLegacy(), and push().
int xmlParser_c::LEGACY [private] |
Referenced by commonInit(), and peekType().
int xmlParser_c::line [private] |
Referenced by commonInit(), exception(), and parseLegacy().
std::string xmlParser_c::name [private] |
Referenced by commonInit(), getName(), nextImpl(), parseEndTag(), parseStartTag(), and pushEntity().
std::string xmlParser_c::Ns [private] |
Referenced by commonInit(), nextImpl(), parseEndTag(), and parseStartTag().
int* xmlParser_c::nspCounts [private] |
Referenced by commonInit(), initBuf(), parseStartTag(), and ~xmlParser_c().
int xmlParser_c::nspSize [private] |
Referenced by commonInit(), initBuf(), and parseStartTag().
std::vector< std::string > xmlParser_c::nspStack [private] |
int xmlParser_c::peek[2] [private] |
A separate peek buffer seems simpler than managing wrap around in the first level read buffer.
int xmlParser_c::peekCount [private] |
Referenced by commonInit().
std::string xmlParser_c::prefix [private] |
Referenced by getPrefix(), nextImpl(), parseEndTag(), and parseStartTag().
bool xmlParser_c::processNsp [private] |
std::istream& xmlParser_c::reader [private] |
bool xmlParser_c::relaxed [private] |
Referenced by commonInit(), parseEndTag(), parseLegacy(), parseStartTag(), and pushEntity().
bool xmlParser_c::skipNextTag [private] |
Referenced by commonInit().
char* xmlParser_c::srcBuf [private] |
Referenced by initBuf(), and ~xmlParser_c().
int xmlParser_c::srcBuflength [private] |
Referenced by initBuf().
int xmlParser_c::srcCount [private] |
Referenced by commonInit().
int xmlParser_c::srcPos [private] |
Referenced by commonInit().
bool xmlParser_c::standalone [private] |
Referenced by commonInit(), and parseLegacy().
std::string xmlParser_c::text [private] |
Referenced by nextImpl().
bool xmlParser_c::token [private] |
Referenced by nextImpl(), and pushEntity().
char* xmlParser_c::txtBuf [private] |
Referenced by get(), initBuf(), push(), and ~xmlParser_c().
int xmlParser_c::txtBufSize [private] |
int xmlParser_c::txtPos [private] |
Referenced by get(), parseLegacy(), parseStartTag(), push(), and pushEntity().
int xmlParser_c::type [private] |
Referenced by commonInit(), exception(), getEventType(), nextImpl(), and pushEntity().
std::string xmlParser_c::unexpected_eof [private] |
Referenced by parseDoctype(), parseLegacy(), parseStartTag(), and pushEntity().
bool xmlParser_c::unresolved [private] |
Referenced by commonInit(), and pushEntity().
std::string xmlParser_c::version [private] |
Referenced by commonInit(), and parseLegacy().
bool xmlParser_c::wasCR [private] |
int xmlParser_c::XML_DECL [private] |
Referenced by commonInit(), nextImpl(), and parseLegacy().