X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/fa6a837300efb9d295b889a8308b74537c9d8677..f24fc8367d4e9290b9fdbfd4b6fadb7b40846e9f:/include/wx/xml/xml.h diff --git a/include/wx/xml/xml.h b/include/wx/xml/xml.h index 1d7aa31dcd..19557b0b14 100644 --- a/include/wx/xml/xml.h +++ b/include/wx/xml/xml.h @@ -28,12 +28,12 @@ #define WXDLLIMPEXP_XML #endif -class WXDLLIMPEXP_XML wxXmlNode; -class WXDLLIMPEXP_XML wxXmlProperty; -class WXDLLIMPEXP_XML wxXmlDocument; -class WXDLLIMPEXP_XML wxXmlIOHandler; -class WXDLLIMPEXP_BASE wxInputStream; -class WXDLLIMPEXP_BASE wxOutputStream; +class WXDLLIMPEXP_FWD_XML wxXmlNode; +class WXDLLIMPEXP_FWD_XML wxXmlProperty; +class WXDLLIMPEXP_FWD_XML wxXmlDocument; +class WXDLLIMPEXP_FWD_XML wxXmlIOHandler; +class WXDLLIMPEXP_FWD_BASE wxInputStream; +class WXDLLIMPEXP_FWD_BASE wxOutputStream; // Represents XML node type. @@ -122,8 +122,11 @@ public: // access methods: wxXmlNodeType GetType() const { return m_type; } - wxString GetName() const { return m_name; } - wxString GetContent() const { return m_content; } + const wxString& GetName() const { return m_name; } + const wxString& GetContent() const { return m_content; } + + bool IsWhitespaceOnly() const; + int GetDepth(wxXmlNode *grandparent = NULL) const; // Gets node content from wxXML_ENTITY_NODE // The problem is, content is represented as @@ -165,8 +168,15 @@ private: +// special indentation value for wxXmlDocument::Save +#define wxXML_NO_INDENTATION (-1) - +// flags for wxXmlDocument::Load +enum wxXmlDocumentLoadFlag +{ + wxXMLDOC_NONE = 0, + wxXMLDOC_KEEP_WHITESPACE_NODES = 1 +}; // This class holds XML data/document as parsed by XML parser. @@ -187,13 +197,13 @@ public: // Parses .xml file and loads data. Returns TRUE on success, FALSE // otherwise. virtual bool Load(const wxString& filename, - const wxString& encoding = wxT("UTF-8")); + const wxString& encoding = wxT("UTF-8"), int flags = wxXMLDOC_NONE); virtual bool Load(wxInputStream& stream, - const wxString& encoding = wxT("UTF-8")); + const wxString& encoding = wxT("UTF-8"), int flags = wxXMLDOC_NONE); // Saves document as .xml file. - virtual bool Save(const wxString& filename) const; - virtual bool Save(wxOutputStream& stream) const; + virtual bool Save(const wxString& filename, int indentstep = 1) const; + virtual bool Save(wxOutputStream& stream, int indentstep = 1) const; bool IsOk() const { return m_root != NULL; } @@ -201,13 +211,14 @@ public: wxXmlNode *GetRoot() const { return m_root; } // Returns version of document (may be empty). - wxString GetVersion() const { return m_version; } + const wxString& GetVersion() const { return m_version; } // Returns encoding of document (may be empty). // Note: this is the encoding original file was saved in, *not* the // encoding of in-memory representation! - wxString GetFileEncoding() const { return m_fileEncoding; } + const wxString& GetFileEncoding() const { return m_fileEncoding; } // Write-access methods: + wxXmlNode *DetachRoot() { wxXmlNode *old=m_root; m_root=NULL; return old; } void SetRoot(wxXmlNode *node) { wxDELETE(m_root); m_root = node; } void SetVersion(const wxString& version) { m_version = version; } void SetFileEncoding(const wxString& encoding) { m_fileEncoding = encoding; }