ulxr::WbXmlParser Class Reference
[Low-level parser classes]

Base class for binary XML parsing. More...

#include <ulxr_wbxmlparse.h>

Inheritance diagram for ulxr::WbXmlParser:

Inheritance graph
[legend]
Collaboration diagram for ulxr::WbXmlParser:

Collaboration graph
[legend]
List of all members.

Public Types

enum  WbXmlToken {
  wbxml_SWITCH_PAGE = 0x00, wbxml_END = 0x01, wbxml_ENTITY = 0x02, wbxml_PI = 0x43,
  wbxml_OPAQUE = 0xC3, wbxml_LITERAL = 0x04, wbxml_LITERAL_C = 0x44, wbxml_LITERAL_A = 0x84,
  wbxml_LITERAL_AC = 0xC4, wbxml_EXT_I_0 = 0x40, wbxml_EXT_I_1 = 0x41, wbxml_EXT_I_2 = 0x42,
  wbxml_EXT_T_0 = 0x80, wbxml_EXT_T_1 = 0x81, wbxml_EXT_T_2 = 0x82, wbxml_EXT_0 = 0xC0,
  wbxml_EXT_1 = 0xC1, wbxml_EXT_2 = 0xC2, wbxml_STR_I = 0x03, wbxml_STR_T = 0x83,
  wbxml_TAG_FIRST = 0x05, wbxml_TAG_LAST = 0x3f, wbxml_TAG_C_FIRST = 0x45, wbxml_TAG_C_LAST = 0x7F,
  wbxml_TAG_A_FIRST = 0x85, wbxml_TAG_A_LAST = 0xBF, wbxml_TAG_AC_FIRST = 0xC5, wbxml_TAG_AC_LAST = 0xFF
}

Public Member Functions

 WbXmlParser ()
 Constructs a parser.
virtual int parse (const char *buffer, int len, int isFinal)
 Parse a piece of xml data.
virtual unsigned getErrorCode () const
 Gets the code for the current error.
virtual CppString getErrorString (unsigned code) const
 Gets the description for an error code.
virtual int getCurrentLineNumber () const
 Gets the line number in the xml data.
virtual int mapToFaultCode (int xpatcode) const
 Maps error codes to xml-rpc error codes.

Static Public Attributes

static const char wbxml_START_SEQ_STR []
static const unsigned wbxml_START_SEQ_LEN

Protected Types

typedef std::vector< AttributeAttributes

Protected Member Functions

virtual ~WbXmlParser ()
 Destroys the parser.
bool testStartElement (unsigned token, const Attributes &attr)
 Tests if the current opening tag is to be parsed by this inheritance level or by the parent.
virtual void startElement (unsigned token, const Attributes &attr)=0
 C++ callback for an opening XML tag.
bool testEndElement ()
 C++ callback for a closing XML tag.
virtual void endElement ()=0
 C++ callback for a closing XML tag.
virtual void charData (const std::string &s)
 Parses the content of the current xml element.

Private Member Functions

void init ()

Private Attributes

std::stack< WbXmlStatewbxmlstates
unsigned wb_version
unsigned wb_pubId
unsigned wb_charset
unsigned lastErrorCode
unsigned tag_count

Classes

class  Attribute
struct  WbXmlState

Detailed Description

Base class for binary XML parsing.

This is a very limitited implementation which only handles a subset which is enough for ulxmlrpcpp.

Definition at line 48 of file ulxr_wbxmlparse.h.


Member Typedef Documentation

typedef std::vector<Attribute> ulxr::WbXmlParser::Attributes [protected]

Definition at line 140 of file ulxr_wbxmlparse.h.


Member Enumeration Documentation

enum ulxr::WbXmlParser::WbXmlToken

