Logo Search packages:      
Sourcecode: zeromq version File versions  Download package

XMLNode Struct Reference

#include <xmlParser.hpp>

List of all members.


Detailed Description

Main Class representing a XML node.

All operations are performed using this class.

Note:
The constructors of the XMLNode class are protected, so use instead one of these four methods to get your first instance of XMLNode:

Definition at line 257 of file xmlParser.hpp.


Public Types

typedef enum
XMLNode::XMLCharEncoding 
XMLCharEncoding
 Enumeration for XML character encoding.
enum  XMLCharEncoding {
  char_encoding_error = 0, char_encoding_UTF8 = 1, char_encoding_legacy = 2, char_encoding_ShiftJIS = 3,
  char_encoding_GB2312 = 4, char_encoding_Big5 = 5, char_encoding_GBK = 6
}
 Enumeration for XML character encoding.

Public Member Functions

XMLAttributeaddAttribute (XMLCSTR lpszName, XMLCSTR lpszValuev)
 Add a new attribute.
XMLAttributeaddAttribute_WOSD (XMLSTR lpszName, XMLSTR lpszValue)
 Add a new attribute.
XMLNode addChild (XMLNode nodeToAdd, XMLElementPosition pos=-1)
 If the "nodeToAdd" has some parents, it will be detached from it's parents before being attached to the current XMLNode.
XMLNode addChild (XMLCSTR lpszName, char isDeclaration=FALSE, XMLElementPosition pos=-1)
 Add a new child node.
XMLNode addChild_WOSD (XMLSTR lpszName, char isDeclaration=FALSE, XMLElementPosition pos=-1)
 Add a new child node.
XMLClearaddClear (XMLCSTR lpszValue, XMLCSTR lpszOpen=NULL, XMLCSTR lpszClose=NULL, XMLElementPosition pos=-1)
XMLClearaddClear_WOSD (XMLSTR lpszValue, XMLCSTR lpszOpen=NULL, XMLCSTR lpszClose=NULL, XMLElementPosition pos=-1)
 Add a new clear Tag.
XMLCSTR addText (XMLCSTR lpszValue, XMLElementPosition pos=-1)
 Add a new text content.
XMLCSTR addText_WOSD (XMLSTR lpszValue, XMLElementPosition pos=-1)
 Add a new text content.
XMLSTR createXMLString (int nFormat=1, int *pnSize=NULL) const
 Create an XML string starting from the current XMLNode.
XMLNode deepCopy () const
 deep copy (duplicate/clone) a XMLNode
void deleteAttribute (XMLAttribute *anAttribute)
 Delete the attribute with the name "anAttribute->lpszName" (the "strcmp" function is used to find the right attribute).
void deleteAttribute (XMLCSTR lpszName)
 Delete the attribute with the given name (the "strcmp" function is used to find the right attribute).
void deleteAttribute (int i=0)
 Delete the ith attribute of the current XMLNode.
void deleteClear (XMLClear *p)
 Delete the clear tag "p" inside the current XMLNode (direct "pointer-to-pointer" comparison on the lpszName of the clear tag is used to find the clear tag).
void deleteClear (XMLCSTR lpszValue)
 Delete the clear tag "lpszValue" inside the current XMLNode (direct "pointer-to-pointer" comparison is used to find the clear tag).
void deleteClear (int i=0)
 Delete the Ith clear tag inside the current XMLNode.
void deleteNodeContent ()
 The "deleteNodeContent" function forces the deletion of the content of this XMLNode and the subtree.
void deleteText (XMLCSTR lpszValue)
 Delete the text content "lpszValue" inside the current XMLNode (direct "pointer-to-pointer" comparison is used to find the right text).
void deleteText (int i=0)
 Delete the Ith text content of the current XMLNode.
XMLNodeContents enumContents (XMLElementPosition i) const
 enumerate all the different contents (attribute,child,text, clear) of the current XMLNode. The order is reflecting the order of the original file/string. NOTE: 0 <= i < nElement();
XMLCSTR getAttribute (XMLCSTR name, int *i=NULL) const
 return next attribute content with specific name (return a NULL if failing)
XMLCSTR getAttribute (XMLCSTR name, int i) const
 return ith attribute content with specific name (return a NULL if failing)
XMLAttribute getAttribute (int i=0) const
 return ith attribute
XMLCSTR getAttributeName (int i=0) const
 return ith attribute name
XMLCSTR getAttributeValue (int i=0) const
 return ith attribute value
XMLNode getChildNode (XMLCSTR name, int *i=NULL) const
 return next child node with specific name (return an empty node if failing)
XMLNode getChildNode (XMLCSTR name, int i) const
 return ith child node with specific name (return an empty node if failing). If i==-1, this returns the last XMLNode with the given name.
XMLNode getChildNode (int i=0) const
 return ith child node
XMLNode getChildNodeByPath (XMLCSTR path, char createNodeIfMissing=0, XMLCHAR sep='/')
 return the first child node with specific path
XMLNode getChildNodeByPathNonConst (XMLSTR path, char createNodeIfMissing=0, XMLCHAR sep='/')
 return the first child node with specific path.
XMLNode getChildNodeWithAttribute (XMLCSTR tagName, XMLCSTR attributeName, XMLCSTR attributeValue=NULL, int *i=NULL) const
 return child node with specific name/attribute (return an empty node if failing)
XMLClear getClear (int i=0) const
 return ith clear field (comments)
XMLCSTR getName () const
 name of the node
XMLNode getParentNode () const
 return the parent node
XMLCSTR getText (int i=0) const
 return ith text field
char isAttributeSet (XMLCSTR name) const
 test if an attribute with a specific name is given
char isDeclaration () const
 is this node a declaration <? .... ?>
char isEmpty () const
 is this node Empty?
int nAttribute () const
 nbr of attribute
int nChildNode () const
 nbr of child node
int nChildNode (XMLCSTR name) const
 return the number of child node with specific name
int nClear () const
 nbr of clear field
int nElement () const
 nbr of different contents for current node
int nText () const
 nbr of text field
XMLNodeoperator= (const XMLNode &A)
 to allow shallow/fast copy:
XMLElementPosition positionOfChildNode (XMLCSTR name, int i=0) const
 return the position of the ith childNode with the specified name if (name==NULL) return the position of the ith childNode
XMLElementPosition positionOfChildNode (XMLNode x) const
XMLElementPosition positionOfChildNode (int i=0) const
XMLElementPosition positionOfClear (XMLClear *a) const
XMLElementPosition positionOfClear (XMLCSTR lpszValue) const
XMLElementPosition positionOfClear (int i=0) const
XMLElementPosition positionOfText (XMLCSTR lpszValue) const
XMLElementPosition positionOfText (int i=0) const
XMLAttributeupdateAttribute (XMLCSTR lpszNewValue, XMLCSTR lpszNewName, XMLCSTR lpszOldName)
 set lpszNewName=NULL if you don't want to change the name of the attribute if the attribute to update is missing, a new one will be added
XMLAttributeupdateAttribute (XMLCSTR lpszNewValue, XMLCSTR lpszNewName=NULL, int i=0)
 if the attribute to update is missing, a new one will be added
XMLAttributeupdateAttribute (XMLAttribute *newAttribute, XMLAttribute *oldAttribute)
 if the attribute to update is missing, a new one will be added
XMLAttributeupdateAttribute_WOSD (XMLSTR lpszNewValue, XMLSTR lpszNewName, XMLCSTR lpszOldName)
 set lpszNewName=NULL if you don't want to change the name of the attribute if the attribute to update is missing, a new one will be added
XMLAttributeupdateAttribute_WOSD (XMLSTR lpszNewValue, XMLSTR lpszNewName=NULL, int i=0)
 if the attribute to update is missing, a new one will be added
XMLAttributeupdateAttribute_WOSD (XMLAttribute *newAttribute, XMLAttribute *oldAttribute)
 if the attribute to update is missing, a new one will be added
XMLClearupdateClear (XMLCSTR lpszNewValue, XMLCSTR lpszOldValue)
 if the clearTag to update is missing, a new one will be added
XMLClearupdateClear (XMLClear *newP, XMLClear *oldP)
 if the clearTag to update is missing, a new one will be added
XMLClearupdateClear (XMLCSTR lpszNewContent, int i=0)
 if the clearTag to update is missing, a new one will be added
XMLClearupdateClear_WOSD (XMLSTR lpszNewValue, XMLCSTR lpszOldValue)
 if the clearTag to update is missing, a new one will be added
XMLClearupdateClear_WOSD (XMLClear *newP, XMLClear *oldP)
 if the clearTag to update is missing, a new one will be added
XMLClearupdateClear_WOSD (XMLSTR lpszNewContent, int i=0)
 if the clearTag to update is missing, a new one will be added
XMLCSTR updateName (XMLCSTR lpszName)
 change node's name
XMLCSTR updateName_WOSD (XMLSTR lpszName)
 change node's name
