Main Class representing a XML node.
All operations are performed using this class.
Definition at line 313 of file xmlParser.h.
#include <xmlparser/xmlParser.h>
Classes | |
struct | XMLNodeDataTag |
Public Types | |
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 } |
childNode with the specified name if (name==nullptr) return the position of the ith childNode More... | |
typedef enum XMLNode::XMLCharEncoding | XMLCharEncoding |
childNode with the specified name if (name==nullptr) return the position of the ith childNode More... | |
Public Member Functions | |
XMLSTR | createXMLString (int nFormat=1, int *pnSize=nullptr) const |
user-friendly explanation of the parsing error More... | |
XMLError | writeToFile (XMLCSTR filename, const char *encoding=nullptr, char nFormat=1) const |
Save the content of an xmlNode inside a file. More... | |
XMLCSTR | getName () const |
name of the node More... | |
XMLCSTR | getText (int i=0) const |
return ith text field More... | |
int | nText () const |
nbr of text field More... | |
XMLNode | getParentNode () const |
return the parent node More... | |
XMLNode | getChildNode (int i=0) const |
return ith child node More... | |
XMLNode | getChildNode (XMLCSTR name, int i) const |
return ith child node More... | |
XMLNode | getChildNode (XMLCSTR name, int *i=nullptr) const |
with specific name (return an empty node if failing). More... | |
XMLNode | getChildNodeWithAttribute (XMLCSTR tagName, XMLCSTR attributeName, XMLCSTR attributeValue=nullptr, int *i=nullptr) const |
next child node with specific name (return an empty node if failing) More... | |
XMLNode | getChildNodeByPath (XMLSTR path, char createNodeIfMissing=0, XMLCHAR sep='/') |
name/attribute (return an empty node if failing) More... | |
XMLNode | getChildNodeByPath (XMLCSTR path, char createNodeIfMissing=0, XMLCHAR sep='/') |
return the first child node with specific path More... | |
int | nChildNode (XMLCSTR name) const |
return the number of child node with specific name More... | |
int | nChildNode () const |
nbr of child node More... | |
XMLAttribute | getAttribute (int i=0) const |
return ith attribute More... | |
XMLCSTR | getAttributeName (int i=0) const |
return ith attribute name More... | |
XMLCSTR | getAttributeValue (int i=0) const |
return ith attribute value More... | |
char | isAttributeSet (XMLCSTR name) const |
test if an attribute with a specific name is given More... | |
XMLCSTR | getAttribute (XMLCSTR name, int i) const |
return ith attribute More... | |
XMLCSTR | getAttribute (XMLCSTR name, int *i=nullptr) const |
content with specific name (return a nullptr if failing) More... | |
int | nAttribute () const |
next attribute content with specific name (return a nullptr if failing) More... | |
XMLClear | getClear (int i=0) const |
return ith clear field (comments) More... | |
int | nClear () const |
nbr of clear field More... | |
XMLNodeContents | enumContents (XMLElementPosition i) const |
enumerate all the different contents (attribute,child,text, More... | |
int | nElement () const |
clear) of the current XMLNode. More... | |
char | isEmpty () const |
is this node Empty? More... | |
char | isDeclaration () const |
is this node a declaration <? .... ?> More... | |
XMLNode | deepCopy () const |
deep copy (duplicate/clone) a XMLNode More... | |
~XMLNode () | |
XMLNode (const XMLNode &A) | |
to allow shallow/fast copy: More... | |
XMLNode & | operator= (const XMLNode &A) |
to allow shallow/fast copy: More... | |
XMLNode () | |
XMLNode | addChild (XMLCSTR lpszName, char isDeclaration=FALSE, XMLElementPosition pos=-1) |
Add a new child node. More... | |
XMLNode | addChild (XMLNode nodeToAdd, XMLElementPosition pos=-1) |
If the "nodeToAdd" has some parents,. More... | |
XMLAttribute * | addAttribute (XMLCSTR lpszName, XMLCSTR lpszValuev) |
it will be detached from it's parents before being attached to the current XMLNode More... | |
XMLCSTR | addText (XMLCSTR lpszValue, XMLElementPosition pos=-1) |
Add a new text content. More... | |
XMLClear * | addClear (XMLCSTR lpszValue, XMLCSTR lpszOpen=nullptr, XMLCSTR lpszClose=nullptr, XMLElementPosition pos=-1) |
Add a new clear tag. More... | |
XMLCSTR | updateName (XMLCSTR lpszName) |
change node's name More... | |
XMLAttribute * | updateAttribute (XMLAttribute *newAttribute, XMLAttribute *oldAttribute) |
if the attribute to update is More... | |
XMLAttribute * | updateAttribute (XMLCSTR lpszNewValue, XMLCSTR lpszNewName=nullptr, int i=0) |
missing, a new one will be added More... | |
XMLAttribute * | updateAttribute (XMLCSTR lpszNewValue, XMLCSTR lpszNewName, XMLCSTR lpszOldName) |
be added More... | |
XMLCSTR | updateText (XMLCSTR lpszNewValue, int i=0) |
change the name of the attribute if the attribute to update is missing, a new one will be added More... | |
XMLCSTR | updateText (XMLCSTR lpszNewValue, XMLCSTR lpszOldValue) |
update is missing, a new one will be added More... | |
XMLClear * | updateClear (XMLCSTR lpszNewContent, int i=0) |
text to update is missing, a new one will be added More... | |
XMLClear * | updateClear (XMLClear *newP, XMLClear *oldP) |
clearTag to update is missing, a new one will be added More... | |
XMLClear * | updateClear (XMLCSTR lpszNewValue, XMLCSTR lpszOldValue) |
to update is missing, a new one will be added More... | |
void | deleteNodeContent () |
The "deleteNodeContent" function forces the deletion of the content of this XMLNode and the subtree. More... | |
void | deleteAttribute (int i=0) |
Delete the ith attribute of the current XMLNode. More... | |
void | deleteAttribute (XMLCSTR lpszName) |
Delete the attribute with the. More... | |
void | deleteAttribute (XMLAttribute *anAttribute) |
given name (the "strcmp" function is used to find the right attribute) More... | |
void | deleteText (int i=0) |
with the name "anAttribute->lpszName" (the "strcmp" function is used to find the right attribute) More... | |
void | deleteText (XMLCSTR lpszValue) |
Delete the text content. More... | |
void | deleteClear (int i=0) |
"lpszValue" inside the current XMLNode (direct "pointer-to-pointer" comparison is used to find the right text) More... | |
void | deleteClear (XMLCSTR lpszValue) |
Delete the clear tag "lpszValue". More... | |
void | deleteClear (XMLClear *p) |
inside the current XMLNode (direct "pointer-to-pointer" comparison is used to find the clear tag) More... | |
XMLNode | addChild_WOSD (XMLSTR lpszName, char isDeclaration=FALSE, XMLElementPosition pos=-1) |
Add a new child node. More... | |
XMLAttribute * | addAttribute_WOSD (XMLSTR lpszName, XMLSTR lpszValue) |
Add a new attribute. More... | |
XMLCSTR | addText_WOSD (XMLSTR lpszValue, XMLElementPosition pos=-1) |
Add a new text content. More... | |
XMLClear * | addClear_WOSD (XMLSTR lpszValue, XMLCSTR lpszOpen=nullptr, XMLCSTR lpszClose=nullptr, XMLElementPosition pos=-1) |
Add a new clear Tag. More... | |
XMLCSTR | updateName_WOSD (XMLSTR lpszName) |
change node's name More... | |
XMLAttribute * | updateAttribute_WOSD (XMLAttribute *newAttribute, XMLAttribute *oldAttribute) |
if the attribute to update is More... | |
XMLAttribute * | updateAttribute_WOSD (XMLSTR lpszNewValue, XMLSTR lpszNewName=nullptr, int i=0) |
missing, a new one will be added More... | |
XMLAttribute * | updateAttribute_WOSD (XMLSTR lpszNewValue, XMLSTR lpszNewName, XMLCSTR lpszOldName) |
be added More... | |
XMLCSTR | updateText_WOSD (XMLSTR lpszNewValue, int i=0) |
change the name of the attribute if the attribute to update is missing, a new one will be added More... | |
XMLCSTR | updateText_WOSD (XMLSTR lpszNewValue, XMLCSTR lpszOldValue) |
if the text to update More... | |
XMLClear * | updateClear_WOSD (XMLSTR lpszNewContent, int i=0) |
is missing, a new one will be added More... | |
XMLClear * | updateClear_WOSD (XMLClear *newP, XMLClear *oldP) |
clearTag to update is missing, a new one will be added More... | |
XMLClear * | updateClear_WOSD (XMLSTR lpszNewValue, XMLCSTR lpszOldValue) |
clearTag to update is missing, a new one will be added More... | |
XMLElementPosition | positionOfText (int i=0) const |
XMLElementPosition | positionOfText (XMLCSTR lpszValue) const |
XMLElementPosition | positionOfClear (int i=0) const |
XMLElementPosition | positionOfClear (XMLCSTR lpszValue) const |
XMLElementPosition | positionOfClear (XMLClear *a) const |
XMLElementPosition | positionOfChildNode (int i=0) const |
XMLElementPosition | positionOfChildNode (XMLNode x) const |
XMLElementPosition | positionOfChildNode (XMLCSTR name, int i=0) const |
return the position of the ith More... | |
Static Public Member Functions | |
static XMLCSTR | getVersion () |
Return the XMLParser library version number. More... | |
static XMLNode | parseString (XMLCSTR lpXMLString, XMLCSTR tag=nullptr, XMLResults *pResults=nullptr) |
Parse an XML string and return the root of a XMLNode tree representing the string. More... | |
static XMLNode | parseFile (XMLCSTR filename, XMLCSTR tag=nullptr, XMLResults *pResults=nullptr) |
Parse an XML file and return the root of a XMLNode tree representing the file. More... | |
static XMLNode | openFileHelper (XMLCSTR filename, XMLCSTR tag=nullptr) |
Parse an XML file and return the root of a XMLNode tree representing the file. More... | |
static XMLCSTR | getError (XMLError error) |
this gives you a More... | |
static XMLNode | emptyNode () |
return XMLNode::emptyXMLNode; More... | |
static XMLNode | createXMLTopNode (XMLCSTR lpszName, char isDeclaration=FALSE) |
Create the top node of an XMLNode structure. More... | |
static XMLNode | createXMLTopNode_WOSD (XMLSTR lpszName, char isDeclaration=FALSE) |
Create the top node of an XMLNode structure. More... | |
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. More... | |
static XMLCharEncoding | guessCharEncoding (void *buffer, int bufLen, char useXMLEncodingAttribute=1) |
Guess the character encoding of the string (ascii, utf8 or shift-JIS) More... | |
Static Public Attributes | |
static XMLNode | emptyXMLNode |
static XMLClear | emptyXMLClear = {nullptr, nullptr, nullptr} |
static XMLAttribute | emptyXMLAttribute = {nullptr, nullptr} |
Private Types | |
typedef struct XMLNode::XMLNodeDataTag | XMLNodeData |
Private Member Functions | |
XMLNode (struct XMLNodeDataTag *pParent, XMLSTR lpszName, char isDeclaration) | |
Constructors are protected, so use instead one of: XMLNode::parseString, XMLNode::parseFile, XMLNode::openFileHelper, XMLNode::createXMLTopNode. More... | |
XMLNode (struct XMLNodeDataTag *p) | |
Constructors are protected, so use instead one of: XMLNode::parseString, XMLNode::parseFile, XMLNode::openFileHelper, XMLNode::createXMLTopNode. More... | |
char | parseClearTag (void *px, void *pa) |
char | maybeAddTxT (void *pa, XMLCSTR tokenPStr) |
int | ParseXMLElement (void *pXML) |
void * | addToOrder (int memInc, int *_pos, int nc, void *p, int size, XMLElementType xtype) |
int | indexText (XMLCSTR lpszValue) const |
int | indexClear (XMLCSTR lpszValue) const |
XMLNode | addChild_priv (int, XMLSTR, char, int) |
XMLAttribute * | addAttribute_priv (int, XMLSTR, XMLSTR) |
XMLCSTR | addText_priv (int, XMLSTR, int) |
XMLClear * | addClear_priv (int, XMLSTR, XMLCSTR, XMLCSTR, int) |
void | emptyTheNode (char force) |
Static Private Member Functions | |
static XMLElementPosition | findPosition (XMLNodeData *d, int index, XMLElementType xtype) |
static int | CreateXMLStringR (XMLNodeData *pEntry, XMLSTR lpszMarker, int nFormat) |
static int | removeOrderElement (XMLNodeData *d, XMLElementType t, int index) |
static void | exactMemory (XMLNodeData *d) |
static int | detachFromParent (XMLNodeData *d) |
Private Attributes | |
XMLNodeData * | d |
typedef enum XMLNode::XMLCharEncoding XMLNode::XMLCharEncoding |
childNode with the specified name if (name==nullptr) return the position of the ith childNode
Enumeration for XML character encoding.
|
private |
enum XMLNode::XMLCharEncoding |
childNode with the specified name if (name==nullptr) return the position of the ith childNode
Enumeration for XML character encoding.
Enumerator | |
---|---|
char_encoding_error | |
char_encoding_UTF8 | |
char_encoding_legacy | |
char_encoding_ShiftJIS | |
char_encoding_GB2312 | |
char_encoding_Big5 | |
char_encoding_GBK |
Definition at line 777 of file xmlParser.h.
|
private |
Constructors are protected, so use instead one of: XMLNode::parseString, XMLNode::parseFile, XMLNode::openFileHelper, XMLNode::createXMLTopNode.
|
private |
Constructors are protected, so use instead one of: XMLNode::parseString, XMLNode::parseFile, XMLNode::openFileHelper, XMLNode::createXMLTopNode.
Definition at line 1382 of file xmlParser.cpp.
References d.
XMLNode::~XMLNode | ( | ) |
Definition at line 2701 of file xmlParser.cpp.
References d, and emptyTheNode().
XMLNode::XMLNode | ( | const XMLNode & | A | ) |
|
inline |
Definition at line 520 of file xmlParser.h.
Referenced by addChild_priv(), createXMLTopNode(), createXMLTopNode_WOSD(), and getParentNode().
|
private |
Definition at line 1525 of file xmlParser.cpp.
References d, emptyXMLAttribute, XMLAttribute::lpszName, XMLAttribute::lpszValue, myFree(), and myRealloc().
Referenced by addAttribute(), addAttribute_WOSD(), and ParseXMLElement().
|
private |
Definition at line 1511 of file xmlParser.cpp.
References addToOrder(), d, emptyXMLNode, eNodeChild, isDeclaration(), and XMLNode().
Referenced by addChild(), addChild_WOSD(), and ParseXMLElement().
|
private |
Definition at line 1562 of file xmlParser.cpp.
References addToOrder(), d, emptyXMLClear, eNodeClear, ALLXMLClearTag::lpszClose, XMLClear::lpszCloseTag, ALLXMLClearTag::lpszOpen, XMLClear::lpszOpenTag, XMLClear::lpszValue, myFree(), and XMLClearTags.
Referenced by addClear(), addClear_WOSD(), and parseClearTag().
Definition at line 1546 of file xmlParser.cpp.
References addToOrder(), d, eNodeText, myFree(), XMLCSTR, and XMLSTR.
Referenced by addText(), addText_WOSD(), and maybeAddTxT().
|
private |
Definition at line 1468 of file xmlParser.cpp.
References d, and myRealloc().
Referenced by addChild(), addChild_priv(), addClear_priv(), and addText_priv().
|
staticprivate |
Definition at line 2376 of file xmlParser.cpp.
References _CXML, charmemset(), eNodeChild, eNodeClear, eNodeText, INDENTCHAR, ToXMLStringTool::lengthXMLString(), LENSTR, XMLClear::lpszCloseTag, XMLAttribute::lpszName, XMLClear::lpszOpenTag, XMLClear::lpszValue, XMLAttribute::lpszValue, ToXMLStringTool::toXMLUnSafe(), XMLCSTR, and xstrcpy().
Referenced by createXMLString().
|
staticprivate |
Definition at line 2685 of file xmlParser.cpp.
References d, eNodeChild, and removeOrderElement().
Referenced by addChild(), deleteNodeContent(), and emptyTheNode().
|
private |
Definition at line 2718 of file xmlParser.cpp.
References d, detachFromParent(), emptyTheNode(), and myFree().
Referenced by deleteNodeContent(), emptyTheNode(), operator=(), and ~XMLNode().
|
staticprivate |
Definition at line 1643 of file xmlParser.cpp.
References d, XMLCSTR, and XMLSTR.
Referenced by ParseXMLElement().
|
inlinestaticprivate |
Definition at line 1443 of file xmlParser.cpp.
References d.
Referenced by positionOfChildNode(), positionOfClear(), positionOfText(), and removeOrderElement().
|
static |
Return the XMLParser library version number.
Definition at line 27 of file xmlParser.cpp.
References _CXML.
|
private |
Definition at line 3036 of file xmlParser.cpp.
References d.
Referenced by deleteClear(), positionOfClear(), and updateClear_WOSD().
|
private |
Definition at line 2955 of file xmlParser.cpp.
Referenced by deleteText(), positionOfText(), and updateText_WOSD().
Definition at line 1659 of file xmlParser.cpp.
References addText_priv(), d, deleteClear(), dropWhiteSpace, eNodeClear, eNodeText, fromXMLString(), ALLXMLClearTag::lpszOpen, XML::lpszText, mrpt::system::os::memcpy(), MEMORYINCREASE, removeCommentsInMiddleOfText, XML_isSPACECHAR, XMLCHAR, XMLClearTags, XMLCSTR, XMLSTR, and xstrlen().
Referenced by ParseXMLElement().
to allow shallow/fast copy:
Definition at line 2766 of file xmlParser.cpp.
References d, and emptyTheNode().
Definition at line 1587 of file xmlParser.cpp.
References _CXML, addClear_priv(), XML::error, eXMLErrorUnmatchedEndClearTag, ALLXMLClearTag::lpszClose, ALLXMLClearTag::lpszOpen, XML::lpXML, MEMORYINCREASE, XML::nIndex, stringDup(), XML_ByteTable, XMLClearTags, XMLCSTR, xstrlen(), and xstrstr().
Referenced by ParseXMLElement().
|
private |
Definition at line 1716 of file xmlParser.cpp.
References _CXML, addAttribute_priv(), addChild_priv(), XML::cbEndTag, XML::cbNewElement, d, emptyXMLNode, XML::error, eTokenClear, eTokenCloseTag, eTokenDeclaration, eTokenEquals, eTokenError, eTokenQuotedText, eTokenShortHandClose, eTokenTagEnd, eTokenTagStart, eTokenText, exactMemory(), eXMLErrorMissingEndTag, eXMLErrorMissingEndTagName, eXMLErrorMissingTagName, eXMLErrorUnexpectedToken, eXMLErrorUnmatchedEndTag, FALSE, fromXMLString(), GetNextToken(), isEmpty(), XML::lpEndTag, XML::lpNewElement, XML::lpszText, XML::lpXML, maybeAddTxT(), MEMORYINCREASE, myTagCompare(), XML::nFirst, XML::nIndex, XML::nIndexMissigEndTag, parseClearTag(), ParseXMLElement(), NextToken::pClr, NextToken::pStr, status, stringDup(), TRUE, XMLCSTR, and XMLSTR.
Referenced by parseString(), and ParseXMLElement().
|
staticprivate |
Definition at line 1454 of file xmlParser.cpp.
References d, and findPosition().
Referenced by deleteClear(), deleteText(), and detachFromParent().
|
private |
Definition at line 916 of file xmlParser.h.
Referenced by addAttribute_priv(), addChild(), addChild_priv(), addClear_priv(), addText_priv(), addToOrder(), createXMLString(), deepCopy(), deleteAttribute(), deleteClear(), deleteNodeContent(), deleteText(), detachFromParent(), emptyTheNode(), enumContents(), exactMemory(), findPosition(), getAttribute(), getAttributeName(), getAttributeValue(), getChildNode(), getClear(), getName(), getParentNode(), getText(), indexClear(), indexText(), isAttributeSet(), isDeclaration(), isEmpty(), maybeAddTxT(), nAttribute(), nChildNode(), nClear(), nElement(), nText(), operator=(), ParseXMLElement(), positionOfChildNode(), positionOfClear(), positionOfText(), removeOrderElement(), updateAttribute_WOSD(), updateClear_WOSD(), updateName_WOSD(), updateText_WOSD(), writeToFile(), XMLNode(), and ~XMLNode().
|
static |
Definition at line 523 of file xmlParser.h.
Referenced by addAttribute_priv(), and getAttribute().
|
static |
Definition at line 522 of file xmlParser.h.
Referenced by addClear_priv(), and getClear().
|
static |
Definition at line 520 of file xmlParser.h.
Referenced by addChild_priv(), deepCopy(), emptyNode(), getChildNode(), getChildNodeByPath(), getChildNodeWithAttribute(), getParentNode(), parseFile(), parseString(), and ParseXMLElement().
Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST |