Main Page | Modules | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

CP_XMLDocReader Class Reference

A class to read an XML document and populate a passed in CP_XMLDocument object from the XML. More...

Inheritance diagram for CP_XMLDocReader:

CP_NoCopy List of all members.

Public Member Functions

Constructor / Destructor
 CP_XMLDocReader (CP_InStream *inOutStream, CP_XMLDocument *inXMLDocument)
 Constructor.
virtual ~CP_XMLDocReader ()
 Destructor.
Parsing
virtual void Parse (bool inUseOSNative=true)
XML_Parser GetParser ()

Protected Member Functions

Error Handling
virtual void OnXMLParseError (SInt16 inLineNumber, SInt16 inXMLError)
XML Elements
virtual void OnStartElement (const XML_Char *inElement, CP_XMLAttributes &inAttributes)
virtual void OnEndElement (const XML_Char *inElement)
virtual void OnStartCData ()
virtual void OnEndCData ()
virtual void OnCharData (const XML_Char *s, SInt16 inLength)
virtual void OnProcessingInstruction (const XML_Char *inTarget, const XML_Char *inData)
virtual void OnComment (const XML_Char *inData)

Protected Attributes

CP_XMLDocumentfXMLDocument
CP_InStreamfInStream
UInt32 fMaxBufferSize
XML_Parser fParser
std::stack< CP_XMLDocNode * > fNodes
bool fProcessingCharData
CP_String fText

Private Member Functions

Child Nodes
void AddChildNodes (CFXMLTreeRef inTreeRef, CP_XMLDocNode *inParentNode)

Static Private Member Functions

Parser Callbacks
static void StartElement_callback (void *inData, const XML_Char *inElement, const XML_Char **inAttributes)
static void EndElement_callback (void *inData, const XML_Char *inElement)
static void StartCData_callback (void *inData)
static void EndCData_callback (void *inData)
static void CharData_callback (void *inData, const XML_Char *s, int inLength)
static void ProcessingInstruction_callback (void *inUserData, const XML_Char *inTarget, const XML_Char *inData)
static void Comment_callback (void *inUserData, const XML_Char *inData)

Detailed Description


Constructor & Destructor Documentation

CP_XMLDocReader::CP_XMLDocReader CP_InStream inStream,
CP_XMLDocument inXMLDocument
 

Constructor.

Parameters:
inStream A CP_InStream object that contains the XML data to be read.
inXMLDocument The CP_XMLDocument that we are going to store the nodes and information from the XML data in the stream.
Exceptions:
none 

CP_XMLDocReader::~CP_XMLDocReader  )  [virtual]
 

Destructor.

Exceptions:
none 


Member Function Documentation

void CP_XMLDocReader::Parse bool  inUseOSNative = true  )  [virtual]
 

Sets up an XML parser object to handle the parsing of the xml data contained in the stream object supplied to this class.

Exceptions:
errors from the parsing of the XML data.
Returns:
void

XML_Parser CP_XMLDocReader::GetParser  ) 
 

Returns the XML_Parser object used in parsing this document.

Exceptions:
none 
Returns:
XML_Parser The XML parser used to parse this document.

void CP_XMLDocReader::OnXMLParseError SInt16  inLineNumber,
SInt16  inXMLError
[protected, virtual]
 

Called when the xml parser encounters some type of error in parsing the XML code.

Parameters:
inLineNumber Line number in the XML file of the error.
inXMLError Error code for the error.
Exceptions:
none 
Returns:
void

void CP_XMLDocReader::OnStartElement const XML_Char *  inElement,
CP_XMLAttributes inAttributes
[protected, virtual]
 

Called when the xml parser encounters a new element. This will create and add a new CP_XMLDocNode to the current node and make it a child of that node. Then any attributes will be set for this new node.

Parameters:
inElement The xml element name.
inAttributes A CP_XMLAttributes object that contains the attributes for this element.
Exceptions:
none 
Returns:
void

void CP_XMLDocReader::OnEndElement const XML_Char *  inElement  )  [protected, virtual]
 

Called when an end element is encountered. This will call the current CP_M_XMLHandler object, if that object returns true, then that handler is removed from the stack, and the previous handler becomes the current one.

Parameters:
inElement The xml element name.
Exceptions:
none 
Returns:
void

void CP_XMLDocReader::OnStartCData  )  [protected, virtual]
 

Called when the beginning of a CData section is encountered.

Exceptions:
none 
Returns:
void

void CP_XMLDocReader::OnEndCData  )  [protected, virtual]
 

Called when the end of a CData section is encountered.

Exceptions:
none 
Returns:
void

void CP_XMLDocReader::OnCharData const XML_Char *  inData,
SInt16  inLength
[protected, virtual]
 

