![]() |
Gray C++ Libraries
0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
|
#include <cXmlDocument.h>
Public Member Functions | |
virtual | ~cXmlNode () |
XMLNODE_TYPE | get_Type () const |
bool | isType (XMLNODE_TYPE eType) const |
void | put_UserData (void *pUserData) |
void * | get_UserData () const |
virtual void | SetClear () |
Delete all the children of this node. Does not affect 'this'. More... | |
void | put_Value (cXmlString sValue) |
const cXmlString & | get_Value () const |
HRESULT | QueryValueInt (int *piValue) const |
HRESULT | QueryValueDouble (double *pdValue) const |
QueryValueDouble examines the value string. See QueryValueInt(). More... | |
int | get_ValueInt () const |
Return the value of this attribute, converted to an integer. More... | |
double | get_ValueDouble () const |
Return the value of this attribute, converted to a double. More... | |
void | put_ValueInt (int iValue) |
Set the value from an integer. More... | |
void | put_ValueDouble (double dValue) |
Set the value from a double. More... | |
cXmlDocument * | get_Document () const |
cXmlNode * | GetPreviousSibling (const char *pszValue) const |
Navigate to a sibling node. More... | |
cXmlNode * | GetNextSiblingX (const char *pszValue) const |
Navigate to a sibling node with the given 'value'. More... | |
cXmlElement * | get_NextSiblingElement () const |
cXmlElement * | GetNextSiblingElement (const char *pszValue) const |
virtual cXmlContainer * | ToContainer () |
virtual cXmlNode * | Clone () const =0 |
virtual HRESULT | SetParseNode (cXmlReader &rReader)=0 |
HRESULT | SetParse (const char *pszData, CXML_ENCODING_TYPE eEncoding=CXML_ENCODING_UNKNOWN) |
virtual HRESULT | Print (cStreamOutput &rOut, int nDepth=0) const =0 |
virtual bool | OnVisit (IXmlVisitor *pVisitor) const =0 |
ITERATE_t | get_Row () const |
StrLen_t | get_Column () const |
![]() | |
cXmlNode * | get_Next () const |
cXmlNode * | get_Prev () const |
![]() | |
virtual | ~cListNodeBase () |
cListBase * | get_Parent () const noexcept |
cListNodeBase * | get_Next () const noexcept |
cListNodeBase * | get_Prev () const noexcept |
bool | hasParent () const noexcept |
void | RemoveFromParent () |
virtual HRESULT | DisposeThis () |
![]() | |
cHeapObject () | |
virtual | ~cHeapObject () |
bool | IsValidInsideN (INT_PTR index) const |
bool | IsValidInsidePtr (void const *pTest) const |
virtual size_t | GetHeapStatsThis (OUT ITERATE_t &iAllocCount) const |
virtual bool | isValidCheck () const noexcept |
Static Public Member Functions | |
static HRESULT | PrintDepth (cStreamOutput &rOut, int nDepth) |
![]() | |
static StrLen_t GRAYCALL | ParseMicrosoftBOM (const BYTE *pszData) |
static bool GRAYCALL | IsXML (const IniChar_t *pszStr, StrLen_t iLenMax=StrT::k_LEN_MAX) |
static cXmlString GRAYCALL | GetAttributeStr (const IniChar_t *pszName, const cXmlString &sValue) |
static void | AddPathElement (cXmlString &sPath, const cXmlString &sElement) |
static void | RemovePathElement (cXmlString &sPath, const cXmlString &sElement) |
Public Attributes | |
cTextPos | m_Pos |
Where (line,col) in the parsed XML document is this node? m_PosNode. More... | |
Protected Member Functions | |
cXmlNode (XMLNODE_TYPE eNodeType, cXmlString sValue="") | |
Only instantiate as a derived type. More... | |
virtual void | SetCopy (const cXmlNode &n) |
![]() | |
virtual void | put_Parent (cListBase *pParent) |
cListNodeBase () noexcept | |
![]() | |
const void * | get_HeapPtr () const noexcept override |
Get the top level (outermost, freeable) class pointer. I can delete get_HeapPtr(). More... | |
![]() | |
cNonCopyable () noexcept | |
Force the use of Factory creation via protected constructor. More... | |
~cNonCopyable () noexcept | |
Protected Attributes | |
const XMLNODE_TYPE | m_eNodeType |
cXmlString | m_sValue |
parent usage dependent m_eNodeType. More... | |
void * | m_pUserData |
Field containing a generic pointer to arbitrary user data. More... | |
Additional Inherited Members | |
![]() | |
enum | XMLNODE_TYPE { XMLNODE_QTY } |
![]() | |
static const char | k_xmlHeader [6] = "<?xml" |
"<?xml" // not case sensitive ! More... | |
static const char | k_xmlEnd [3] = "?>" |
"?>" More... | |
static const char | k_commentHeader [5] = "<!--" |
"<!--" // comments are not reentrant! More... | |
static const char | k_commentEnd [4] = "-->" |
"-->" More... | |
static const char | k_cdataHeader [10] = "<![CDATA[" |
"<![CDATA[" More... | |
static const char | k_cdataEnd [4] = "]]>" |
"]]>" More... | |
static const char | k_dtdHeader [3] = "<!" |
"<!" More... | |
Store a base node of data in the XML tree cXmlDocument. The parent/base class for everything in the cXmlDocument Object Model. (Except for attributes). Nodes have siblings, a parent, and children. A node can be in a document, or stand on its own. The type of a cXmlNode can be queried, and it can be cast to its more defined type. In XML, the document and elements can contain other elements and other types of nodes.
//! A Document can contain: Element (container or leaf) //! Comment (leaf) //! Unknown (leaf) //! Declaration( leaf ) //! //! An Element can contain: Element (container or leaf) //! Text (leaf) //! Attributes (not on tree) //! Comment (leaf) //! Unknown (leaf) //! //! A Declaration contains: Attributes (not on tree) //!
|
protected |
Only instantiate as a derived type.
|
virtual |
|
pure virtual |
Create an exact duplicate of this node and return it. The memory must be deleted by the caller.
Implemented in GrayLib::cXmlDocument, GrayLib::cXmlElement, GrayLib::cXmlUnknown, GrayLib::cXmlDeclaration, GrayLib::cXmlText, and GrayLib::cXmlComment.
|
inline |
cXmlDocument * GrayLib::cXmlNode::get_Document | ( | ) | const |
Return a pointer to the Document this node lives in. Returns nullptr if not in a document.
Walk up the tree to my top level parent document.
cXmlElement * GrayLib::cXmlNode::get_NextSiblingElement | ( | ) | const |
Convenience function to get through elements. Calls NextSibling and ToElement. Will skip all non-Element nodes. Returns nullptr if there is not another element.
|
inline |
Return the position, in the original source file, of this node or attribute. The row and column are 1-based. (That is the first row and first column is 1,1). If the returns values are 0 or less, then the parser does not have a row and column value.
Generally, the row and column value will be set when the cXmlDocument::Load(), cXmlDocument::LoadFile(), or any cXmlNode::ParseNode() is called. It will NOT be set when the DOM was created from operator>>.
The values reflect the initial load. Once the DOM is modified programmatically (by adding or changing nodes and attributes) the new values will NOT update to reflect changes in the document.
There is a minor performance cost to computing the row and column. Computation can be disabled if cXmlDocument::SetTabSize() is called with 0 as the value.
|
inline |
< Query the type (as an enumerated value, above) of this node.
|
inline |
< Get a pointer to arbitrary user data.
|
inline |
< Return the value of this attribute. string.
double GrayLib::cXmlNode::get_ValueDouble | ( | ) | const |
Return the value of this attribute, converted to a double.
int GrayLib::cXmlNode::get_ValueInt | ( | ) | const |
Return the value of this attribute, converted to an integer.
cXmlElement * GrayLib::cXmlNode::GetNextSiblingElement | ( | const char * | pszValue | ) | const |
Convenience function to get through elements. Calls NextSibling and ToElement. Will skip all non-Element nodes. Returns nullptr if there is not another element.
cXmlNode * GrayLib::cXmlNode::GetNextSiblingX | ( | const char * | pszValue | ) | const |
Navigate to a sibling node with the given 'value'.
Get the next element/node with this value.
cXmlNode * GrayLib::cXmlNode::GetPreviousSibling | ( | const char * | pszValue | ) | const |
Navigate to a sibling node.
Get the previous element/node with this value.
|
inline |
|
pure virtual |
OnVisit a hierarchical visit the nodes in the cXml DOM. Every node in the XML tree will be conditionally visited and the host will be called back via the IXmlVisitor interface.
This is essentially a SAX interface for cXml. (Note however it doesn't re-parse the XML for the callbacks, so the performance of cXml is unchanged by using this interface versus any other.)
The interface has been based on ideas from:
Which are both good references for "visiting". An example of using OnVisit():
//! cXmlWriter printer; //! xmlDoc.OnVisit( &printer ); //! const char* xmlcstr = printer.CStr(); //!
Implemented in GrayLib::cXmlElement, GrayLib::cXmlDeclaration, GrayLib::cXmlComment, GrayLib::cXmlDocument, GrayLib::cXmlUnknown, and GrayLib::cXmlText.
|
pure virtual |
All cXml classes can print themselves to a filestream or the string class (cXmlString in non-STL mode, std::string in STL mode.) Either or both pFile and string can be null.
This is a formatted print, and will insert tabs and newlines.
(For an unformatted stream, use the << operator.)
Implemented in GrayLib::cXmlDocument, GrayLib::cXmlElement, GrayLib::cXmlUnknown, GrayLib::cXmlDeclaration, GrayLib::cXmlText, and GrayLib::cXmlComment.
|
static |
Tab in the file to show depth.
|
inline |
< Set a pointer to arbitrary user data.
|
inline |
< Set the value.
void GrayLib::cXmlNode::put_ValueDouble | ( | double | dValue | ) |
Set the value from a double.
like StrT::sprintfN( szBuffer, STRMAX(szBuffer), "%lf", dValue);
void GrayLib::cXmlNode::put_ValueInt | ( | int | iValue | ) |
Set the value from an integer.
HRESULT GrayLib::cXmlNode::QueryValueDouble | ( | double * | pdValue | ) | const |
QueryValueDouble examines the value string. See QueryValueInt().
error as if using scanf("%lf")
HRESULT GrayLib::cXmlNode::QueryValueInt | ( | int * | piValue | ) | const |
QueryValueInt examines the value string. It is an alternative to the IntValue() method with richer error checking. If the value is an integer, it is stored in 'value' and the call returns S_OK. If it is not an integer, it returns HRESULT_WIN32_C(ERROR_DATATYPE_MISMATCH).
A specialized but useful call. Note that for success it returns 0, which is the opposite of almost all other cXml calls.
error as if using scanf("%d")
|
virtual |
Delete all the children of this node. Does not affect 'this'.
Reimplemented in GrayLib::cXmlDocument, GrayLib::cXmlElement, GrayLib::cXmlDeclaration, and GrayLib::cXmlText.
|
protectedvirtual |
Copy to the allocated object. Shared functionality between Clone, Copy constructor, and the assignment operator.
HRESULT GrayLib::cXmlNode::SetParse | ( | const char * | pszData, |
CXML_ENCODING_TYPE | eEncoding = CXML_ENCODING_UNKNOWN |
||
) |
Populate node. Just parse a block of text for this node type. Like JavaScript DOMParser.parseFromString()
|
pure virtual |
|
inlinevirtual |
Is this Node a child container? Can it have children?
Reimplemented in GrayLib::cXmlDocument, and GrayLib::cXmlElement.
|
protected |
cTextPos GrayLib::cXmlNode::m_Pos |
Where (line,col) in the parsed XML document is this node? m_PosNode.
|
protected |
Field containing a generic pointer to arbitrary user data.
|
protected |
parent usage dependent m_eNodeType.