X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/95b4a59e67af301bb6ff061055ac5a9a09b96d6c..0c46625036e3dfb9613aae310f72a00590530689:/interface/wx/xml/xml.h?ds=inline diff --git a/interface/wx/xml/xml.h b/interface/wx/xml/xml.h index c66ce74ca5..514fa1a508 100644 --- a/interface/wx/xml/xml.h +++ b/interface/wx/xml/xml.h @@ -3,7 +3,7 @@ // Purpose: interface of wxXmlNode, wxXmlAttribute, wxXmlDocument // Author: wxWidgets team // RCS-ID: $Id$ -// Licence: wxWindows license +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -34,9 +34,11 @@ enum wxXmlNodeType Node has a name and may have content and attributes. Most common node types are @c wxXML_TEXT_NODE (name and attributes are irrelevant) - and @c wxXML_ELEMENT_NODE (e.g. in @c \hi\ there is an element - with name="title", irrelevant content and one child @c wxXML_TEXT_NODE - with content="hi"). + and @c wxXML_ELEMENT_NODE. + + Example: in \hi\ there is an element with the name + @c title and irrelevant content and one child of type @c wxXML_TEXT_NODE + with @c hi as content. If @c wxUSE_UNICODE is 0, all strings are encoded in the encoding given to wxXmlDocument::Load (default is UTF-8). @@ -181,6 +183,13 @@ public: */ int GetDepth(wxXmlNode* grandparent = NULL) const; + /** + Returns a flag indicating whether encoding conversion is necessary when saving. The default is @false. + + You can improve saving efficiency considerably by setting this value. + */ + bool GetNoConversion() const; + /** Returns line number of the node in the input XML file or @c -1 if it is unknown. */ @@ -263,6 +272,8 @@ public: @return @true if @a precedingNode has been found and the @a child node has been inserted. + @param child + The child to insert. @param precedingNode The node to insert @a child after. As a special case, this can be @NULL if this node has no children yet -- in that case, @a child @@ -297,7 +308,7 @@ public: /** Sets as first attribute the given wxXmlAttribute object. - The caller is responsible to delete any previously present attributes + The caller is responsible for deleting any previously present attributes attached to this node. */ void SetAttributes(wxXmlAttribute* attr); @@ -305,7 +316,7 @@ public: /** Sets as first child the given node. - The caller is responsible to delete any previously present children node. + The caller is responsible for deleting any previously present children node. */ void SetChildren(wxXmlNode* child); @@ -322,14 +333,21 @@ public: /** Sets as sibling the given node. - The caller is responsible to delete any previously present sibling node. + The caller is responsible for deleting any previously present sibling node. */ void SetNext(wxXmlNode* next); + /** + Sets a flag to indicate whether encoding conversion is necessary when saving. The default is @false. + + You can improve saving efficiency considerably by setting this value. + */ + void SetNoConversion(bool noconversion); + /** Sets as parent the given node. - The caller is responsible to delete any previously present parent node. + The caller is responsible for deleting any previously present parent node. */ void SetParent(wxXmlNode* parent); @@ -351,8 +369,8 @@ public: Represents a node attribute. - Example: in @c "\", @c "src" is attribute with value - @c "hello.gif" and @c "id" is a attribute with value @c "3". + Example: in \, @c src is an attribute + with value @c hello.gif and @c id is an attribute with value @c 3. @library{wxxml} @category{xml} @@ -424,39 +442,37 @@ public: @code wxXmlDocument doc; - if (!doc.Load(wxT("myfile.xml"))) - return @false; + if (!doc.Load("myfile.xml")) + return false; // start processing the XML file - if (doc.GetRoot()-GetName() != wxT("myroot-node")) - return @false; + if (doc.GetRoot()->GetName() != "myroot-node") + return false; - wxXmlNode *child = doc.GetRoot()-GetChildren(); + wxXmlNode *child = doc.GetRoot()->GetChildren(); while (child) { - if (child-GetName() == wxT("tag1")) { + if (child->GetName() == "tag1") { // process text enclosed by tag1/tag1 - wxString content = child-GetNodeContent(); + wxString content = child->GetNodeContent(); ... // process attributes of tag1 wxString attrvalue1 = - child-GetAttribute(wxT("attr1"), - wxT("default-value")); + child->GetAttribute("attr1", "default-value"); wxString attrvalue2 = - child-GetAttribute(wxT("attr2"), - wxT("default-value")); + child->GetAttribute("attr2", "default-value"); ... - } else if (child-GetName() == wxT("tag2")) { + } else if (child->GetName() == "tag2") { // process tag2 ... } - child = child-GetNext(); + child = child->GetNext(); } @endcode @@ -466,10 +482,10 @@ public: @code wxXmlDocument doc; - doc.Load(wxT("myfile.xml"), wxT("UTF-8"), wxXMLDOC_KEEP_WHITESPACE_NODES); + doc.Load("myfile.xml", "UTF-8", wxXMLDOC_KEEP_WHITESPACE_NODES); // myfile2.xml will be indentic to myfile.xml saving it this way: - doc.Save(wxT("myfile2.xml"), wxXML_NO_INDENTATION); + doc.Save("myfile2.xml", wxXML_NO_INDENTATION); @endcode Using default parameters, you will get a reformatted document which in general @@ -477,8 +493,8 @@ public: @code wxXmlDocument doc; - doc.Load(wxT("myfile.xml")); - doc.Save(wxT("myfile2.xml")); // myfile2.xml != myfile.xml + doc.Load("myfile.xml"); + doc.Save("myfile2.xml"); // myfile2.xml != myfile.xml @endcode @library{wxxml} @@ -503,13 +519,13 @@ public: Loads the given filename using the given encoding. See Load(). */ wxXmlDocument(const wxString& filename, - const wxString& encoding = wxT("UTF-8")); + const wxString& encoding = "UTF-8")); /** Loads the XML document from given stream using the given encoding. See Load(). */ wxXmlDocument(wxInputStream& stream, - const wxString& encoding = wxT("UTF-8")); + const wxString& encoding = "UTF-8"); /** Virtual destructor. Frees the document root node. @@ -577,14 +593,14 @@ public: Returns true on success, false otherwise. */ virtual bool Load(const wxString& filename, - const wxString& encoding = wxT("UTF-8"), int flags = wxXMLDOC_NONE); + const wxString& encoding = "UTF-8", int flags = wxXMLDOC_NONE); /** Like Load(const wxString&, const wxString&, int) but takes the data from given input stream. */ virtual bool Load(wxInputStream& stream, - const wxString& encoding = wxT("UTF-8"), int flags = wxXMLDOC_NONE); + const wxString& encoding = "UTF-8", int flags = wxXMLDOC_NONE); /** Saves XML tree creating a file named with given string. @@ -595,13 +611,13 @@ public: If @a indentstep is @c wxXML_NO_INDENTATION, then, automatic indentation is turned off. */ - virtual bool Save(const wxString& filename, int indentstep = 1) const; + virtual bool Save(const wxString& filename, int indentstep = 2) const; /** Saves XML tree in the given output stream. See Save(const wxString&, int) for a description of @a indentstep. */ - virtual bool Save(wxOutputStream& stream, int indentstep = 1) const; + virtual bool Save(wxOutputStream& stream, int indentstep = 2) const; /** Sets the enconding of the document.