xmlParser_c Class Reference

A simple, pull based XML parser. More...

#include <xml.h>

Collaboration diagram for xmlParser_c:

Collaboration graph
[legend]

List of all members.

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: &lt! 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


Detailed Description

A simple, pull based XML parser.

As this parser is taken from an other project I don't understand it completely I only comment the functions that I used...


Member Enumeration Documentation

anonymous enum

possible xml events

Enumerator:
START_DOCUMENT 
END_DOCUMENT 
START_TAG  an open tag (can be both tag types)
END_TAG  the end of a node (either closing tag, or short tag)
TEXT  a text node
CDSECT 
ENTITY_REF 
IGNORABLE_WHITESPACE 
PROCESSING_INSTRUCTION 
COMMENT 
DOCDECL 
UNKNOWN 


Constructor & Destructor Documentation

xmlParser_c::xmlParser_c ( std::istream &  is  ) 

References commonInit(), and initBuf().

xmlParser_c::xmlParser_c ( void   ) 

References commonInit(), and initBuf().

xmlParser_c::~xmlParser_c ( void   ) 

References nspCounts, srcBuf, and txtBuf.


Member Function Documentation

void xmlParser_c::commonInit ( void   )  [private]

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().

std::string xmlParser_c::get ( int  pos  )  [private]

References txtBuf, and txtPos.

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  ) 

get the name of one of the attributes

Referenced by parseStartTag(), and puzzle_c::puzzle_c().

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  ) 

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]

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   ) 

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: &lt! consumed

References exception(), push(), read(), and unexpected_eof.

Referenced by parseLegacy().

void xmlParser_c::parseEndTag ( void   )  [private]

int xmlParser_c::parseLegacy ( bool  push  )  [private]

void xmlParser_c::parseStartTag ( bool  xmldecl  )  [private]

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]

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") 
to enforce that we are at an open puzzle tag

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]


Member Data Documentation

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]

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]

std::string xmlParser_c::Ns [private]

int* xmlParser_c::nspCounts [private]

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]

bool xmlParser_c::processNsp [private]

std::istream& xmlParser_c::reader [private]

bool xmlParser_c::relaxed [private]

bool xmlParser_c::skipNextTag [private]

Referenced by commonInit().

char* xmlParser_c::srcBuf [private]

Referenced by initBuf(), and ~xmlParser_c().

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]

Referenced by initBuf(), and push().

int xmlParser_c::txtPos [private]

int xmlParser_c::type [private]

std::string xmlParser_c::unexpected_eof [private]

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().


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

Generated on Sun Oct 10 10:03:22 2010 for BurrTools by  doxygen 1.5.8