wxArt2D
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
a2dIOHandlerXMLPull Class Reference

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]

Public Member Functions

 a2dIOHandlerXMLPull ()
 Constructor. More...
 
 ~a2dIOHandlerXMLPull ()
 Destructor.
 
a2dXMLTagGetCurrentTag ()
 return the tag where the stream is situated
 
virtual void InitializeLoad ()
 Inits the IO handler for reading. More...
 
virtual void ResetLoad ()
 Reset the object after loading.
 
void Require (const XMLeventType &type, wxString name)
 Forces a special tag. More...
 
wxString GetTagName ()
 Returns name of the current XML tag. More...
 
wxString GetContent ()
 Returns the current content. More...
 
XMLeventType GetEventType ()
 Returns the type of current event. More...
 
int GetDepth ()
 Returns depth.
 
XMLeventType NextTag ()
 Walks to next tag. More...
 
XMLeventType Next ()
 Walks to next element and returns event type. More...
 
wxString GetAttributeValue (const wxString &attrib, const wxString &defaultv=wxT(""))
 Returns the value of an attribute. More...
 
wxString RequireAttributeValue (const wxString &attrib)
 Forces an attribute and returns its string value. More...
 
double GetAttributeValueDouble (const wxString &attrib, double defaultv=0)
 Returns the double value of an attribute. More...
 
double RequireAttributeValueDouble (const wxString &attrib)
 Forces an attribute and returns its double value. More...
 
int GetAttributeValueInt (const wxString &attrib, int defaultv=0)
 Returns the integer value of an attribute. More...
 
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. More...
 
long GetAttributeValueLong (const wxString &attrib, long defaultv=0)
 Returns the long value of an attribute. More...
 
long RequireAttributeValueLong (const wxString &attrib)
 Forces an attribute and returns its long integer value. More...
 
bool GetAttributeValueBool (const wxString &attrib, bool defaultv=false)
 Returns the boolean value of an attribute. More...
 
bool RequireAttributeValueBool (const wxString &attrib)
 Forces an attribute and returns its boolean value. More...
 
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
 
void SetScale (double scale)
 
double GetScale ()
 See GetScale()
 
- Public Member Functions inherited from a2dIOHandlerXML
 a2dIOHandlerXML ()
 Constructor. More...
 
 ~a2dIOHandlerXML ()
 Destructor.
 
XML_Parser & GetXMLParser ()
 Returns the XML parser.
 
wxString GetErrorString ()
 Returns last error as string.
 
double ParseDouble (const wxString &buffer, unsigned int &position)
 
void SkipCommaSpaces (const wxString &buffer, unsigned int &position)
 
void SkipSpaces (const wxString &buffer, unsigned int &position)
 
- Public Member Functions inherited from a2dIOHandlerStrIn
 a2dIOHandlerStrIn (wxMBConv &conv=wxConvUTF8)
 constructor
 
 ~a2dIOHandlerStrIn ()
 destructor
 
virtual bool CanLoad (a2dDocumentInputStream &stream, const wxObject *obj=NULL, wxClassInfo *docClassInfo=NULL)=0
 Should return true if the handler can read from the stream. More...
 
virtual bool Load (a2dDocumentInputStream &stream, wxObject *obj)=0
 override to read the stream and store (part of) the contents in to a specific a2dDocument or othere object. More...
 
wxClassInfo * GetDocumentClassInfo () const
 class info for the (document) class this handler reads data into.
 
void SetDocumentClassInfo (wxClassInfo *docClassInfo)
 class info for the (document) class this handler reads data into.
 
void SetFileName (const wxFileName &filename)
 
const wxFileName & GetFileName () const
 
- Public Member Functions inherited from a2dIOHandler
 a2dIOHandler ()
 constructor
 
 ~a2dIOHandler ()
 destructor
 
virtual wxObject * CreateObject (const wxString &symbolicName)
 Creates an specific object by name. More...
 
- Public Member Functions inherited from a2dRefMap
 a2dRefMap ()
 constructor
 
 ~a2dRefMap ()
 destructor
 
virtual void Initialize ()
 initialize mapping tables
 
a2dHashMapIntToObject & GetObjectHashMap ()
 This is used to find multiple referenced objects by id.
 
a2dHashMapCreateObject & GetObjectCreateHashMap ()
 has to map symbolic names to real classnames.
 
a2dResolveIdList & GetResolveIdList ()
 list of not resolved objects
 
bool ResolveOrAdd (a2dSmrtPtr< a2dObject > *storedHere, const wxString &id=wxT(""))
 try to resolve the object that is in storedHere when it is a reference. More...
 
bool ResolveOrAdd (a2dAutoZeroPtr< a2dObject > *storedHere, const wxString &id=wxT(""))
 try to resolve the object that is in storedHere when it is a reference.
 