XMLCSTR updateText (XMLCSTR lpszNewValue, XMLCSTR lpszOldValue)
 if the text to update is missing, a new one will be added
XMLCSTR updateText (XMLCSTR lpszNewValue, int i=0)
 if the text to update is missing, a new one will be added
XMLCSTR updateText_WOSD (XMLSTR lpszNewValue, XMLCSTR lpszOldValue)
 if the text to update is missing, a new one will be added
XMLCSTR updateText_WOSD (XMLSTR lpszNewValue, int i=0)
 if the text to update is missing, a new one will be added
XMLError writeToFile (XMLCSTR filename, const char *encoding=NULL, char nFormat=1) const
 Save the content of an xmlNode inside a file.
 XMLNode (const XMLNode &A)
 to allow shallow/fast copy:

Static Public Member Functions

static XMLNode createXMLTopNode (XMLCSTR lpszName, char isDeclaration=FALSE)
 Create the top node of an XMLNode structure.
static XMLNode createXMLTopNode_WOSD (XMLSTR lpszName, char isDeclaration=FALSE)
 Create the top node of an XMLNode structure.
static XMLNode emptyNode ()
 return XMLNode::emptyXMLNode;
static XMLCSTR getError (XMLError error)
 this gives you a user-friendly explanation of the parsing error
static XMLCSTR getVersion ()
 Return the XMLParser library version number.
static XMLCharEncoding guessCharEncoding (void *buffer, int bufLen, char useXMLEncodingAttribute=1)
 Guess the character encoding of the string (ascii, utf8 or shift-JIS).
static XMLNode openFileHelper (XMLCSTR filename, XMLCSTR tag=NULL)
 Parse an XML file and return the root of a XMLNode tree representing the file. A very crude error checking is made. An attempt to guess the Char Encoding used in the file is made.
static XMLNode parseFile (XMLCSTR filename, XMLCSTR tag=NULL, XMLResults *pResults=NULL)
 Parse an XML file and return the root of a XMLNode tree representing the file.
static XMLNode parseString (XMLCSTR lpXMLString, XMLCSTR tag=NULL, XMLResults *pResults=NULL)
 Parse an XML string and return the root of a XMLNode tree representing the string.
static char setGlobalOptions (XMLCharEncoding characterEncoding=XMLNode::char_encoding_UTF8, char guessWideCharChars=1, char dropWhiteSpace=1, char removeCommentsInMiddleOfText=1)
 Sets the global options for the conversions.

Static Public Attributes

static XMLAttribute emptyXMLAttribute = { NULL, NULL}
static XMLClear emptyXMLClear = { NULL, NULL, NULL}
static XMLNode emptyXMLNode

Private Types

typedef struct
XMLNode::XMLNodeDataTag 
XMLNodeData

Private Member Functions

XMLAttributeaddAttribute_priv (int, XMLSTR, XMLSTR)
XMLNode addChild_priv (int, XMLSTR, char, int)
XMLClearaddClear_priv (int, XMLSTR, XMLCSTR, XMLCSTR, int)
XMLCSTR addText_priv (int, XMLSTR, int)
void * addToOrder (int memInc, int *_pos, int nc, void *p, int size, XMLElementType xtype)
void emptyTheNode (char force)
int indexClear (XMLCSTR lpszValue) const
int indexText (XMLCSTR lpszValue) const
char maybeAddTxT (void *pa, XMLCSTR tokenPStr)
char parseClearTag (void *px, void *pa)
int ParseXMLElement (void *pXML)
 XMLNode (struct XMLNodeDataTag *p)
 Constructors are protected, so use instead one of: XMLNode::parseString, XMLNode::parseFile, XMLNode::openFileHelper, XMLNode::createXMLTopNode.
 XMLNode (struct XMLNodeDataTag *pParent, XMLSTR lpszName, char isDeclaration)
 Constructors are protected, so use instead one of: XMLNode::parseString, XMLNode::parseFile, XMLNode::openFileHelper, XMLNode::createXMLTopNode.

Static Private Member Functions

static int CreateXMLStringR (XMLNodeData *pEntry, XMLSTR lpszMarker, int nFormat)
static int detachFromParent (XMLNodeData *d)
static void exactMemory (XMLNodeData *d)
static XMLElementPosition findPosition (XMLNodeData *d, int index, XMLElementType xtype)
static int removeOrderElement (XMLNodeData *d, XMLElementType t, int index)

Private Attributes

XMLNodeData * d

Classes

struct  XMLNodeDataTag

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

Generated by  Doxygen 1.6.0   Back to index