Called when char data is encountered. This will add the data to the string that is keeping track of the char data as it is encountered for an element. This may be called several times for char data for a particular element, as the data may be coming in sections.

Parameters:
inData Pointer to the first byte of the char data.
inLength length of the data.
Exceptions:
none 
Returns:
void

void CP_XMLDocReader::OnProcessingInstruction const XML_Char *  inTarget,
const XML_Char *  inData
[protected, virtual]
 

Called when a processing instruction is encountered. Subclasses need to override to handle.

Parameters:
inTarget The target of the instruction.
inData The data for the instruction.
Exceptions:
none 
Returns:
void

void CP_XMLDocReader::OnComment const XML_Char *  inData  )  [protected, virtual]
 

Called when a comment section is encountered. Subclasses need to override to handle.

Parameters:
inData The data for the comment.
Exceptions:
none 
Returns:
void

void CP_XMLDocReader::StartElement_callback void *  inData,
const XML_Char *  inElement,
const XML_Char **  inAttributes
[static, private]
 

Callback used to communicate between the expat parser and this class for the StartElement section. This calls the xml readers OnStartElement to handle the actual processing of data.

Parameters:
inData Pointer to this class.
inElement The name of the element being encountered.
inAttributes A list of attributes for this element.
Exceptions:
none 
Returns:
void

void CP_XMLDocReader::EndElement_callback void *  inData,
const XML_Char *  inElement
[static, private]
 

Callback used to communicate between the expat parser and this class for the EndElement section. This calls the xml readers OnEndElement to handle the actual processing of data.

Parameters:
inData Pointer to this class.
inElement The name of the element being encountered.
Exceptions:
none 
Returns:
void

void CP_XMLDocReader::StartCData_callback void *  inData  )  [static, private]
 

Callback used to communicate between the expat parser and this class for the beginning of a CData section. This calls the xml readers OnStartCData to handle the actual processing of data.

Parameters:
inData Pointer to this class.
Exceptions:
none 
Returns:
void

void CP_XMLDocReader::EndCData_callback void *  inData  )  [static, private]
 

Callback used to communicate between the expat parser and this class for the end of a CData section. This calls the xml readers OnEndCData to handle the actual processing of data.

Parameters:
inData Pointer to this class.
Exceptions:
none 
Returns:
void

void CP_XMLDocReader::CharData_callback void *  inData,
const XML_Char *  inCharData,
int  inLength
[static, private]
 

Callback used to communicate between the expat parser and this class char data is encountered. This calls the xml readers OnCharData to handle the actual processing of data.

Parameters:
inData Pointer to this class.
inCharData Points to the first char of the char data.
inLength The length of the char data.
Exceptions:
none 
Returns:
void

void CP_XMLDocReader::ProcessingInstruction_callback void *  inUserData,
const XML_Char *  inTarget,
const XML_Char *  inData
[static, private]
 

Callback used to communicate between the expat parser and this class when a processing instruction is encountered. This calls the xml readers OnProcessingInstruction to handle the actual processing of data.

Parameters:
inUserData Pointer to this class.
inTarget The target for the instruction.
inData Data for the instruction.
Exceptions:
none 
Returns:
void

void CP_XMLDocReader::Comment_callback void *  inUserData,
const XML_Char *  inData
[static, private]
 

Callback used to communicate between the expat parser and this class when a comment is encountered. This calls the xml readers OnComment to handle the actual processing of data.

Parameters:
inUserData Pointer to this class.
inData Data for the instruction.
Exceptions:
none 
Returns:
void

void CP_XMLDocReader::AddChildNodes CFXMLTreeRef  inTreeRef,
CP_XMLDocNode inParentNode
[private]
 

The accumulated character data for this node.


Member Data Documentation

CP_XMLDocument* CP_XMLDocReader::fXMLDocument [protected]
 

CP_InStream* CP_XMLDocReader::fInStream [protected]
 

The CP_CP_XMLDocument that we are sending data to.

UInt32 CP_XMLDocReader::fMaxBufferSize [protected]
 

The CP_InStream containing the XML data.

XML_Parser CP_XMLDocReader::fParser [protected]
 

Maximum size of the data we read each time.

std::stack<CP_XMLDocNode *> CP_XMLDocReader::fNodes [protected]
 

The XML parser object used to parse our data.

bool CP_XMLDocReader::fProcessingCharData [protected]
 

Stack of nodes read in.

CP_String CP_XMLDocReader::fText [protected]
 

Flag to indicate if we are currently processing character data.


The documentation for this class was generated from the following files:
Generated on Sat Sep 17 20:02:36 2005 for CPLAT by  doxygen 1.4.0