bool ResolveOrAddLink (a2dObject *obj, const wxString &id=wxT(""))
 try to resolve an object referenced by obj using the LinkReference function
 
void ResolveInform (a2dObject *obj)
 call the objects LinkReference function (ptr=0) to inform it that links are done
 
void SetLastObjectLoadedId (const wxString &lastid)
 set by RefObject when finding a reference id during loading.
 
virtual bool LinkReferences (bool ignoreNonResolved=false)
 link references to their destination More...
 
bool RemoveReference (const wxString &idToRemove)
 remove given reference if from reference map.
 
a2dError GetLastError () const
 get last error encountered
 
void SetLastError (a2dError error)
 set last error encountered
 
- Public Member Functions inherited from a2dObject
virtual bool ProcessEvent (wxEvent &event)
 
bool SearchDynamicEventTable (wxEvent &event)
 
void Connect (int winid, int lastId, int eventType, wxObjectEventFunction func, wxObject *userData=(wxObject *) NULL, wxEvtHandler *eventSink=(wxEvtHandler *) NULL)
 
bool Disconnect (int winid, int lastId, wxEventType eventType, wxObjectEventFunction func=NULL, wxObject *userData=(wxObject *) NULL, wxEvtHandler *eventSink=(wxEvtHandler *) NULL)
 
void ProcessConnectedEvent (wxEvent &event)
 wxCHECK_VERSION(2,9,0) More...
 
void ConnectEvent (wxEventType type, wxEvtHandler *eventSink)
 
bool DisconnectEvent (wxEventType type, wxEvtHandler *eventSink)
 
bool DisconnectEventAll (wxEvtHandler *eventSink)
 Remove all dynamic events in classA, going to classB (eventSink) More...
 
 a2dObject ()
 constructor
 
virtual ~a2dObject ()
 destructor
 
void operator= (const a2dObject &other)
 assignment operator
 
int GetOwnedBy ()
 like it to be protected, but this does not work with wxList macros More...
 
virtual a2dObjectSetNonDynamic ()
 Call to mark this object as non-dynamic (static/local/auto) More...
 
void CheckReferences ()
 Check zero reference count and delete if count is 0. More...
 
a2dObjectClone (CloneOptions options, a2dRefMap *refs=NULL) const
 create an exact copy of this property
 
 a2dObject (const a2dObject &other, CloneOptions options, a2dRefMap *refs)
 
virtual wxString GetName () const
 Returns the name of this object, if no name is given the internal id will be returned. More...
 
virtual void SetName (const wxString &name)
 Creates the a2dStringProperty PROPID_Name. More...
 
virtual bool IsTemporary_DontSave () const
 Check if this is a temporary object, which should not be saved.
 
void SaveAsDocument (a2dIOHandlerXmlSerOut &out)
 Save this object and all below as an XML document. More...
 
virtual void Save (wxObject *parent, a2dIOHandlerXmlSerOut &out, a2dObjectList *towrite)
 write all needed to an XML type of file called the CVG format More...
 
void LoadFromDocument (a2dIOHandlerXmlSerIn &parser)
 Load this object and all below from an XML document. More...
 
virtual void Load (wxObject *parent, a2dIOHandlerXmlSerIn &parser)
 load object from CVG file More...
 
wxInt64 GetUniqueSerializationId () const
 return a unique id for this object More...
 
virtual bool AlwaysWriteSerializationId () const
 If true, always write an id. More...
 
virtual bool LinkReference (a2dObject *other)
 link a reference in the object to the given value More...
 
virtual void ResolveInform ()
 inform an object that reference resolution was done More...
 
void Walker (wxObject *parent, a2dWalkerIOHandler &handler)
 This is used to recursively walk through an object tree.
 
void SetCheck (bool check)
 general flag use at will. More...
 
bool GetCheck () const
 general flag use at will.
 
void SetRelease (bool value)
 set release flag More...
 
bool GetRelease () const
 get release flag More...
 
a2dAutoZeroPtr< a2dObject > ** GetAutoZeroPtrList ()
 return the list head pointer for autozero pointers to this object More...
 
 DECLARE_PROPERTIES ()
 
a2dNamedPropertyGetProperty (const a2dPropertyId *propertyId, a2dPropertyId::Flags flags=a2dPropertyId::flag_none) const
 get property on this object More...
 
void SetProperty (a2dNamedProperty *propertyHolder, a2dPropertyId::SetFlags flags=a2dPropertyId::set_none)
 Set the property to the this object. More...
 
void SetProperty (const a2dNamedProperty &propertyHolder, a2dPropertyId::SetFlags flags=a2dPropertyId::set_none)
 Set the property to the this object and if enabled, to all childs and object members. More...
 
virtual a2dNamedPropertyFindProperty (const a2dPropertyId *id, a2dPropertyId::Flags flags=a2dPropertyId::flag_none)
 Find a dynamic property with given id in the property list. More...
 
