a2dIOHandlerXMLPull Class Reference
[File IO]

Input and output handler for XML alike files. More...

#include <genxmlpars.h>

Inheritance diagram for a2dIOHandlerXMLPull:

Inheritance graph
[legend]
Collaboration diagram for a2dIOHandlerXMLPull:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 a2dIOHandlerXMLPull ()
 Constructor.
 ~a2dIOHandlerXMLPull ()
 Destructor.
a2dXMLTagGetCurrentTag ()
 return the tag where the stream is situated
virtual void InitializeLoad ()
 Inits the IO handler for reading.
virtual void ResetLoad ()
 Reset the object after loading.
void Require (const XMLeventType &type, wxString name)
 Forces a special tag.
wxString GetTagName ()
 Returns name of the current XML tag.
wxString GetContent ()
 Returns the current content.
XMLeventType GetEventType ()
 Returns the type of current event.
int GetDepth ()
 Returns depth.
XMLeventType NextTag ()
 Walks to next tag.
XMLeventType Next ()
 Walks to next element and returns event type.
wxString GetAttributeValue (const wxString &attrib, const wxString &defaultv=wxT(""))
 Returns the value of an attribute.
wxString RequireAttributeValue (const wxString &attrib)
 Forces an attribute and returns its string value.
double GetAttributeValueDouble (const wxString &attrib, double defaultv=0)
 Returns the double value of an attribute.
double RequireAttributeValueDouble (const wxString &attrib)
 Forces an attribute and returns its double value.
int GetAttributeValueInt (const wxString &attrib, int defaultv=0)
 Returns the integer value of an attribute.
wxUint16 GetAttributeValueUint16 (const wxString &attrib, wxUint16 defaultv=0)
 cast to wxUint16 of GetAttributeValueInt()
wxUint32 GetAttributeValueUint32 (const wxString &attrib, wxUint32 defaultv=0)
 cast to wxUint32 of GetAttributeValueInt()
int RequireAttributeValueInt (const wxString &attrib)
 Forces an attribute and returns its integer value.
long GetAttributeValueLong (const wxString &attrib, long defaultv=0)
 Returns the long value of an attribute.
long RequireAttributeValueLong (const wxString &attrib)
 Forces an attribute and returns its long integer value.
bool GetAttributeValueBool (const wxString &attrib, bool defaultv=false)
 Returns the boolean value of an attribute.
bool RequireAttributeValueBool (const wxString &attrib)
 Forces an attribute and returns its boolean value.
bool HasAttribute (const wxString &attrib)
 Does the current tag have this attribute?
void SkipSubTree ()
 Skips all child elements / tags of current element / tag.
virtual int GetCurrentColumnNumber ()
 where in the input was column the current tag
virtual int GetCurrentLineNumber ()
 where in the input was line the current tag

Protected Member Functions

virtual void StartElementHnd (a2dXMLTag *tag)
virtual void EndElementHnd (const wxString &name)
virtual void CharacterDataHnd (const wxString &text)
virtual void CommentHnd (const wxString &comment)
virtual void DefaultHnd (const wxString &def)
void FillQueue ()
 Reads next piece of document into buffer.

Protected Attributes

a2dSmrtPtrList< a2dXMLTagm_elements
 queue of begin and end elements tags not yet processed
int m_depth
a2dXMLTagm_startdoc
a2dXMLTagm_enddoc
a2dXMLTagm_current
 current XML tag


Detailed Description

Input and output handler for XML alike files.

The file is parsed by pulling information from it. One chunk of information is a XML begin_tag + attributes or an end_tag or content between the tags. The caller decides what should be pulled next after a reading chunk. This makes it very easy to read known fixes file formats, since one can directly store the information read into an object of choice. This is ideal for mapping a certain XML input format to the programs internal format.

See also http://www.xmlpull.org/ for further details about XML pull parsing.

Definition at line 304 of file genxmlpars.h.


Constructor & Destructor Documentation

a2dIOHandlerXMLPull::a2dIOHandlerXMLPull (  ) 

Constructor.

See also:
a2dIOHandlerXML::a2dIOHandlerXML for description and remarks

Definition at line 312 of file genxmlpars.cpp.


Member Function Documentation

void a2dIOHandlerXMLPull::InitializeLoad (  )  [virtual]

Inits the IO handler for reading.

See also:
a2dIOHandlerXML::InitializeLoad for description and remarks

Reimplemented from a2dIOHandlerXML.

Definition at line 326 of file genxmlpars.cpp.

void a2dIOHandlerXMLPull::Require ( const XMLeventType type,
wxString  name 
)

Forces a special tag.

If the current XMLeventType and the tag name is not the required type and name, an a2dIOHandlerXMLException will occur.

See also:
a2dIOHandlerXMLException
Parameters:
type the required tag type
name the required tag name

Definition at line 389 of file genxmlpars.cpp.

wxString a2dIOHandlerXMLPull::GetTagName (  ) 

Returns name of the current XML tag.

This method returns the name of the current XML tag

Returns:
tag name

Definition at line 564 of file genxmlpars.cpp.

wxString a2dIOHandlerXMLPull::GetContent (  ) 

