diff --git a/include/wx/xml/xml.h b/include/wx/xml/xml.h index 8df417203b..02936478c2 100644 --- a/include/wx/xml/xml.h +++ b/include/wx/xml/xml.h @@ -104,7 +104,7 @@ class WXDLLIMPEXP_XML wxXmlNode public: wxXmlNode() : m_attrs(NULL), m_parent(NULL), m_children(NULL), m_next(NULL), - m_lineNo(-1) + m_lineNo(-1), m_noConversion(false) { } @@ -171,6 +171,10 @@ public: void SetAttributes(wxXmlAttribute *attr) { m_attrs = attr; } virtual void AddAttribute(wxXmlAttribute *attr); + // If true, don't do encoding conversion to improve efficiency - node content is ACII text + bool GetNoConversion() const { return m_noConversion; } + void SetNoConversion(bool noconversion) { m_noConversion = noconversion; } + #if WXWIN_COMPATIBILITY_2_8 wxDEPRECATED( inline wxXmlAttribute *GetProperties() const ); wxDEPRECATED( inline bool GetPropVal(const wxString& propName, @@ -210,6 +214,7 @@ private: wxXmlAttribute *m_attrs; wxXmlNode *m_parent, *m_children, *m_next; int m_lineNo; // line number in original file, or -1 + bool m_noConversion; // don't do encoding conversion - node is plain text void DoCopy(const wxXmlNode& node); }; diff --git a/interface/wx/xml/xml.h b/interface/wx/xml/xml.h index 95ee47db5f..514fa1a508 100644 --- a/interface/wx/xml/xml.h +++ b/interface/wx/xml/xml.h @@ -183,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. */ @@ -301,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); @@ -309,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); @@ -326,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); diff --git a/src/xml/xml.cpp b/src/xml/xml.cpp index 5507a4fd77..7e4fdd5a99 100644 --- a/src/xml/xml.cpp +++ b/src/xml/xml.cpp @@ -54,7 +54,8 @@ wxXmlNode::wxXmlNode(wxXmlNode *parent,wxXmlNodeType type, : m_type(type), m_name(name), m_content(content), m_attrs(attrs), m_parent(parent), m_children(NULL), m_next(next), - m_lineNo(lineNo) + m_lineNo(lineNo), + m_noConversion(false) { if (m_parent) { @@ -74,7 +75,7 @@ wxXmlNode::wxXmlNode(wxXmlNodeType type, const wxString& name, : m_type(type), m_name(name), m_content(content), m_attrs(NULL), m_parent(NULL), m_children(NULL), m_next(NULL), - m_lineNo(lineNo) + m_lineNo(lineNo), m_noConversion(false) {} wxXmlNode::wxXmlNode(const wxXmlNode& node) @@ -115,6 +116,7 @@ void wxXmlNode::DoCopy(const wxXmlNode& node) m_name = node.m_name; m_content = node.m_content; m_lineNo = node.m_lineNo; + m_noConversion = node.m_noConversion; m_children = NULL; wxXmlNode *n = node.m_children; @@ -796,7 +798,14 @@ bool OutputString(wxOutputStream& stream, wxUnusedVar(convMem); if ( !convFile ) convFile = &wxConvUTF8; - +#if 1 + // JACS test + const wxWX2MBbuf buf(str.mb_str(*convFile)); + if (!buf.length()) + return false; + + stream.Write((const char*)buf, strlen((const char*)buf)); +#else const wxScopedCharBuffer buf(str.mb_str(*convFile)); if ( !buf.length() ) { @@ -806,6 +815,8 @@ bool OutputString(wxOutputStream& stream, } stream.Write(buf, buf.length()); +#endif + #else // !wxUSE_UNICODE if ( convFile && convMem ) { @@ -913,7 +924,13 @@ bool OutputNode(wxOutputStream& stream, break; case wxXML_TEXT_NODE: - rc = OutputEscapedString(stream, node->GetContent(), + if (node->GetNoConversion()) + { + stream.Write(node->GetContent().c_str(), node->GetContent().Length()); + rc = true; + } + else + rc = OutputEscapedString(stream, node->GetContent(), convMem, convFile, Escape_Text); break;