virtual const a2dNamedPropertyFindProperty (const a2dPropertyId *id, a2dPropertyId::Flags flags=a2dPropertyId::flag_none) const
 Find a dynamic property with given id in the property list. More...
 
virtual bool HasProperty (const a2dPropertyId *id, const wxString &stringvalue=wxEmptyString) const
 Check if the object has a property with given id and string representation. More...
 
virtual void OnPropertyChanged (const a2dPropertyId *id)
 This function is called after a property changed. More...
 
virtual bool EditProperties (const a2dPropertyId *id, bool withUndo=true)
 edit properties of the object More...
 
void TakeOverProperties (a2dObject *from, a2dPropertyIdList *listOfIds)
 Properties in the id list are taken from the given object, en set to this. More...
 
wxURI GetURI () const
 quick way to get to PROPID_URI property More...
 
void SetURI (const wxURI &url)
 quickly set a property PROPID_URI More...
 
const a2dNamedPropertyListGetPropertyList () const
 Get the Property List. More...
 
bool HasDynamicProperties () const
 test if there are dynamic properties in the m_propertylist
 
virtual bool RemoveProperty (const a2dPropertyId *id, bool all=true)
 This function is called by a2dPropertyId to remove a property from the list. More...
 
void RemoveTemporaryProperties ()
 remove all temporary properties
 
virtual bool AddProperty (a2dNamedProperty *property)
 This function is called by a2dPropertyId to add a property to the list. More...
 

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 Member Functions inherited from a2dIOHandlerStrIn
void SetMode (wxEOL mode=wxEOL_NATIVE)
 define the line end mode for textual files
 
wxEOL GetMode ()
 get line end mode for textual files
 
char Peek ()
 
char GetC ()
 
a2dIOHandlerStrInSeekI (wxFileOffset pos)
 set stream at a position
 
bool Eof () const
 
bool IsOk () const
 
size_t Read (char *buffer, size_t size)
 
- Protected Member Functions inherited from a2dObject
virtual bool DoIgnoreIfNotMember (const a2dPropertyId *id) const
 used to decide if a property shall be ignored, if it is not a member More...
 
virtual void DoWalker (wxObject *parent, a2dWalkerIOHandler &handler)
 iterate over this object and its children More...
 

Protected Attributes

a2dSmrtPtrList< a2dXMLTagm_elements
 queue of begin and end elements tags not yet processed
 
int m_depth
 
double m_scale
 
a2dXMLTagm_startdoc
 
a2dXMLTagm_enddoc
 
a2dXMLTagm_current
 current XML tag
 
- Protected Attributes inherited from a2dIOHandlerXML
XML_Parser m_parser
 expat parser
 
char * m_buffer
 buffer used for passing part of the input stream
 
bool m_done
 true if reached end of document
 
- Protected Attributes inherited from a2dIOHandlerStrIn
wxFileName m_filename
 
wxMBConv & m_conv
 unicode conversion
 
a2dDocumentInputStreamm_streami
 file or other string stream containing the format to parse.
 
wxClassInfo * m_docClassInfo
 Run-time class information that allows document instances to be constructed dynamically.
 
wxEOL m_mode
 end of line mode
 
- Protected Attributes inherited from a2dRefMap
a2dHashMapIntToObject m_objecthashmap
 This is used to find multiple referenced objects by id.
 
a2dHashMapCreateObject m_objectCreate
 This is used to find a classname using a symbolic name.
 
a2dResolveIdList m_toResolve
 refernces to object which have not bin resolved yet ( e.g not read yet, but already referenced )
 
wxString m_lastObjectId
 
a2dError m_lastError
 set to last error found when parsing
 
- Protected Attributes inherited from a2dObject
a2dNamedPropertyList m_propertylist
 properties
 
int m_refcount
 how many references to this object do exist
 
bool m_check: 1
 used for linking multiple referenced objects when serializing
 
bool m_release: 1
 when set object is treated as being deleted, and wil be deleted in idle time.
 
bool m_recursion_active: 1
 this is used as a recursion stopper
 
bool m_pendingDisconnects: 1
 
unsigned int m_iteratorCount
 
a2dAutoZeroPtr< a2dObject > * m_autozeroptrlist
 this is a list of all a2dAutoZeroPtr object pointing to this object
 

Additional Inherited Members

- Public Types inherited from a2dObject
enum  CloneOptions {
  clone_members = 0x00000001, clone_properties = 0x00000002, clone_childs = 0x00000004, clone_unused = 0x00000008,
  clone_setoriginal = 0x00000010, clone_seteditcopy = 0x00000020, clone_noReference = 0x00000040, clone_noCameleonRef = 0x00000080,
  clone_toDrag = 0x00000100, clone_flat = 0x00000000, clone_deep = clone_members | clone_properties | clone_childs
}
 options for cloning More...
 