Returns the current content.

Returns the content between the opening XML tag and the ending tag

Returns:
content between tag

Definition at line 569 of file genxmlpars.cpp.

XMLeventType a2dIOHandlerXMLPull::GetEventType (  ) 

Returns the type of current event.

The event type may be one of the following:

  • START_DOCUMENT
  • END_DOCUMENT
  • START_TAG
  • END_TAG
  • CONTENT

See also:
XMLeventType
Returns:
the event type

Definition at line 604 of file genxmlpars.cpp.

XMLeventType a2dIOHandlerXMLPull::NextTag (  ) 

Walks to next tag.

Does internally a call to Next() and checks if the XMLEventType is an START_TAG or END_TAG, otherwise an a2dIOHandlerXMLException is thrown.

See also:
a2dIOHandlerXMLException

Next

Returns:
the event type

Definition at line 410 of file genxmlpars.cpp.

XMLeventType a2dIOHandlerXMLPull::Next (  ) 

Walks to next element and returns event type.

Goes to the next element and returns the event type of the element.

See also:
NextTag
Returns:
the event type

Definition at line 421 of file genxmlpars.cpp.

wxString a2dIOHandlerXMLPull::GetAttributeValue ( const wxString &  attrib,
const wxString &  defaultv = wxT("") 
)

Returns the value of an attribute.

Returns the value of the attribute "attrib"

Parameters:
attrib the attribute name
defaultv the default value (empty string by default)
Returns:
the value of the attribute if found or the default value

Definition at line 449 of file genxmlpars.cpp.

wxString a2dIOHandlerXMLPull::RequireAttributeValue ( const wxString &  attrib  ) 

Forces an attribute and returns its string value.

Walks through the attributes of the current start tag and returns the value of the requested attribute. If the attribute is not found, an a2dIOHandlerXMLException will be thrown.

See also:
a2dIOHandlerXMLException
Parameters:
attrib the attribute name
Returns:
the attribute value

Definition at line 460 of file genxmlpars.cpp.

double a2dIOHandlerXMLPull::GetAttributeValueDouble ( const wxString &  attrib,
double  defaultv = 0 
)

Returns the double value of an attribute.

See also:
GetAttributeValue
Parameters:
attrib the attribute name
defaultv the default value (0 by default)
Returns:
the value of the attribute if found or the default value

Definition at line 473 of file genxmlpars.cpp.

double a2dIOHandlerXMLPull::RequireAttributeValueDouble ( const wxString &  attrib  ) 

Forces an attribute and returns its double value.

See also:
RequireAttributeValue
Parameters:
attrib the attribute name
Returns:
the attribute value

Definition at line 486 of file genxmlpars.cpp.

int a2dIOHandlerXMLPull::GetAttributeValueInt ( const wxString &  attrib,
int  defaultv = 0 
)

Returns the integer value of an attribute.

See also:
GetAttributeValue
Parameters:
attrib the attribute name
defaultv the default value (0 by default)
Returns:
the value of the attribute if found or the default value

Definition at line 494 of file genxmlpars.cpp.

int a2dIOHandlerXMLPull::RequireAttributeValueInt ( const wxString &  attrib  ) 

Forces an attribute and returns its integer value.

See also:
RequireAttributeValue
Parameters:
attrib the attribute name
Returns:
the attribute value

Definition at line 507 of file genxmlpars.cpp.

long a2dIOHandlerXMLPull::GetAttributeValueLong ( const wxString &  attrib,
long  defaultv = 0 
)

Returns the long value of an attribute.

See also:
GetAttributeValue
Parameters:
attrib the attribute name
defaultv the default value (0 by default)
Returns:
the value of the attribute if found or the default value

Definition at line 515 of file genxmlpars.cpp.

long a2dIOHandlerXMLPull::RequireAttributeValueLong ( const wxString &  attrib  ) 

Forces an attribute and returns its long integer value.

See also:
RequireAttributeValue
Parameters:
attrib the attribute name
Returns:
the attribute value

Definition at line 528 of file genxmlpars.cpp.

bool a2dIOHandlerXMLPull::GetAttributeValueBool ( const wxString &  attrib,
bool  defaultv = false 
)

Returns the boolean value of an attribute.

Attribute values like "true", "true", "True"... will be returned as boolean (case-insensitive).

Remarks:
An attribute value of "1" or "0" are not valid boolean values.
See also:
GetAttributeValue
Parameters:
attrib the attribute name
defaultv the default value
Returns:
the value of the attribute if found or the default value

Definition at line 536 of file genxmlpars.cpp.

bool a2dIOHandlerXMLPull::RequireAttributeValueBool ( const wxString &  attrib  ) 

Forces an attribute and returns its boolean value.

See also:
RequireAttributeValue
Parameters:
attrib the attribute name
Returns:
the attribute value

Definition at line 550 of file genxmlpars.cpp.


The documentation for this class was generated from the following files:
a2dIOHandlerXMLPull Class Reference -- Tue Aug 31 18:29:24 2010 -- 31 Aug 2010 -- 1.5.5 -- wxArt2D -- . -- Main Page Reference Documentation