Enumerator:
wbxml_SWITCH_PAGE  switch code page followed by a byte
wbxml_END  end of attribut list or element
wbxml_ENTITY  followed by a multibyte UCS-4 entity
wbxml_PI  Processing instruction.
wbxml_OPAQUE  opaque data followed by multibyte-length and data
wbxml_LITERAL  unknown empty tag or attribut name, followed by table index
wbxml_LITERAL_C  unknown tag with content, followed by table index
wbxml_LITERAL_A  unknown tag with attributes, followed by table index
wbxml_LITERAL_AC  unknown tag with content and attributes, followed by table index
wbxml_EXT_I_0  inline string extension 0 followed by string + terminator
wbxml_EXT_I_1  inline string extension 1 followed by string + terminator
wbxml_EXT_I_2  inline string extension 2 followed by string + terminator
wbxml_EXT_T_0  inline integer extension 0 followed by multibyte
wbxml_EXT_T_1  inline integer extension 1 followed by multibyte
wbxml_EXT_T_2  inline integer extension 2 followed by multibyte
wbxml_EXT_0  single byte extension 0
wbxml_EXT_1  single byte extension 1
wbxml_EXT_2  single byte extension 2
wbxml_STR_I  followed by inline string + terminator
wbxml_STR_T  string table index followed by multibyte
wbxml_TAG_FIRST  first value for empty elements
wbxml_TAG_LAST  last value for empty elements
wbxml_TAG_C_FIRST  first value for elements with content
wbxml_TAG_C_LAST  last value for elements with content
wbxml_TAG_A_FIRST  first value for elements without content but with attributes
wbxml_TAG_A_LAST  last value for elements without content but with attributes
wbxml_TAG_AC_FIRST  first value for elements with content and attributes
wbxml_TAG_AC_LAST  last value for elements with content and attributes

Definition at line 96 of file ulxr_wbxmlparse.h.


Constructor & Destructor Documentation

ulxr::WbXmlParser::~WbXmlParser (  )  [protected, virtual]

Destroys the parser.

The derived class is responsible for cleaning up stack<ParserState*>.

Definition at line 106 of file ulxr_wbxmlparse.cpp.

ulxr::WbXmlParser::WbXmlParser (  ) 

Constructs a parser.

Definition at line 91 of file ulxr_wbxmlparse.cpp.

References init().


Member Function Documentation

int ulxr::WbXmlParser::parse ( const char *  buffer,
int  len,
int  isFinal 
) [virtual]

Parse a piece of xml data.

Parameters:
buffer pointer start of next data chunk
len len of this chunk
isFinal true: last call to parser
Returns:
error condition, 0 = ok

Implements ulxr::XmlParserBase.

Definition at line 118 of file ulxr_wbxmlparse.cpp.

References ulxr::HtmlFormHandler::makeHexNumber(), ulxr::HtmlFormHandler::makeNumber(), ulxr::NotWellformedError, ulxr::stBody, ulxr::stCharset, ulxr::stNone, ulxr::stPubId, ulxr::stStr_I, ulxr::stStrTableLen, ulxr_i18n, ULXR_PCHAR, and ULXR_TRACE.

unsigned ulxr::WbXmlParser::getErrorCode (  )  const [virtual]

Gets the code for the current error.

Returns:
error code

Implements ulxr::XmlParserBase.

Definition at line 111 of file ulxr_wbxmlparse.cpp.

CppString ulxr::WbXmlParser::getErrorString ( unsigned  code  )  const [virtual]

Gets the description for an error code.

Parameters:
code error code
Returns:
pointer to description

Implements ulxr::XmlParserBase.

Definition at line 199 of file ulxr_wbxmlparse.cpp.

References ULXR_PCHAR.

int ulxr::WbXmlParser::getCurrentLineNumber (  )  const [virtual]

Gets the line number in the xml data.

Because the binary data has nothing like a line number, the current number of start tags is returned.

Returns:
number of start tags

Implements ulxr::XmlParserBase.

Definition at line 205 of file ulxr_wbxmlparse.cpp.

int ulxr::WbXmlParser::mapToFaultCode ( int  xpatcode  )  const [virtual]