typedef a2dAutoZeroPtr< a2dObjectTAutoZeroPtrListClass
 this is needed inside the smart pointer template code
 
- Static Public Attributes inherited from a2dObject
static a2dPropertyIdBoolPROPID_Check = NULL
 used for linking multiple referenced objects when serializing
 
static a2dPropertyIdUriPROPID_URI = NULL
 attach an URL to the object
 
static a2dPropertyIdStringPROPID_Name = NULL
 Name property, to return name of this object.
 
static a2dPropertyIdVoidPtrPROPID_autozeroptrlist = NULL
 
static const a2dSignal sm_Edit_properties = wxNewId()
 edit properties event, see EditProperties()
 
- Protected Types inherited from a2dObject
enum  { refcount_nondynamic = 0x76543210 }
 special refcount value for non-dynamic objects
 
- Static Protected Member Functions inherited from a2dIOHandlerXML
static void BaseStartElementHnd (void *userData, const char *name, const char **atts)
 
static void BaseEndElementHnd (void *userData, const char *name)
 
static void BaseCharacterDataHnd (void *userData, const char *s, int len)
 
static void BaseCommentHnd (void *userData, const char *data)
 
static void BaseDefaultHnd (void *userData, const char *s, int len)
 
- Static Protected Attributes inherited from a2dIOHandlerXML
static wxString m_encoding = wxT( "UTF-8" )
 
static wxString m_version = wxT( "1.0" )
 

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 308 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

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

Returns the value of an attribute.

Returns the value of the attribute "attrib"

Parameters
attribthe attribute name
defaultvthe default value (empty string by default)
Returns
the value of the attribute if found or the default value

Definition at line 450 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
attribthe attribute name
defaultvthe default value
Returns
the value of the attribute if found or the default value

Definition at line 537 of file genxmlpars.cpp.

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

Returns the double value of an attribute.

See Also
GetAttributeValue
Parameters
attribthe attribute name
defaultvthe default value (0 by default)
Returns
the value of the attribute if found or the default value

Definition at line 474 of file genxmlpars.cpp.

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

Returns the integer value of an attribute.

See Also
GetAttributeValue
Parameters
attribthe attribute name
defaultvthe default value (0 by default)
Returns
the value of the attribute if found or the default value

Definition at line 495 of file genxmlpars.cpp.

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

Returns the long value of an attribute.

See Also
GetAttributeValue
Parameters
attribthe attribute name
defaultvthe default value (0 by default)
Returns
the value of the attribute if found or the default value

Definition at line 516 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 570 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 606 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 565 of file genxmlpars.cpp.

void a2dIOHandlerXMLPull::InitializeLoad ( )
virtual

Inits the IO handler for reading.

See Also
a2dIOHandlerXML::InitializeLoad for description and remarks

Reimplemented from a2dIOHandlerXML.

Definition at line 327 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 422 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 411 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
typethe required tag type
namethe required tag name

Definition at line 390 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
attribthe attribute name
Returns
the attribute value

Definition at line 461 of file genxmlpars.cpp.

bool a2dIOHandlerXMLPull::RequireAttributeValueBool ( const wxString &  attrib)

Forces an attribute and returns its boolean value.

See Also
RequireAttributeValue
Parameters
attribthe attribute name
Returns
the attribute value

Definition at line 551 of file genxmlpars.cpp.

double a2dIOHandlerXMLPull::RequireAttributeValueDouble ( const wxString &  attrib)

Forces an attribute and returns its double value.

See Also
RequireAttributeValue
Parameters
attribthe attribute name
Returns
the attribute value

Definition at line 487 of file genxmlpars.cpp.

int a2dIOHandlerXMLPull::RequireAttributeValueInt ( const wxString &  attrib)

Forces an attribute and returns its integer value.

See Also
RequireAttributeValue
Parameters
attribthe attribute name
Returns
the attribute value

Definition at line 508 of file genxmlpars.cpp.

long a2dIOHandlerXMLPull::RequireAttributeValueLong ( const wxString &  attrib)

Forces an attribute and returns its long integer value.

See Also
RequireAttributeValue
Parameters
attribthe attribute name
Returns
the attribute value

Definition at line 529 of file genxmlpars.cpp.

void a2dIOHandlerXMLPull::SetScale ( double  scale)
inline

Scale factor to scale input numbers (int double etc. ) with this. This can be used by a derived IO handler to scale input numbers.

Definition at line 542 of file genxmlpars.h.


The documentation for this class was generated from the following files:
a2dIOHandlerXMLPull Class Reference -- Sun Oct 12 2014 17:04:41 -- Sun Oct 12 2014 -- 1.8.5 -- wxArt2D -- . -- Main Page Reference Documentation