|
wxXml2
|
This class holds XML data/document as parsed by the libxml2 parser. More...
#include <xml2.h>


Public Member Functions | |
| wxXml2Document () | |
| Creates an empty document. | |
| wxXml2Document (wxXml2Node &root) | |
| Constructs a document and sets its root to the given node. | |
| wxXml2Document (const wxString &filename) | |
| Loads the given filename and parse it. | |
| wxXml2Document (xmlDoc *doc) | |
| Wraps the given libxml2 structure. | |
| wxXml2Document (const wxXml2Document &doc) | |
| Copies the given wrapper (does not imply the XML structure copy). | |
| virtual | ~wxXml2Document () |
| Destructor. | |
| bool | operator== (const wxXml2Document &doc) const |
| bool | operator!= (const wxXml2Document &doc) const |
| wxXml2Document & | operator= (const wxXml2Document &doc) |
| bool | Create (const wxString &version=wxS("1.0")) |
| Creates a new empty XML document with the given version. | |
| bool | Load (wxInputStream &stream, wxString *pErr=NULL) |
| Parses the data from the given wxInputStream. See Load(). | |
| bool | Load (const wxString &filename, wxString *pErr=NULL) |
| Parses XML & XHTML file and loads data. | |
| int | Save (wxOutputStream &stream, const wxString &encoding=wxS("UTF-8"), long flags=wxXML2DOC_USE_NATIVE_NEWLINES, int indentstep=4) const |
| Saves the XML data in the given stream with the given encoding. | |
| bool | Save (const wxString &filename, const wxString &encoding=wxS("UTF-8"), long flags=wxXML2DOC_USE_NATIVE_NEWLINES, int indentstep=4) const |
| Saves the document as XML or XHTML file in the given encoding format. | |
| bool | IsNonEmpty () const |
| Returns TRUE if this object is wrapping a non-NULL object. | |
| bool | IsOk () const |
| Returns TRUE if everything is okay in the XML tree structure. | |
| bool | IsUnlinked () const |
| Returns always TRUE since documents are entities which contain links to other structures (wxXml2DTD, wxXml2Node...) but a doc is never linked with structures that are not own by itself. | |
| bool | IsDTDValid (wxString *err=NULL, int bUseInternal=0) const |
| Checks if this document is conform to the DTD which it holds. | |
| wxXml2Node | GetRoot () const |
| Returns the root node of the document. | |
| wxXml2DTD | GetDTD () const |
| Returns the internal DTD associated with this document. | |
| wxString | GetVersion () const |
| Returns version of document (may be empty). | |
| wxString | GetFileEncoding () const |
| Returns encoding of document (may be empty). | |
| xmlDoc * | GetObj () const |
| Returns the libxml2 underlying object. | |
| void | SetRoot (wxXml2Node &node) |
| Changes the root of the document (deleting old one). | |
| void | SetDTD (wxXml2DTD &dtd) |
| Sets the DTD for this document. | |
| void | SetStyleSheet (const wxString &xslfile) |
| Creates a PI node of the type: <?xml-stylesheet type="text/xsl" href="xslfile"?> where "xslfile" is the given URI to an XSL file. | |
| void | SetMathMLDTD () |
| Sets the MathML DTD for this document. | |
| void | SetXHTMLStrictDTD () |
| Sets the XHTML DTD for this document. | |
| void | SetXHTMLTransitionalDTD () |
| void | SetXHTMLFrameSetDTD () |
Public Member Functions inherited from wxXml2Wrapper | |
| wxXml2Wrapper () | |
| Constructs this wrapper but not its wrapped data. | |
| virtual | ~wxXml2Wrapper () |
| The wxXml2Wrapper destructor will free the memory of the underlying libxml2 structure only if it is not linked to any XML tree. | |
| virtual void | DestroyIfUnlinked () |
| Destroys the wrapped data if it is unlinked. | |
Protected Member Functions | |
| void | Destroy () |
| Destroys the data wrapped by this class freeing its memory. | |
| void | SetAsEmpty () |
| Sets this element as empty: that is wrapping a NULL pointer. | |
| void | Copy (const wxXml2Document &doc) |
| int & | GetPrivate () const |
| Copies the given object. | |
Protected Member Functions inherited from wxXml2Wrapper | |
| void | ResetRefCount () |
| void | IncRefCount () |
| void | DecRefCount () |
| int | GetRefCount () const |
| void | UnwrappingOld () |
| This function should be called each time the internal pointer of the class is going to be replaced by another one. | |
| void | JustWrappedNew () |
| This function should be called each time the internal pointer of the class has been replaced by another one. | |
This class holds XML data/document as parsed by the libxml2 parser.
Use Load and Save to perform IO on wxStream or on wxFile objects. Use the GetRoot() function to edit the contents of the XML document through wxXml2Node functions.
|
inline |
Creates an empty document.
Use the Create function before using it.
| wxXml2Document::wxXml2Document | ( | wxXml2Node & | root | ) |
Constructs a document and sets its root to the given node.
|
inline |
Loads the given filename and parse it.
References wxXml2Wrapper::JustWrappedNew(), and WX2XML.
|
inline |
Wraps the given libxml2 structure.
References wxXml2Wrapper::JustWrappedNew().
|
inline |
Copies the given wrapper (does not imply the XML structure copy).
|
inlinevirtual |
Destructor.
References wxXml2Wrapper::DestroyIfUnlinked().
|
inlineprotected |
References wxXml2Wrapper::JustWrappedNew(), and wxXml2Wrapper::UnwrappingOld().
| bool wxXml2Document::Create | ( | const wxString & | version = wxS("1.0") | ) |
Creates a new empty XML document with the given version.
References IsOk(), wxXml2Wrapper::JustWrappedNew(), and WX2XML.
|
inlineprotectedvirtual |
Destroys the data wrapped by this class freeing its memory.
This function should not try to update the reference count since it should have been already updated by the caller.
Implements wxXml2Wrapper.
References wxXml2Wrapper::SetAsEmpty().
| wxXml2DTD wxXml2Document::GetDTD | ( | ) | const |
Returns the internal DTD associated with this document.
If no internal DTDs are associated then wxXml2EmptyDTD is returned.
References wxXml2DTD.
|
inline |
Returns encoding of document (may be empty).
Note: this is the encoding original file was saved in, not the encoding of in-memory representation!
References XML2WX.
|
inline |
Returns the libxml2 underlying object.
Referenced by wxXml2Node::Build(), wxXml2DTD::Create(), wxXml2Node::CreateRoot(), operator==(), and SetDTD().
|
inlineprotectedvirtual |
Copies the given object.
This function should be used to implement copy constructor and assignment operators. Returns the private member of the wrapped structure.
Implements wxXml2Wrapper.
| wxXml2Node wxXml2Document::GetRoot | ( | ) | const |
Returns the root node of the document.
References wxXml2Node.
Referenced by operator==(), and SetStyleSheet().
|
inline |
Returns version of document (may be empty).
References XML2WX.
| bool wxXml2Document::IsDTDValid | ( | wxString * | err = NULL, |
| int | bUseInternal = 0 |
||
| ) | const |
Checks if this document is conform to the DTD which it holds.
| bUseInternal | If this parameter is set to 1, then the internal subset (m_doc->intSubset) will be used. If this parameter is set to 0, then the external subset (m_doc->extSubset) will be used. If this parameter is set to -1, then the subset will be chosen automatically (the first valid one). |
|
inlinevirtual |
Returns TRUE if this object is wrapping a non-NULL object.
Implements wxXml2Wrapper.
|
inline |
|
inlinevirtual |
Returns always TRUE since documents are entities which contain links to other structures (wxXml2DTD, wxXml2Node...) but a doc is never linked with structures that are not own by itself.
Implements wxXml2Wrapper.
| bool wxXml2Document::Load | ( | wxInputStream & | stream, |
| wxString * | pErr = NULL |
||
| ) |
Parses the data from the given wxInputStream. See Load().
References IsOk(), wxXml2Wrapper::JustWrappedNew(), and wxXml2Wrapper::UnwrappingOld().
Referenced by Load().
| bool wxXml2Document::Load | ( | const wxString & | filename, |
| wxString * | pErr = NULL |
||
| ) |
Parses XML & XHTML file and loads data.
Returns TRUE on success. Returns FALSE otherwise & provide an error description if the given pointer is not NULL.
References Load().
|
inline |
|
inline |
| bool wxXml2Document::operator== | ( | const wxXml2Document & | doc | ) | const |
| int wxXml2Document::Save | ( | wxOutputStream & | stream, |
| const wxString & | encoding = wxS("UTF-8"), |
||
| long | flags = wxXML2DOC_USE_NATIVE_NEWLINES, |
||
| int | indentstep = 4 |
||
| ) | const |
Saves the XML data in the given stream with the given encoding.
Returns the number of bytes written: -1 if there were errors.
References wxXml2::RestoreLastIndentMode(), wxXml2::SetIndentMode(), WX2XML, wxXML2DOC_USE_INDENTATION, and wxXML2DOC_USE_NATIVE_NEWLINES.
Referenced by Save().
| bool wxXml2Document::Save | ( | const wxString & | filename, |
| const wxString & | encoding = wxS("UTF-8"), |
||
| long | flags = wxXML2DOC_USE_NATIVE_NEWLINES, |
||
| int | indentstep = 4 |
||
| ) | const |
Saves the document as XML or XHTML file in the given encoding format.
Returns TRUE on success.
References Save().
|
inlineprotectedvirtual |
Sets this element as empty: that is wrapping a NULL pointer.
This function must not free the memory of the currently wrapped pointer: it must just reset that pointer to NULL. This function is used by DestroyIfUnlinked().
Implements wxXml2Wrapper.
| void wxXml2Document::SetDTD | ( | wxXml2DTD & | dtd | ) |
Sets the DTD for this document.
References wxXml2DTD::GetObj(), and GetObj().
Referenced by SetMathMLDTD(), SetXHTMLFrameSetDTD(), SetXHTMLStrictDTD(), and SetXHTMLTransitionalDTD().
| void wxXml2Document::SetMathMLDTD | ( | ) |
Sets the MathML DTD for this document.
References SetDTD().
| void wxXml2Document::SetRoot | ( | wxXml2Node & | node | ) |
Changes the root of the document (deleting old one).
References wxXml2Node::GetObj().
| void wxXml2Document::SetStyleSheet | ( | const wxString & | xslfile | ) |
Creates a PI node of the type: <?xml-stylesheet type="text/xsl" href="xslfile"?> where "xslfile" is the given URI to an XSL file.
References wxXml2Node::AddPIChild(), wxXml2Node::CreateRoot(), GetRoot(), wxXml2Node::SetContent(), wxXml2BaseNode::SetType(), wxXML2_PI_NODE, and wxXml2EmptyNode.
| void wxXml2Document::SetXHTMLFrameSetDTD | ( | ) |
References SetDTD().
| void wxXml2Document::SetXHTMLStrictDTD | ( | ) |
Sets the XHTML DTD for this document.
References SetDTD().
| void wxXml2Document::SetXHTMLTransitionalDTD | ( | ) |
References SetDTD().
1.8.2