Maps error codes to xml-rpc error codes.

Compatibility function due to expat, always return input.

Parameters:
xpatcode error code
Returns:
the according xml-rpc error

Implements ulxr::XmlParserBase.

Definition at line 211 of file ulxr_wbxmlparse.cpp.

bool ulxr::WbXmlParser::testStartElement ( unsigned  token,
const Attributes attr 
) [protected]

Tests if the current opening tag is to be parsed by this inheritance level or by the parent.

Parameters:
token current well known token
attr tag attributes
Returns:
true: element has been handled

Definition at line 237 of file ulxr_wbxmlparse.cpp.

References ulxr::HtmlFormHandler::makeHexNumber(), ulxr::NotWellformedError, ulxr_i18n, and ULXR_PCHAR.

Referenced by startElement(), and ulxr::ValueParserWb::startElement().

void ulxr::WbXmlParser::startElement ( unsigned  token,
const Attributes attr 
) [protected, pure virtual]

C++ callback for an opening XML tag.

Parameters:
token current literal tag
attr tag attributes

Definition at line 230 of file ulxr_wbxmlparse.cpp.

References testStartElement().

bool ulxr::WbXmlParser::testEndElement (  )  [protected]

C++ callback for a closing XML tag.

Returns:
true: element has been handled

Reimplemented in ulxr::MethodCallParserWb, ulxr::MethodResponseParserWb, and ulxr::ValueParserWb.

Definition at line 246 of file ulxr_wbxmlparse.cpp.

References ulxr::NotWellformedError, ulxr_i18n, and ULXR_PCHAR.

Referenced by ulxr::ValueParserWb::endElement().

virtual void ulxr::WbXmlParser::endElement (  )  [protected, pure virtual]

C++ callback for a closing XML tag.

Implemented in ulxr::MethodCallParserWb, ulxr::MethodResponseParserWb, and ulxr::ValueParserWb.

void ulxr::WbXmlParser::charData ( const std::string &  s  )  [protected, virtual]

Parses the content of the current xml element.

Parameters:
s the current chunk of text

Definition at line 217 of file ulxr_wbxmlparse.cpp.

References ULXR_GET_STRING, ULXR_PCHAR, and ULXR_TRACE.

void ulxr::WbXmlParser::init (  )  [private]

Definition at line 98 of file ulxr_wbxmlparse.cpp.

References ulxr::stNone.

Referenced by WbXmlParser().


Member Data Documentation

const char ulxr::WbXmlParser::wbxml_START_SEQ_STR [static]

Definition at line 134 of file ulxr_wbxmlparse.h.

Referenced by ulxr::MethodResponse::getWbXml(), and ulxr::MethodCall::getWbXml().

const unsigned ulxr::WbXmlParser::wbxml_START_SEQ_LEN [static]

Definition at line 135 of file ulxr_wbxmlparse.h.

Referenced by ulxr::MethodResponse::getWbXml(), and ulxr::MethodCall::getWbXml().

std::stack<WbXmlState> ulxr::WbXmlParser::wbxmlstates [private]

Definition at line 184 of file ulxr_wbxmlparse.h.

unsigned ulxr::WbXmlParser::wb_version [private]

Definition at line 186 of file ulxr_wbxmlparse.h.

unsigned ulxr::WbXmlParser::wb_pubId [private]

Definition at line 187 of file ulxr_wbxmlparse.h.

unsigned ulxr::WbXmlParser::wb_charset [private]

Definition at line 188 of file ulxr_wbxmlparse.h.

unsigned ulxr::WbXmlParser::lastErrorCode [private]

Definition at line 190 of file ulxr_wbxmlparse.h.

unsigned ulxr::WbXmlParser::tag_count [private]

Definition at line 191 of file ulxr_wbxmlparse.h.


The documentation for this class was generated from the following files:
Generated on Sun Aug 19 20:09:14 2007 for ulxmlrpcpp by  doxygen 1.5.1