From 288b6107e1060b57ec50048d06cfc3f22bc11e0c Mon Sep 17 00:00:00 2001 From: =?utf8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Sat, 14 Jul 2007 10:07:41 +0000 Subject: [PATCH] renamed wxXmlProperty to wxXmlAttribute, plus implied method names changes (bug #1751761) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@47450 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/changes.txt | 3 + docs/latex/wx/category.tex | 2 +- docs/latex/wx/classes.tex | 2 +- .../latex/wx/{xmlproperty.tex => xmlattr.tex} | 30 ++--- docs/latex/wx/xmldocument.tex | 14 +-- docs/latex/wx/xmlnode.tex | 62 +++++------ include/wx/xml/xml.h | 105 +++++++++++++----- src/common/debugrpt.cpp | 20 ++-- src/common/xtixml.cpp | 26 ++--- src/richtext/richtextxml.cpp | 78 ++++++------- src/xml/xml.cpp | 94 ++++++++-------- src/xrc/xh_chckl.cpp | 2 +- src/xrc/xh_odcombo.cpp | 4 +- src/xrc/xh_radbx.cpp | 4 +- src/xrc/xmlres.cpp | 61 +++++----- utils/wxrc/wxrc.cpp | 16 +-- 16 files changed, 291 insertions(+), 232 deletions(-) rename docs/latex/wx/{xmlproperty.tex => xmlattr.tex} (58%) diff --git a/docs/changes.txt b/docs/changes.txt index eb941842dc..1e06a74e89 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -92,6 +92,9 @@ Deprecated methods and their replacements - wxDocManager::MakeDefaultName() replaced by MakeNewDocumentName() and wxDocument::GetPrintableName() with GetUserReadableName() which are simpler to use +- wxXmlProperty class was renamed to wxXmlAttribute in order to use standard + terminology. Corresponding wxXmlNode methods were renamed to use + "Attribute" instead of "Property" or "Prop" in their names. Major new features in this release diff --git a/docs/latex/wx/category.tex b/docs/latex/wx/category.tex index 65cbdb312d..edf7a2dc9e 100644 --- a/docs/latex/wx/category.tex +++ b/docs/latex/wx/category.tex @@ -648,7 +648,7 @@ used internally by the HTML classes. \begin{twocollist}\itemsep=0pt \twocolitem{\helpref{wxXmlDocument}{wxxmldocument}}{A class to parse XML files.} \twocolitem{\helpref{wxXmlNode}{wxxmlnode}}{A class which represents XML nodes.} -\twocolitem{\helpref{wxXmlProperty}{wxxmlproperty}}{A class which represents XML properties.} +\twocolitem{\helpref{wxXmlAttribute}{wxxmlattribute}}{A class which represents XML properties.} \end{twocollist} {\large {\bf XML-based resource system classes}} diff --git a/docs/latex/wx/classes.tex b/docs/latex/wx/classes.tex index f1643f06ae..4833c5bc94 100644 --- a/docs/latex/wx/classes.tex +++ b/docs/latex/wx/classes.tex @@ -453,7 +453,7 @@ \input wizpage.tex \input xmldocument.tex \input xmlnode.tex -\input xmlproperty.tex +\input xmlattr.tex \input xmlres.tex \input xmlresh.tex \input zipstrm.tex diff --git a/docs/latex/wx/xmlproperty.tex b/docs/latex/wx/xmlattr.tex similarity index 58% rename from docs/latex/wx/xmlproperty.tex rename to docs/latex/wx/xmlattr.tex index 5df67f03a7..701a1bb468 100644 --- a/docs/latex/wx/xmlproperty.tex +++ b/docs/latex/wx/xmlattr.tex @@ -1,6 +1,6 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% Name: xmlnode.tex -%% Purpose: wxXmlProperty documentation +%% Purpose: wxXmlAttribute documentation %% Author: Francesco Montorsi %% Created: 2006-04-18 %% RCS-ID: $Id$ @@ -8,7 +8,7 @@ %% License: wxWindows license %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\section{\class{wxXmlProperty}}\label{wxxmlproperty} +\section{\class{wxXmlAttribute}}\label{wxxmlattribute} Represents a node property. @@ -30,53 +30,53 @@ No base class \latexignore{\rtfignore{\wxheading{Members}}} -\membersection{wxXmlProperty::wxXmlProperty}\label{wxxmlpropertywxxmlproperty} +\membersection{wxXmlAttribute::wxXmlAttribute}\label{wxxmlattributewxxmlattribute} -\func{}{wxXmlProperty}{\void} +\func{}{wxXmlAttribute}{\void} -\func{}{wxXmlProperty}{\param{const wxString\& }{name}, \param{const wxString\& }{value}, \param{wxXmlProperty* }{next = NULL}} +\func{}{wxXmlAttribute}{\param{const wxString\& }{name}, \param{const wxString\& }{value}, \param{wxXmlAttribute* }{next = NULL}} Creates the property with given {\it name} and {\it value}. If {\it next} is not NULL, then sets it as sibling of this property. -\membersection{wxXmlProperty::\destruct{wxXmlProperty}}\label{wxxmlpropertydtor} +\membersection{wxXmlAttribute::\destruct{wxXmlAttribute}}\label{wxxmlattributedtor} -\func{}{\destruct{wxXmlProperty}}{\void} +\func{}{\destruct{wxXmlAttribute}}{\void} The virtual destructor. -\membersection{wxXmlProperty::GetName}\label{wxxmlpropertygetname} +\membersection{wxXmlAttribute::GetName}\label{wxxmlattributegetname} \constfunc{wxString}{GetName}{\void} Returns the name of this property. -\membersection{wxXmlProperty::GetNext}\label{wxxmlpropertygetnext} +\membersection{wxXmlAttribute::GetNext}\label{wxxmlattributegetnext} -\constfunc{wxXmlProperty*}{GetNext}{\void} +\constfunc{wxXmlAttribute*}{GetNext}{\void} Returns the sibling of this property or NULL if there are no siblings. -\membersection{wxXmlProperty::GetValue}\label{wxxmlpropertygetvalue} +\membersection{wxXmlAttribute::GetValue}\label{wxxmlattributegetvalue} \constfunc{wxString}{GetValue}{\void} Returns the value of this property. -\membersection{wxXmlProperty::SetName}\label{wxxmlpropertysetname} +\membersection{wxXmlAttribute::SetName}\label{wxxmlattributesetname} \func{void}{SetName}{\param{const wxString\& }{name}} Sets the name of this property. -\membersection{wxXmlProperty::SetNext}\label{wxxmlpropertysetnext} +\membersection{wxXmlAttribute::SetNext}\label{wxxmlattributesetnext} -\func{void}{SetNext}{\param{wxXmlProperty* }{next}} +\func{void}{SetNext}{\param{wxXmlAttribute* }{next}} Sets the sibling of this property. -\membersection{wxXmlProperty::SetValue}\label{wxxmlpropertysetvalue} +\membersection{wxXmlAttribute::SetValue}\label{wxxmlattributesetvalue} \func{void}{SetValue}{\param{const wxString\& }{value}} diff --git a/docs/latex/wx/xmldocument.tex b/docs/latex/wx/xmldocument.tex index d73740818b..df0acfdceb 100644 --- a/docs/latex/wx/xmldocument.tex +++ b/docs/latex/wx/xmldocument.tex @@ -36,12 +36,12 @@ while (child) { ... - // process properties of - wxString propvalue1 = - child->GetPropVal(wxT("prop1"), + // process attributes of + wxString attrvalue1 = + child->GetAttribute(wxT("attr1"), wxT("default-value")); - wxString propvalue2 = - child->GetPropVal(wxT("prop2"), + wxString attrvalue2 = + child->GetAttribute(wxT("attr2"), wxT("default-value")); ... @@ -86,7 +86,7 @@ doc.Save(wxT("myfile2.xml")); // myfile2.xml != myfile.xml \wxheading{See also} -\helpref{wxXmlNode}{wxxmlnode}, \helpref{wxXmlProperty}{wxxmlproperty} +\helpref{wxXmlNode}{wxxmlnode}, \helpref{wxXmlAttribute}{wxxmlattribute} \latexignore{\rtfignore{\wxheading{Members}}} @@ -166,7 +166,7 @@ Returns the root node of the document. Returns the version of document. This is the value in the {\tt } header of the XML document. -If the version property was not explicitely given in the header, this function +If the version attribute was not explicitely given in the header, this function returns an empty string. diff --git a/docs/latex/wx/xmlnode.tex b/docs/latex/wx/xmlnode.tex index 53d8e3d29c..331f8000ac 100644 --- a/docs/latex/wx/xmlnode.tex +++ b/docs/latex/wx/xmlnode.tex @@ -12,8 +12,8 @@ Represents a node in an XML document. See \helpref{wxXmlDocument}{wxxmldocument}. -Node has a name and may have content and properties. Most common node types are -{\tt wxXML\_TEXT\_NODE} (name and properties are irrelevant) and +Node has a name and may have content and attributes. Most common node types are +{\tt wxXML\_TEXT\_NODE} (name and attributes are irrelevant) and {\tt wxXML\_ELEMENT\_NODE} (e.g. in {\tt hi} there is an element with name="title", irrelevant content and one child ({\tt wxXML\_TEXT\_NODE} with content="hi"). @@ -57,7 +57,7 @@ enum wxXmlNodeType \wxheading{See also} -\helpref{wxXmlDocument}{wxxmldocument}, \helpref{wxXmlProperty}{wxxmlproperty} +\helpref{wxXmlDocument}{wxxmldocument}, \helpref{wxXmlAttribute}{wxxmlattribute} \latexignore{\rtfignore{\wxheading{Members}}} @@ -65,7 +65,7 @@ enum wxXmlNodeType \membersection{wxXmlNode::wxXmlNode}\label{wxxmlnodewxxmlnode} -\func{}{wxXmlNode}{\param{wxXmlNode* }{parent}, \param{wxXmlNodeType }{type}, \param{const wxString\& }{name}, \param{const wxString\& }{content = wxEmptyString}, \param{wxXmlProperty* }{props = \NULL}, \param{wxXmlNode* }{next = \NULL}} +\func{}{wxXmlNode}{\param{wxXmlNode* }{parent}, \param{wxXmlNodeType }{type}, \param{const wxString\& }{name}, \param{const wxString\& }{content = wxEmptyString}, \param{wxXmlAttribute* }{attrs = \NULL}, \param{wxXmlNode* }{next = \NULL}} \wxheading{Parameters} @@ -78,7 +78,7 @@ constructor and it shouldn't be done again.} \docparam{name}{The name of the node. This is the string which appears between angular brackets.} \docparam{content}{The content of the node. Only meaningful when {\it type} is {\tt wxXML\_TEXT\_NODE} or {\tt wxXML\_CDATA\_SECTION\_NODE}.} -\docparam{props}{If not \NULL, this \helpref{wxXmlProperty}{wxxmlproperty} object +\docparam{attrs}{If not \NULL, this \helpref{wxXmlAttribute}{wxxmlattribute} object and its eventual siblings are attached to the node.} \docparam{next}{If not \NULL, this node and its eventual siblings are attached to the node.} @@ -92,7 +92,7 @@ and parent pointer, i.e. \helpref{GetParent()}{wxxmlnodegetparent} and \helpref{GetNext()}{wxxmlnodegetnext} will return \NULL after using copy ctor and are never unmodified by operator=. -On the other hand, it DOES copy children and properties. +On the other hand, it DOES copy children and attributes. \func{}{wxXmlNode}{\param{wxXmlNodeType }{type}, \param{const wxString\& }{name}, \param{const wxString\& }{content = wxEmptyString}} @@ -104,7 +104,7 @@ A simplified version of the first constructor form, assuming a \NULL parent. \func{}{\destruct{wxXmlNode}}{\void} -The virtual destructor. Deletes attached children and properties. +The virtual destructor. Deletes attached children and attributes. \membersection{wxXmlNode::AddChild}\label{wxxmlnodeaddchild} @@ -113,21 +113,21 @@ The virtual destructor. Deletes attached children and properties. Adds the given node as child of this node. To attach a second children to this node, use the \helpref{SetNext()}{wxxmlnodesetnext} function of the {\it child} node. -\membersection{wxXmlNode::AddProperty}\label{wxxmlnodeaddproperty} +\membersection{wxXmlNode::AddAttribute}\label{wxxmlnodeaddattribute} -\func{void}{AddProperty}{\param{const wxString\& }{name}, \param{const wxString\& }{value}} +\func{void}{AddAttribute}{\param{const wxString\& }{name}, \param{const wxString\& }{value}} -Appends a property with given {\it name} and {\it value} to the list of properties for this node. +Appends a attribute with given {\it name} and {\it value} to the list of attributes for this node. -\func{void}{AddProperty}{\param{wxXmlProperty* }{prop}} +\func{void}{AddAttribute}{\param{wxXmlAttribute* }{attr}} -Appends the given property to the list of properties for this node. +Appends given attribute to the list of attributes for this node. -\membersection{wxXmlNode::DeleteProperty}\label{wxxmlnodedeleteproperty} +\membersection{wxXmlNode::DeleteAttribute}\label{wxxmlnodedeleteattribute} -\func{bool}{DeleteProperty}{\param{const wxString\& }{name}} +\func{bool}{DeleteAttribute}{\param{const wxString\& }{name}} -Removes the first properties which has the given {\it name} from the list of properties for this node. +Removes the first attributes which has the given {\it name} from the list of attributes for this node. \membersection{wxXmlNode::GetChildren}\label{wxxmlnodegetchildren} @@ -198,23 +198,23 @@ Returns a pointer to the sibling of this node or \NULL if there are no siblings. Returns a pointer to the parent of this node or \NULL if this node has no parent. -\membersection{wxXmlNode::GetPropVal}\label{wxxmlnodegetpropval} +\membersection{wxXmlNode::GetAttribute}\label{wxxmlnodegetattribute} -\constfunc{bool}{GetPropVal}{\param{const wxString\& }{propName}, \param{wxString* }{value}} +\constfunc{bool}{GetAttribute}{\param{const wxString\& }{attrName}, \param{wxString* }{value}} -Returns \true if a property named {\it propName} could be found. -If the {\it value} pointer is not \NULL, the value of that property is saved there. +Returns \true if a attribute named {\it attrName} could be found. +If the {\it value} pointer is not \NULL, the value of that attribute is saved there. -\constfunc{wxString}{GetPropVal}{\param{const wxString\& }{propName}, \param{const wxString\& }{defaultVal}} +\constfunc{wxString}{GetAttribute}{\param{const wxString\& }{attrName}, \param{const wxString\& }{defaultVal}} -Returns the value of the property named {\it propName} if it does exist. +Returns the value of the attribute named {\it attrName} if it does exist. If it does not exist, the {\it defaultVal} is returned. -\membersection{wxXmlNode::GetProperties}\label{wxxmlnodegetproperties} +\membersection{wxXmlNode::GetAttributes}\label{wxxmlnodegetattributes} -\constfunc{wxXmlProperty *}{GetProperties}{\void} +\constfunc{wxXmlAttribute *}{GetAttributes}{\void} -Return a pointer to the first property of this node. +Return a pointer to the first attribute of this node. \membersection{wxXmlNode::GetType}\label{wxxmlnodegettype} @@ -223,11 +223,11 @@ Return a pointer to the first property of this node. Returns the type of this node. -\membersection{wxXmlNode::HasProp}\label{wxxmlnodehasprop} +\membersection{wxXmlNode::HasAttribute}\label{wxxmlnodehasattribute} -\constfunc{bool}{HasProp}{\param{const wxString\& }{propName}} +\constfunc{bool}{HasAttribute}{\param{const wxString\& }{attrName}} -Returns \true if this node has a property named {\it propName}. +Returns \true if this node has a attribute named {\it attrName}. \membersection{wxXmlNode::InsertChild}\label{wxxmlnodeinsertchild} @@ -288,12 +288,12 @@ sibling node. Sets as parent the given node. The caller is responsible to delete any previously present parent node. -\membersection{wxXmlNode::SetProperties}\label{wxxmlnodesetproperties} +\membersection{wxXmlNode::SetAttributes}\label{wxxmlnodesetattributes} -\func{void}{SetProperties}{\param{wxXmlProperty* }{prop}} +\func{void}{SetAttributes}{\param{wxXmlAttribute* }{attr}} -Sets as first property the given wxXmlProperty object. -The caller is responsible to delete any previously present properties attached to this node. +Sets as first attribute the given wxXmlAttribute object. +The caller is responsible to delete any previously present attributes attached to this node. \membersection{wxXmlNode::SetType}\label{wxxmlnodesettype} diff --git a/include/wx/xml/xml.h b/include/wx/xml/xml.h index 19557b0b14..030f4d34c1 100644 --- a/include/wx/xml/xml.h +++ b/include/wx/xml/xml.h @@ -29,7 +29,7 @@ #endif class WXDLLIMPEXP_FWD_XML wxXmlNode; -class WXDLLIMPEXP_FWD_XML wxXmlProperty; +class WXDLLIMPEXP_FWD_XML wxXmlAttribute; class WXDLLIMPEXP_FWD_XML wxXmlDocument; class WXDLLIMPEXP_FWD_XML wxXmlIOHandler; class WXDLLIMPEXP_FWD_BASE wxInputStream; @@ -60,33 +60,38 @@ enum wxXmlNodeType // Example: in "src" is property with value // "hello.gif" and "id" is prop. with value "3". -class WXDLLIMPEXP_XML wxXmlProperty +class WXDLLIMPEXP_XML wxXmlAttribute { public: - wxXmlProperty() : m_next(NULL) {} - wxXmlProperty(const wxString& name, const wxString& value, - wxXmlProperty *next = NULL) + wxXmlAttribute() : m_next(NULL) {} + wxXmlAttribute(const wxString& name, const wxString& value, + wxXmlAttribute *next = NULL) : m_name(name), m_value(value), m_next(next) {} - virtual ~wxXmlProperty() {} + virtual ~wxXmlAttribute() {} wxString GetName() const { return m_name; } wxString GetValue() const { return m_value; } - wxXmlProperty *GetNext() const { return m_next; } + wxXmlAttribute *GetNext() const { return m_next; } void SetName(const wxString& name) { m_name = name; } void SetValue(const wxString& value) { m_value = value; } - void SetNext(wxXmlProperty *next) { m_next = next; } + void SetNext(wxXmlAttribute *next) { m_next = next; } private: wxString m_name; wxString m_value; - wxXmlProperty *m_next; + wxXmlAttribute *m_next; }; +#if WXWIN_COMPATIBILITY_2_8 + // NB: #define is used instead of typedef so that forward declarations + // continue to work + #define wxXmlProperty wxXmlAttribute +#endif -// Represents node in XML document. Node has name and may have content -// and properties. Most common node types are wxXML_TEXT_NODE (name and props +// Represents node in XML document. Node has name and may have content and +// attributes. Most common node types are wxXML_TEXT_NODE (name and attributes // are irrelevant) and wxXML_ELEMENT_NODE (e.g. in hi there is // element with name="title", irrelevant content and one child (wxXML_TEXT_NODE // with content="hi"). @@ -97,17 +102,17 @@ private: class WXDLLIMPEXP_XML wxXmlNode { public: - wxXmlNode() : m_properties(NULL), m_parent(NULL), - m_children(NULL), m_next(NULL) {} + wxXmlNode() + : m_attrs(NULL), m_parent(NULL), m_children(NULL), m_next(NULL) {} wxXmlNode(wxXmlNode *parent, wxXmlNodeType type, const wxString& name, const wxString& content = wxEmptyString, - wxXmlProperty *props = NULL, wxXmlNode *next = NULL); + wxXmlAttribute *attrs = NULL, wxXmlNode *next = NULL); virtual ~wxXmlNode(); // copy ctor & operator=. Note that this does NOT copy syblings // and parent pointer, i.e. m_parent and m_next will be NULL // after using copy ctor and are never unmodified by operator=. - // On the other hand, it DOES copy children and properties. + // On the other hand, it DOES copy children and attributes. wxXmlNode(const wxXmlNode& node); wxXmlNode& operator=(const wxXmlNode& node); @@ -117,8 +122,10 @@ public: virtual void AddChild(wxXmlNode *child); virtual bool InsertChild(wxXmlNode *child, wxXmlNode *before_node); virtual bool RemoveChild(wxXmlNode *child); - virtual void AddProperty(const wxString& name, const wxString& value); - virtual bool DeleteProperty(const wxString& name); + virtual void AddAttribute(const wxString& name, const wxString& value) + { AddProperty(name, value); } + virtual bool DeleteAttribute(const wxString& name) + { return DeleteProperty(name); } // access methods: wxXmlNodeType GetType() const { return m_type; } @@ -139,11 +146,11 @@ public: wxXmlNode *GetNext() const { return m_next; } wxXmlNode *GetChildren() const { return m_children; } - wxXmlProperty *GetProperties() const { return m_properties; } - bool GetPropVal(const wxString& propName, wxString *value) const; - wxString GetPropVal(const wxString& propName, - const wxString& defaultVal) const; - bool HasProp(const wxString& propName) const; + wxXmlAttribute *GetAttributes() const { return m_attrs; } + bool GetAttribute(const wxString& attrName, wxString *value) const; + wxString GetAttribute(const wxString& attrName, + const wxString& defaultVal) const; + bool HasAttribute(const wxString& attrName) const; void SetType(wxXmlNodeType type) { m_type = type; } void SetName(const wxString& name) { m_name = name; } @@ -153,19 +160,67 @@ public: void SetNext(wxXmlNode *next) { m_next = next; } void SetChildren(wxXmlNode *child) { m_children = child; } - void SetProperties(wxXmlProperty *prop) { m_properties = prop; } - virtual void AddProperty(wxXmlProperty *prop); + void SetAttributes(wxXmlAttribute *attr) { m_attrs = attr; } + virtual void AddAttribute(wxXmlAttribute *attr) + { AddProperty(attr); } + +#if WXWIN_COMPATIBILITY_2_8 + wxDEPRECATED( inline wxXmlAttribute *GetProperties() const ); + wxDEPRECATED( inline bool GetPropVal(const wxString& propName, + wxString *value) const ); + wxDEPRECATED( inline wxString GetPropVal(const wxString& propName, + const wxString& defaultVal) const ); + wxDEPRECATED( inline bool HasProp(const wxString& propName) const ); + + wxDEPRECATED( inline void SetProperties(wxXmlAttribute *prop) ); +#endif // WXWIN_COMPATIBILITY_2_8 + + // The following three functions are backward compatibility, but because + // they were virtual, we must make it possible to override them. This + // is done by calling e.g. AddProperty() from AddAttribute(), so we have + // to keep AddProperty() even if 2.8 compatibility is off. To prevent + // old code from compiling in that case, we make them private and + // non-virtual. (This can be removed when WXWIN_COMPATIBILITY_2_8 is + // removed, we'll have just *Attribute versions then.) +#if WXWIN_COMPATIBILITY_2_8 + wxDEPRECATED_BUT_USED_INTERNALLY( + virtual void AddProperty(const wxString& name, const wxString& value) ); + wxDEPRECATED_BUT_USED_INTERNALLY( + virtual bool DeleteProperty(const wxString& name) ); + wxDEPRECATED_BUT_USED_INTERNALLY( + virtual void AddProperty(wxXmlAttribute *attr) ); +#else +private: + void AddProperty(const wxString& name, const wxString& value); + bool DeleteProperty(const wxString& name); + void AddProperty(wxXmlAttribute *attr); +#endif // WXWIN_COMPATIBILITY_2_8/!WXWIN_COMPATIBILITY_2_8 private: wxXmlNodeType m_type; wxString m_name; wxString m_content; - wxXmlProperty *m_properties; + wxXmlAttribute *m_attrs; wxXmlNode *m_parent, *m_children, *m_next; void DoCopy(const wxXmlNode& node); }; +#if WXWIN_COMPATIBILITY_2_8 +inline wxXmlAttribute *wxXmlNode::GetProperties() const + { return GetAttributes(); } +inline bool wxXmlNode::GetPropVal(const wxString& propName, + wxString *value) const + { return GetAttribute(propName, value); } +inline wxString wxXmlNode::GetPropVal(const wxString& propName, + const wxString& defaultVal) const + { return GetAttribute(propName, defaultVal); } +inline bool wxXmlNode::HasProp(const wxString& propName) const + { return HasAttribute(propName); } +inline void wxXmlNode::SetProperties(wxXmlAttribute *prop) + { SetAttributes(prop); } +#endif // WXWIN_COMPATIBILITY_2_8 + // special indentation value for wxXmlDocument::Save diff --git a/src/common/debugrpt.cpp b/src/common/debugrpt.cpp index 9eeab34255..542715a0f0 100644 --- a/src/common/debugrpt.cpp +++ b/src/common/debugrpt.cpp @@ -87,13 +87,13 @@ protected: static inline void HexProperty(wxXmlNode *node, const wxChar *name, unsigned long value) { - node->AddProperty(name, wxString::Format(_T("%08lx"), value)); + node->AddAttribute(name, wxString::Format(_T("%08lx"), value)); } static inline void NumProperty(wxXmlNode *node, const wxChar *name, unsigned long value) { - node->AddProperty(name, wxString::Format(_T("%lu"), value)); + node->AddAttribute(name, wxString::Format(_T("%lu"), value)); } static inline void @@ -129,13 +129,13 @@ void XmlStackWalker::OnStackFrame(const wxStackFrame& frame) wxString func = frame.GetName(); if ( !func.empty() ) { - nodeFrame->AddProperty(_T("function"), func); + nodeFrame->AddAttribute(_T("function"), func); HexProperty(nodeFrame, _T("offset"), frame.GetOffset()); } if ( frame.HasSourceLocation() ) { - nodeFrame->AddProperty(_T("file"), frame.GetFileName()); + nodeFrame->AddAttribute(_T("file"), frame.GetFileName()); NumProperty(nodeFrame, _T("line"), frame.GetLine()); } @@ -348,7 +348,7 @@ void wxDebugReport::AddAll(Context context) bool wxDebugReport::DoAddSystemInfo(wxXmlNode *nodeSystemInfo) { - nodeSystemInfo->AddProperty(_T("description"), wxGetOsDescription()); + nodeSystemInfo->AddAttribute(_T("description"), wxGetOsDescription()); return true; } @@ -371,7 +371,7 @@ bool wxDebugReport::DoAddLoadedModules(wxXmlNode *nodeModules) if ( path.empty() ) path = info.GetName(); if ( !path.empty() ) - nodeModule->AddProperty(_T("path"), path); + nodeModule->AddAttribute(_T("path"), path); void *addr = NULL; size_t len = 0; @@ -384,7 +384,7 @@ bool wxDebugReport::DoAddLoadedModules(wxXmlNode *nodeModules) wxString ver = info.GetVersion(); if ( !ver.empty() ) { - nodeModule->AddProperty(_T("version"), ver); + nodeModule->AddAttribute(_T("version"), ver); } } @@ -402,7 +402,7 @@ bool wxDebugReport::DoAddExceptionInfo(wxXmlNode *nodeContext) nodeContext->AddChild(nodeExc); HexProperty(nodeExc, _T("code"), c.code); - nodeExc->AddProperty(_T("name"), c.GetExceptionString()); + nodeExc->AddAttribute(_T("name"), c.GetExceptionString()); HexProperty(nodeExc, _T("address"), wxPtrToUInt(c.addr)); #ifdef __INTEL__ @@ -445,8 +445,8 @@ bool wxDebugReport::AddContext(wxDebugReport::Context ctx) wxXmlDocument xmldoc; wxXmlNode *nodeRoot = new wxXmlNode(wxXML_ELEMENT_NODE, _T("report")); xmldoc.SetRoot(nodeRoot); - nodeRoot->AddProperty(_T("version"), _T("1.0")); - nodeRoot->AddProperty(_T("kind"), ctx == Context_Current ? _T("user") + nodeRoot->AddAttribute(_T("version"), _T("1.0")); + nodeRoot->AddAttribute(_T("kind"), ctx == Context_Current ? _T("user") : _T("exception")); // add system information diff --git a/src/common/xtixml.cpp b/src/common/xtixml.cpp index ed5039461b..dae1f64eba 100644 --- a/src/common/xtixml.cpp +++ b/src/common/xtixml.cpp @@ -94,7 +94,7 @@ void wxXmlWriter::DoBeginWriteTopLevelEntry( const wxString &name ) { wxXmlNode *pnode; pnode = new wxXmlNode(wxXML_ELEMENT_NODE, wxT("entry")); - pnode->AddProperty(wxString(wxT("name")), name); + pnode->AddAttribute(wxString(wxT("name")), name); m_data->m_current->AddChild(pnode) ; m_data->Push( pnode ) ; } @@ -108,12 +108,12 @@ void wxXmlWriter::DoBeginWriteObject(const wxObject *WXUNUSED(object), const wxC { wxXmlNode *pnode; pnode = new wxXmlNode(wxXML_ELEMENT_NODE, wxT("object")); - pnode->AddProperty(wxT("class"), wxString(classInfo->GetClassName())); - pnode->AddProperty(wxT("id"), wxString::Format( wxT("%d") , objectID ) ); + pnode->AddAttribute(wxT("class"), wxString(classInfo->GetClassName())); + pnode->AddAttribute(wxT("id"), wxString::Format( wxT("%d") , objectID ) ); for ( size_t i = 0 ; i < metadata.GetCount() ; ++i ) { - pnode->AddProperty( metadata[i].GetName() , metadata[i].GetAsString() ) ; + pnode->AddAttribute( metadata[i].GetName() , metadata[i].GetAsString() ) ; } m_data->m_current->AddChild(pnode) ; m_data->Push( pnode ) ; @@ -148,7 +148,7 @@ void wxXmlWriter::DoBeginWriteProperty(const wxPropertyInfo *pi ) { wxXmlNode *pnode; pnode = new wxXmlNode(wxXML_ELEMENT_NODE, wxT("prop") ); - pnode->AddProperty(wxT("name"), pi->GetName() ); + pnode->AddAttribute(wxT("name"), pi->GetName() ); m_data->m_current->AddChild(pnode) ; m_data->Push( pnode ) ; } @@ -165,7 +165,7 @@ void wxXmlWriter::DoWriteRepeatedObject( int objectID ) { wxXmlNode *pnode; pnode = new wxXmlNode(wxXML_ELEMENT_NODE, wxT("object")); - pnode->AddProperty(wxString(wxT("href")), wxString::Format( wxT("%d") , objectID ) ); + pnode->AddAttribute(wxString(wxT("href")), wxString::Format( wxT("%d") , objectID ) ); m_data->m_current->AddChild(pnode) ; } @@ -220,7 +220,7 @@ int wxXmlReader::ReadComponent(wxXmlNode *node, wxDepersister *callbacks) if (!children) { // check for a null object or href - if (node->GetPropVal(wxT("href") , &ObjectIdString ) ) + if (node->GetAttribute(wxT("href") , &ObjectIdString ) ) { objectID = atoi( ObjectIdString.ToAscii() ) ; if ( HasObjectClassInfo( objectID ) ) @@ -233,12 +233,12 @@ int wxXmlReader::ReadComponent(wxXmlNode *node, wxDepersister *callbacks) return wxInvalidObjectID ; } } - if ( !node->GetPropVal(wxT("id") , &ObjectIdString ) ) + if ( !node->GetAttribute(wxT("id") , &ObjectIdString ) ) { return wxNullObjectID; } } - if (!node->GetPropVal(wxT("class"), &className)) + if (!node->GetAttribute(wxT("class"), &className)) { // No class name. Eek. FIXME: error handling return wxInvalidObjectID; @@ -255,7 +255,7 @@ int wxXmlReader::ReadComponent(wxXmlNode *node, wxDepersister *callbacks) wxLogError(_("objects cannot have XML Text Nodes") ) ; return wxInvalidObjectID; } - if (!node->GetPropVal(wxT("id"), &ObjectIdString)) + if (!node->GetAttribute(wxT("id"), &ObjectIdString)) { wxLogError(_("Objects must have an id attribute") ) ; // No object id. Eek. FIXME: error handling @@ -274,7 +274,7 @@ int wxXmlReader::ReadComponent(wxXmlNode *node, wxDepersister *callbacks) SetObjectClassInfo( objectID , classInfo ) ; wxxVariantArray metadata ; - wxXmlProperty *xp = node->GetProperties() ; + wxXmlAttribute *xp = node->GetAttributes() ; while ( xp ) { if ( xp->GetName() != wxString(wxT("class")) && xp->GetName() != wxString(wxT("id")) ) @@ -305,7 +305,7 @@ int wxXmlReader::ReadComponent(wxXmlNode *node, wxDepersister *callbacks) while( children ) { wxString name ; - children->GetPropVal( wxT("name") , &name ) ; + children->GetAttribute( wxT("name") , &name ) ; propertyNames.push_back( (const wxChar*)name.c_str() ) ; propertyNodes[(const wxChar*)name.c_str()] = children->GetChildren() ; children = children->GetNext() ; @@ -525,7 +525,7 @@ int wxXmlReader::ReadObject( const wxString &name , wxDepersister *callbacks) while ( iter ) { wxString entryName ; - if ( iter->GetPropVal(wxT("name"), &entryName) ) + if ( iter->GetAttribute(wxT("name"), &entryName) ) { if ( entryName == name ) return ReadComponent( iter->GetChildren() , callbacks ) ; diff --git a/src/richtext/richtextxml.cpp b/src/richtext/richtextxml.cpp index 620f6fd6df..c5759c78cc 100644 --- a/src/richtext/richtextxml.cpp +++ b/src/richtext/richtextxml.cpp @@ -101,7 +101,7 @@ bool wxRichTextXMLHandler::ImportXML(wxRichTextBuffer* buffer, wxXmlNode* node) if (name == wxT("paragraphlayout")) { - wxString partial = node->GetPropVal(wxT("partialparagraph"), wxEmptyString); + wxString partial = node->GetAttribute(wxT("partialparagraph"), wxEmptyString); if (partial == wxT("true")) buffer->SetPartialParagraph(true); } @@ -173,7 +173,7 @@ bool wxRichTextXMLHandler::ImportXML(wxRichTextBuffer* buffer, wxXmlNode* node) else if (childName == wxT("image")) { int imageType = wxBITMAP_TYPE_PNG; - wxString value = node->GetPropVal(wxT("imagetype"), wxEmptyString); + wxString value = node->GetAttribute(wxT("imagetype"), wxEmptyString); if (!value.empty()) imageType = wxAtoi(value); @@ -217,8 +217,8 @@ bool wxRichTextXMLHandler::ImportXML(wxRichTextBuffer* buffer, wxXmlNode* node) if (GetFlags() & wxRICHTEXT_HANDLER_INCLUDE_STYLESHEET) { wxRichTextStyleSheet* sheet = new wxRichTextStyleSheet; - wxString sheetName = node->GetPropVal(wxT("name"), wxEmptyString); - wxString sheetDescription = node->GetPropVal(wxT("description"), wxEmptyString); + wxString sheetName = node->GetAttribute(wxT("name"), wxEmptyString); + wxString sheetDescription = node->GetAttribute(wxT("description"), wxEmptyString); sheet->SetName(sheetName); sheet->SetDescription(sheetDescription); @@ -254,8 +254,8 @@ bool wxRichTextXMLHandler::ImportXML(wxRichTextBuffer* buffer, wxXmlNode* node) bool wxRichTextXMLHandler::ImportStyleDefinition(wxRichTextStyleSheet* sheet, wxXmlNode* node) { wxString styleType = node->GetName(); - wxString styleName = node->GetPropVal(wxT("name"), wxEmptyString); - wxString baseStyleName = node->GetPropVal(wxT("basestyle"), wxEmptyString); + wxString styleName = node->GetAttribute(wxT("name"), wxEmptyString); + wxString baseStyleName = node->GetAttribute(wxT("basestyle"), wxEmptyString); if (styleName.IsEmpty()) return false; @@ -283,7 +283,7 @@ bool wxRichTextXMLHandler::ImportStyleDefinition(wxRichTextStyleSheet* sheet, wx { wxRichTextParagraphStyleDefinition* def = new wxRichTextParagraphStyleDefinition(styleName); - wxString nextStyleName = node->GetPropVal(wxT("nextstyle"), wxEmptyString); + wxString nextStyleName = node->GetAttribute(wxT("nextstyle"), wxEmptyString); def->SetNextStyle(nextStyleName); def->SetBaseStyle(baseStyleName); @@ -305,7 +305,7 @@ bool wxRichTextXMLHandler::ImportStyleDefinition(wxRichTextStyleSheet* sheet, wx { wxRichTextListStyleDefinition* def = new wxRichTextListStyleDefinition(styleName); - wxString nextStyleName = node->GetPropVal(wxT("nextstyle"), wxEmptyString); + wxString nextStyleName = node->GetAttribute(wxT("nextstyle"), wxEmptyString); def->SetNextStyle(nextStyleName); def->SetBaseStyle(baseStyleName); @@ -317,7 +317,7 @@ bool wxRichTextXMLHandler::ImportStyleDefinition(wxRichTextStyleSheet* sheet, wx wxTextAttrEx attr; GetStyle(attr, child, false); - wxString styleLevel = child->GetPropVal(wxT("level"), wxEmptyString); + wxString styleLevel = child->GetAttribute(wxT("level"), wxEmptyString); if (styleLevel.IsEmpty()) { def->SetStyle(attr); @@ -1020,37 +1020,37 @@ bool wxRichTextXMLHandler::GetStyle(wxTextAttrEx& attr, wxXmlNode* node, bool is int fontFlags = 0; - fontFacename = node->GetPropVal(wxT("fontface"), wxEmptyString); + fontFacename = node->GetAttribute(wxT("fontface"), wxEmptyString); if (!fontFacename.IsEmpty()) fontFlags |= wxTEXT_ATTR_FONT_FACE; wxString value; - //value = node->GetPropVal(wxT("fontfamily"), wxEmptyString); + //value = node->GetAttribute(wxT("fontfamily"), wxEmptyString); //if (!value.empty()) // fontFamily = wxAtoi(value); - value = node->GetPropVal(wxT("fontstyle"), wxEmptyString); + value = node->GetAttribute(wxT("fontstyle"), wxEmptyString); if (!value.empty()) { fontStyle = wxAtoi(value); fontFlags |= wxTEXT_ATTR_FONT_ITALIC; } - value = node->GetPropVal(wxT("fontsize"), wxEmptyString); + value = node->GetAttribute(wxT("fontsize"), wxEmptyString); if (!value.empty()) { fontSize = wxAtoi(value); fontFlags |= wxTEXT_ATTR_FONT_SIZE; } - value = node->GetPropVal(wxT("fontweight"), wxEmptyString); + value = node->GetAttribute(wxT("fontweight"), wxEmptyString); if (!value.empty()) { fontWeight = wxAtoi(value); fontFlags |= wxTEXT_ATTR_FONT_WEIGHT; } - value = node->GetPropVal(wxT("fontunderlined"), wxEmptyString); + value = node->GetAttribute(wxT("fontunderlined"), wxEmptyString); if (!value.empty()) { fontUnderlined = wxAtoi(value) != 0; @@ -1065,7 +1065,7 @@ bool wxRichTextXMLHandler::GetStyle(wxTextAttrEx& attr, wxXmlNode* node, bool is // Restore correct font flags attr.SetFlags(fontFlags); - value = node->GetPropVal(wxT("textcolor"), wxEmptyString); + value = node->GetAttribute(wxT("textcolor"), wxEmptyString); if (!value.empty()) { if (value[0] == wxT('#')) @@ -1074,7 +1074,7 @@ bool wxRichTextXMLHandler::GetStyle(wxTextAttrEx& attr, wxXmlNode* node, bool is attr.SetTextColour(value); } - value = node->GetPropVal(wxT("backgroundcolor"), wxEmptyString); + value = node->GetAttribute(wxT("backgroundcolor"), wxEmptyString); if (!value.empty()) { if (value[0] == wxT('#')) @@ -1083,17 +1083,17 @@ bool wxRichTextXMLHandler::GetStyle(wxTextAttrEx& attr, wxXmlNode* node, bool is attr.SetBackgroundColour(value); } - value = node->GetPropVal(wxT("characterstyle"), wxEmptyString); + value = node->GetAttribute(wxT("characterstyle"), wxEmptyString); if (!value.empty()) attr.SetCharacterStyleName(value); - value = node->GetPropVal(wxT("texteffects"), wxEmptyString); + value = node->GetAttribute(wxT("texteffects"), wxEmptyString); if (!value.IsEmpty()) { attr.SetTextEffects(wxAtoi(value)); } - value = node->GetPropVal(wxT("texteffectflags"), wxEmptyString); + value = node->GetAttribute(wxT("texteffectflags"), wxEmptyString); if (!value.IsEmpty()) { attr.SetTextEffectFlags(wxAtoi(value)); @@ -1102,7 +1102,7 @@ bool wxRichTextXMLHandler::GetStyle(wxTextAttrEx& attr, wxXmlNode* node, bool is // Set paragraph attributes if (isPara) { - value = node->GetPropVal(wxT("alignment"), wxEmptyString); + value = node->GetAttribute(wxT("alignment"), wxEmptyString); if (!value.empty()) attr.SetAlignment((wxTextAttrAlignment) wxAtoi(value)); @@ -1110,14 +1110,14 @@ bool wxRichTextXMLHandler::GetStyle(wxTextAttrEx& attr, wxXmlNode* node, bool is int leftIndent = 0; bool hasLeftIndent = false; - value = node->GetPropVal(wxT("leftindent"), wxEmptyString); + value = node->GetAttribute(wxT("leftindent"), wxEmptyString); if (!value.empty()) { leftIndent = wxAtoi(value); hasLeftIndent = true; } - value = node->GetPropVal(wxT("leftsubindent"), wxEmptyString); + value = node->GetAttribute(wxT("leftsubindent"), wxEmptyString); if (!value.empty()) { leftSubIndent = wxAtoi(value); @@ -1127,31 +1127,31 @@ bool wxRichTextXMLHandler::GetStyle(wxTextAttrEx& attr, wxXmlNode* node, bool is if (hasLeftIndent) attr.SetLeftIndent(leftIndent, leftSubIndent); - value = node->GetPropVal(wxT("rightindent"), wxEmptyString); + value = node->GetAttribute(wxT("rightindent"), wxEmptyString); if (!value.empty()) attr.SetRightIndent(wxAtoi(value)); - value = node->GetPropVal(wxT("parspacingbefore"), wxEmptyString); + value = node->GetAttribute(wxT("parspacingbefore"), wxEmptyString); if (!value.empty()) attr.SetParagraphSpacingBefore(wxAtoi(value)); - value = node->GetPropVal(wxT("parspacingafter"), wxEmptyString); + value = node->GetAttribute(wxT("parspacingafter"), wxEmptyString); if (!value.empty()) attr.SetParagraphSpacingAfter(wxAtoi(value)); - value = node->GetPropVal(wxT("linespacing"), wxEmptyString); + value = node->GetAttribute(wxT("linespacing"), wxEmptyString); if (!value.empty()) attr.SetLineSpacing(wxAtoi(value)); - value = node->GetPropVal(wxT("bulletstyle"), wxEmptyString); + value = node->GetAttribute(wxT("bulletstyle"), wxEmptyString); if (!value.empty()) attr.SetBulletStyle(wxAtoi(value)); - value = node->GetPropVal(wxT("bulletnumber"), wxEmptyString); + value = node->GetAttribute(wxT("bulletnumber"), wxEmptyString); if (!value.empty()) attr.SetBulletNumber(wxAtoi(value)); - value = node->GetPropVal(wxT("bulletsymbol"), wxEmptyString); + value = node->GetAttribute(wxT("bulletsymbol"), wxEmptyString); if (!value.empty()) { wxChar ch = wxAtoi(value); @@ -1160,31 +1160,31 @@ bool wxRichTextXMLHandler::GetStyle(wxTextAttrEx& attr, wxXmlNode* node, bool is attr.SetBulletText(s); } - value = node->GetPropVal(wxT("bullettext"), wxEmptyString); + value = node->GetAttribute(wxT("bullettext"), wxEmptyString); if (!value.empty()) attr.SetBulletText(value); - value = node->GetPropVal(wxT("bulletfont"), wxEmptyString); + value = node->GetAttribute(wxT("bulletfont"), wxEmptyString); if (!value.empty()) attr.SetBulletFont(value); - value = node->GetPropVal(wxT("bulletname"), wxEmptyString); + value = node->GetAttribute(wxT("bulletname"), wxEmptyString); if (!value.empty()) attr.SetBulletName(value); - value = node->GetPropVal(wxT("url"), wxEmptyString); + value = node->GetAttribute(wxT("url"), wxEmptyString); if (!value.empty()) attr.SetURL(value); - value = node->GetPropVal(wxT("parstyle"), wxEmptyString); + value = node->GetAttribute(wxT("parstyle"), wxEmptyString); if (!value.empty()) attr.SetParagraphStyleName(value); - value = node->GetPropVal(wxT("liststyle"), wxEmptyString); + value = node->GetAttribute(wxT("liststyle"), wxEmptyString); if (!value.empty()) attr.SetListStyleName(value); - value = node->GetPropVal(wxT("tabs"), wxEmptyString); + value = node->GetAttribute(wxT("tabs"), wxEmptyString); if (!value.empty()) { wxArrayInt tabs; @@ -1197,13 +1197,13 @@ bool wxRichTextXMLHandler::GetStyle(wxTextAttrEx& attr, wxXmlNode* node, bool is attr.SetTabs(tabs); } - value = node->GetPropVal(wxT("pagebreak"), wxEmptyString); + value = node->GetAttribute(wxT("pagebreak"), wxEmptyString); if (!value.IsEmpty()) { attr.SetPageBreak(wxAtoi(value) != 0); } - value = node->GetPropVal(wxT("outlinelevel"), wxEmptyString); + value = node->GetAttribute(wxT("outlinelevel"), wxEmptyString); if (!value.IsEmpty()) { attr.SetOutlineLevel(wxAtoi(value) != 0); diff --git a/src/xml/xml.cpp b/src/xml/xml.cpp index 16ced8c8f6..a35d73b267 100644 --- a/src/xml/xml.cpp +++ b/src/xml/xml.cpp @@ -49,9 +49,9 @@ static bool wxIsWhiteOnly(const wxString& buf); wxXmlNode::wxXmlNode(wxXmlNode *parent,wxXmlNodeType type, const wxString& name, const wxString& content, - wxXmlProperty *props, wxXmlNode *next) + wxXmlAttribute *attrs, wxXmlNode *next) : m_type(type), m_name(name), m_content(content), - m_properties(props), m_parent(parent), + m_attrs(attrs), m_parent(parent), m_children(NULL), m_next(next) { if (m_parent) @@ -69,7 +69,7 @@ wxXmlNode::wxXmlNode(wxXmlNode *parent,wxXmlNodeType type, wxXmlNode::wxXmlNode(wxXmlNodeType type, const wxString& name, const wxString& content) : m_type(type), m_name(name), m_content(content), - m_properties(NULL), m_parent(NULL), + m_attrs(NULL), m_parent(NULL), m_children(NULL), m_next(NULL) {} @@ -89,8 +89,8 @@ wxXmlNode::~wxXmlNode() delete c; } - wxXmlProperty *p, *p2; - for (p = m_properties; p; p = p2) + wxXmlAttribute *p, *p2; + for (p = m_attrs; p; p = p2) { p2 = p->GetNext(); delete p; @@ -99,7 +99,7 @@ wxXmlNode::~wxXmlNode() wxXmlNode& wxXmlNode::operator=(const wxXmlNode& node) { - wxDELETE(m_properties); + wxDELETE(m_attrs); wxDELETE(m_children); DoCopy(node); return *this; @@ -119,49 +119,49 @@ void wxXmlNode::DoCopy(const wxXmlNode& node) n = n->GetNext(); } - m_properties = NULL; - wxXmlProperty *p = node.m_properties; + m_attrs = NULL; + wxXmlAttribute *p = node.m_attrs; while (p) { - AddProperty(p->GetName(), p->GetValue()); + AddAttribute(p->GetName(), p->GetValue()); p = p->GetNext(); } } -bool wxXmlNode::HasProp(const wxString& propName) const +bool wxXmlNode::HasAttribute(const wxString& attrName) const { - wxXmlProperty *prop = GetProperties(); + wxXmlAttribute *attr = GetAttributes(); - while (prop) + while (attr) { - if (prop->GetName() == propName) return true; - prop = prop->GetNext(); + if (attr->GetName() == attrName) return true; + attr = attr->GetNext(); } return false; } -bool wxXmlNode::GetPropVal(const wxString& propName, wxString *value) const +bool wxXmlNode::GetAttribute(const wxString& attrName, wxString *value) const { - wxXmlProperty *prop = GetProperties(); + wxXmlAttribute *attr = GetAttributes(); - while (prop) + while (attr) { - if (prop->GetName() == propName) + if (attr->GetName() == attrName) { - *value = prop->GetValue(); + *value = attr->GetValue(); return true; } - prop = prop->GetNext(); + attr = attr->GetNext(); } return false; } -wxString wxXmlNode::GetPropVal(const wxString& propName, const wxString& defaultVal) const +wxString wxXmlNode::GetAttribute(const wxString& attrName, const wxString& defaultVal) const { wxString tmp; - if (GetPropVal(propName, &tmp)) + if (GetAttribute(attrName, &tmp)) return tmp; return defaultVal; @@ -248,48 +248,48 @@ bool wxXmlNode::RemoveChild(wxXmlNode *child) void wxXmlNode::AddProperty(const wxString& name, const wxString& value) { - AddProperty(new wxXmlProperty(name, value, NULL)); + AddProperty(new wxXmlAttribute(name, value, NULL)); } -void wxXmlNode::AddProperty(wxXmlProperty *prop) +void wxXmlNode::AddProperty(wxXmlAttribute *attr) { - if (m_properties == NULL) - m_properties = prop; + if (m_attrs == NULL) + m_attrs = attr; else { - wxXmlProperty *p = m_properties; + wxXmlAttribute *p = m_attrs; while (p->GetNext()) p = p->GetNext(); - p->SetNext(prop); + p->SetNext(attr); } } bool wxXmlNode::DeleteProperty(const wxString& name) { - wxXmlProperty *prop; + wxXmlAttribute *attr; - if (m_properties == NULL) + if (m_attrs == NULL) return false; - else if (m_properties->GetName() == name) + else if (m_attrs->GetName() == name) { - prop = m_properties; - m_properties = prop->GetNext(); - prop->SetNext(NULL); - delete prop; + attr = m_attrs; + m_attrs = attr->GetNext(); + attr->SetNext(NULL); + delete attr; return true; } else { - wxXmlProperty *p = m_properties; + wxXmlAttribute *p = m_attrs; while (p->GetNext()) { if (p->GetNext()->GetName() == name) { - prop = p->GetNext(); - p->SetNext(prop->GetNext()); - prop->SetNext(NULL); - delete prop; + attr = p->GetNext(); + p->SetNext(attr->GetNext()); + attr->SetNext(NULL); + delete attr; return true; } p = p->GetNext(); @@ -469,7 +469,7 @@ static void StartElementHnd(void *userData, const char *name, const char **atts) const char **a = atts; while (*a) { - node->AddProperty(CharToString(ctx->conv, a[0]), CharToString(ctx->conv, a[1])); + node->AddAttribute(CharToString(ctx->conv, a[0]), CharToString(ctx->conv, a[1])); a += 2; } if (ctx->root == NULL) @@ -750,7 +750,7 @@ static void OutputNode(wxOutputStream& stream, wxXmlNode *node, int indent, wxMBConv *convMem, wxMBConv *convFile, int indentstep) { wxXmlNode *n, *prev; - wxXmlProperty *prop; + wxXmlAttribute *attr; switch (node->GetType()) { @@ -768,14 +768,14 @@ static void OutputNode(wxOutputStream& stream, wxXmlNode *node, int indent, OutputString(stream, wxT("<")); OutputString(stream, node->GetName()); - prop = node->GetProperties(); - while (prop) + attr = node->GetAttributes(); + while (attr) { - OutputString(stream, wxT(" ") + prop->GetName() + wxT("=\"")); - OutputStringEnt(stream, prop->GetValue(), convMem, convFile, + OutputString(stream, wxT(" ") + attr->GetName() + wxT("=\"")); + OutputStringEnt(stream, attr->GetValue(), convMem, convFile, XML_ESCAPE_QUOTES); OutputString(stream, wxT("\"")); - prop = prop->GetNext(); + attr = attr->GetNext(); } if (node->GetChildren()) diff --git a/src/xrc/xh_chckl.cpp b/src/xrc/xh_chckl.cpp index d4c97f998f..a633b112a9 100644 --- a/src/xrc/xh_chckl.cpp +++ b/src/xrc/xh_chckl.cpp @@ -72,7 +72,7 @@ wxObject *wxCheckListBoxXmlHandler::DoCreateResource() { n = n->GetNext(); continue; } // checking boolean is a bit ugly here (see GetBool() ) - wxString v = n->GetPropVal(wxT("checked"), wxEmptyString); + wxString v = n->GetAttribute(wxT("checked"), wxEmptyString); v.MakeLower(); if (v == wxT("1")) control->Check( i, true ); diff --git a/src/xrc/xh_odcombo.cpp b/src/xrc/xh_odcombo.cpp index 3093395902..fa4503ff64 100644 --- a/src/xrc/xh_odcombo.cpp +++ b/src/xrc/xh_odcombo.cpp @@ -103,12 +103,12 @@ bool wxOwnerDrawnComboBoxXmlHandler::CanHandle(wxXmlNode *node) #else // Avoid GCC bug - this fails on certain GCC 3.3 and 3.4 builds for an unknown reason -// it is believed to be related to the fact IsOfClass is inline, and node->GetPropVal +// it is believed to be related to the fact IsOfClass is inline, and node->GetAttribute // gets passed an invalid "this" pointer. On 2.7, the function is out of line, so the // above should work fine. This code is left in here so this file can easily be used // in a version backported to 2.6. All we are doing here is expanding the macro - bool fOurClass = node->GetPropVal(wxT("class"), wxEmptyString) == wxT("wxOwnerDrawnComboBox"); + bool fOurClass = node->GetAttribute(wxT("class"), wxEmptyString) == wxT("wxOwnerDrawnComboBox"); return (fOurClass || (m_insideBox && node->GetName() == wxT("item"))); #endif diff --git a/src/xrc/xh_radbx.cpp b/src/xrc/xh_radbx.cpp index 5cf6472c5b..dbbf54b5e4 100644 --- a/src/xrc/xh_radbx.cpp +++ b/src/xrc/xh_radbx.cpp @@ -109,10 +109,10 @@ wxObject *wxRadioBoxXmlHandler::DoCreateResource() wxString str = GetNodeContent(m_node); wxString tooltip; - m_node->GetPropVal(wxT("tooltip"), &tooltip); + m_node->GetAttribute(wxT("tooltip"), &tooltip); wxString helptext; - bool hasHelptext = m_node->GetPropVal(wxT("helptext"), &helptext); + bool hasHelptext = m_node->GetAttribute(wxT("helptext"), &helptext); if (m_resource->GetFlags() & wxXRC_USE_LOCALE) { diff --git a/src/xrc/xmlres.cpp b/src/xrc/xmlres.cpp index af053770ac..5a024457b6 100644 --- a/src/xrc/xmlres.cpp +++ b/src/xrc/xmlres.cpp @@ -351,7 +351,7 @@ static void ProcessPlatformProperty(wxXmlNode *node) while (c) { isok = false; - if (!c->GetPropVal(wxT("platform"), &s)) + if (!c->GetAttribute(wxT("platform"), &s)) isok = true; else { @@ -481,7 +481,7 @@ bool wxXmlResource::UpdateResources() { long version; int v1, v2, v3, v4; - wxString verstr = m_data[i].Doc->GetRoot()->GetPropVal( + wxString verstr = m_data[i].Doc->GetRoot()->GetAttribute( wxT("version"), wxT("0.0.0.0")); if (wxSscanf(verstr.c_str(), wxT("%i.%i.%i.%i"), &v1, &v2, &v3, &v4) == 4) @@ -534,20 +534,20 @@ wxXmlNode *wxXmlResource::DoFindResource(wxXmlNode *parent, if ( node->GetType() == wxXML_ELEMENT_NODE && (node->GetName() == wxT("object") || node->GetName() == wxT("object_ref")) && - node->GetPropVal(wxT("name"), &dummy) && dummy == name ) + node->GetAttribute(wxT("name"), &dummy) && dummy == name ) { - wxString cls(node->GetPropVal(wxT("class"), wxEmptyString)); + wxString cls(node->GetAttribute(wxT("class"), wxEmptyString)); if (!classname || cls == classname) return node; - // object_ref may not have 'class' property: + // object_ref may not have 'class' attribute: if (cls.empty() && node->GetName() == wxT("object_ref")) { - wxString refName = node->GetPropVal(wxT("ref"), wxEmptyString); + wxString refName = node->GetAttribute(wxT("ref"), wxEmptyString); if (refName.empty()) continue; wxXmlNode* refNode = FindResource(refName, wxEmptyString, true); if (refNode && - refNode->GetPropVal(wxT("class"), wxEmptyString) == classname) + refNode->GetAttribute(wxT("class"), wxEmptyString) == classname) { return node; } @@ -601,34 +601,35 @@ wxXmlNode *wxXmlResource::FindResource(const wxString& name, static void MergeNodes(wxXmlNode& dest, wxXmlNode& with) { - // Merge properties: - for (wxXmlProperty *prop = with.GetProperties(); prop; prop = prop->GetNext()) + // Merge attributes: + for ( wxXmlAttribute *attr = with.GetAttributes(); + attr; attr = attr->GetNext() ) { - wxXmlProperty *dprop; - for (dprop = dest.GetProperties(); dprop; dprop = dprop->GetNext()) + wxXmlAttribute *dattr; + for (dattr = dest.GetAttributes(); dattr; dattr = dattr->GetNext()) { - if ( dprop->GetName() == prop->GetName() ) + if ( dattr->GetName() == attr->GetName() ) { - dprop->SetValue(prop->GetValue()); + dattr->SetValue(attr->GetValue()); break; } } - if ( !dprop ) - dest.AddProperty(prop->GetName(), prop->GetValue()); + if ( !dattr ) + dest.AddAttribute(attr->GetName(), attr->GetValue()); } // Merge child nodes: for (wxXmlNode* node = with.GetChildren(); node; node = node->GetNext()) { - wxString name = node->GetPropVal(wxT("name"), wxEmptyString); + wxString name = node->GetAttribute(wxT("name"), wxEmptyString); wxXmlNode *dnode; for (dnode = dest.GetChildren(); dnode; dnode = dnode->GetNext() ) { if ( dnode->GetName() == node->GetName() && - dnode->GetPropVal(wxT("name"), wxEmptyString) == name && + dnode->GetAttribute(wxT("name"), wxEmptyString) == name && dnode->GetType() == node->GetType() ) { MergeNodes(*dnode, *node); @@ -639,7 +640,7 @@ static void MergeNodes(wxXmlNode& dest, wxXmlNode& with) if ( !dnode ) { static const wxChar *AT_END = wxT("end"); - wxString insert_pos = node->GetPropVal(wxT("insert_at"), AT_END); + wxString insert_pos = node->GetAttribute(wxT("insert_at"), AT_END); if ( insert_pos == AT_END ) { dest.AddChild(new wxXmlNode(*node)); @@ -664,7 +665,7 @@ wxObject *wxXmlResource::CreateResFromNode(wxXmlNode *node, wxObject *parent, // handling of referenced resource if ( node->GetName() == wxT("object_ref") ) { - wxString refName = node->GetPropVal(wxT("ref"), wxEmptyString); + wxString refName = node->GetAttribute(wxT("ref"), wxEmptyString); wxXmlNode* refNode = FindResource(refName, wxEmptyString, true); if ( !refNode ) @@ -705,7 +706,7 @@ wxObject *wxXmlResource::CreateResFromNode(wxXmlNode *node, wxObject *parent, wxLogError(_("No handler found for XML node '%s', class '%s'!"), node->GetName().c_str(), - node->GetPropVal(wxT("class"), wxEmptyString).c_str()); + node->GetAttribute(wxT("class"), wxEmptyString).c_str()); return NULL; } @@ -759,10 +760,10 @@ wxObject *wxXmlResourceHandler::CreateResource(wxXmlNode *node, wxObject *parent wxWindow *myParentAW = m_parentAsWindow; m_instance = instance; - if (!m_instance && node->HasProp(wxT("subclass")) && + if (!m_instance && node->HasAttribute(wxT("subclass")) && !(m_resource->GetFlags() & wxXRC_NO_SUBCLASSING)) { - wxString subclass = node->GetPropVal(wxT("subclass"), wxEmptyString); + wxString subclass = node->GetAttribute(wxT("subclass"), wxEmptyString); if (!subclass.empty()) { for (wxXmlSubclassFactoriesList::compatibility_iterator i = wxXmlResource::ms_subclassFactories->GetFirst(); @@ -775,7 +776,7 @@ wxObject *wxXmlResourceHandler::CreateResource(wxXmlNode *node, wxObject *parent if (!m_instance) { - wxString name = node->GetPropVal(wxT("name"), wxEmptyString); + wxString name = node->GetAttribute(wxT("name"), wxEmptyString); wxLogError(_("Subclass '%s' not found for resource '%s', not subclassing!"), subclass.c_str(), name.c_str()); } @@ -783,7 +784,7 @@ wxObject *wxXmlResourceHandler::CreateResource(wxXmlNode *node, wxObject *parent } m_node = node; - m_class = node->GetPropVal(wxT("class"), wxEmptyString); + m_class = node->GetAttribute(wxT("class"), wxEmptyString); m_parent = parent; m_parentAsWindow = wxDynamicCast(m_parent, wxWindow); @@ -922,7 +923,7 @@ wxString wxXmlResourceHandler::GetText(const wxString& param, bool translate) if (m_resource->GetFlags() & wxXRC_USE_LOCALE) { if (translate && parNode && - parNode->GetPropVal(wxT("translate"), wxEmptyString) != wxT("0")) + parNode->GetAttribute(wxT("translate"), wxEmptyString) != wxT("0")) { return wxGetTranslation(str2, m_resource->GetDomain()); } @@ -986,7 +987,7 @@ int wxXmlResourceHandler::GetID() wxString wxXmlResourceHandler::GetName() { - return m_node->GetPropVal(wxT("name"), wxT("-1")); + return m_node->GetAttribute(wxT("name"), wxT("-1")); } @@ -1068,7 +1069,7 @@ wxColour wxXmlResourceHandler::GetColour(const wxString& param, const wxColour& if (clr.Ok()) return clr; - wxLogError(_("XRC resource: Incorrect colour specification '%s' for property '%s'."), + wxLogError(_("XRC resource: Incorrect colour specification '%s' for attribute '%s'."), v.c_str(), param.c_str()); return wxNullColour; } @@ -1086,10 +1087,10 @@ wxBitmap wxXmlResourceHandler::GetBitmap(const wxString& param, wxXmlNode *bmpNode = GetParamNode(param); if ( bmpNode ) { - wxString sid = bmpNode->GetPropVal(wxT("stock_id"), wxEmptyString); + wxString sid = bmpNode->GetAttribute(wxT("stock_id"), wxEmptyString); if ( !sid.empty() ) { - wxString scl = bmpNode->GetPropVal(wxT("stock_client"), wxEmptyString); + wxString scl = bmpNode->GetAttribute(wxT("stock_client"), wxEmptyString); if (scl.empty()) scl = defaultArtClient; else @@ -1195,7 +1196,7 @@ wxXmlNode *wxXmlResourceHandler::GetParamNode(const wxString& param) bool wxXmlResourceHandler::IsOfClass(wxXmlNode *node, const wxString& classname) { - return node->GetPropVal(wxT("class"), wxEmptyString) == classname; + return node->GetAttribute(wxT("class"), wxEmptyString) == classname; } diff --git a/utils/wxrc/wxrc.cpp b/utils/wxrc/wxrc.cpp index 9d740b4947..9d7bd03d14 100644 --- a/utils/wxrc/wxrc.cpp +++ b/utils/wxrc/wxrc.cpp @@ -65,8 +65,8 @@ private: while (node) { if (node->GetName() == _T("object") - && node->GetPropVal(_T("class"),&classValue) - && node->GetPropVal(_T("name"),&nameValue)) + && node->GetAttribute(_T("class"),&classValue) + && node->GetAttribute(_T("name"),&nameValue)) { m_wdata.Add(XRCWidgetData(nameValue,classValue)); } @@ -409,8 +409,8 @@ wxArrayString XmlResApp::PrepareTempFiles() wxString classValue,nameValue; while(node){ if(node->GetName() == _T("object") - && node->GetPropVal(_T("class"),&classValue) - && node->GetPropVal(_T("name"),&nameValue)){ + && node->GetAttribute(_T("class"),&classValue) + && node->GetAttribute(_T("name"),&nameValue)){ aXRCWndClassData.Add( XRCWndClassData(nameValue,classValue,node) @@ -444,7 +444,7 @@ static bool NodeContainsFilename(wxXmlNode *node) // wxBitmapButton: wxXmlNode *parent = node->GetParent(); if (parent != NULL && - parent->GetPropVal(_T("class"), _T("")) == _T("wxBitmapButton") && + parent->GetAttribute(_T("class"), _T("")) == _T("wxBitmapButton") && (name == _T("focus") || name == _T("disabled") || name == _T("selected"))) @@ -453,7 +453,7 @@ static bool NodeContainsFilename(wxXmlNode *node) // wxBitmap or wxIcon toplevel resources: if ( name == _T("object") ) { - wxString klass = node->GetPropVal(_T("class"), wxEmptyString); + wxString klass = node->GetAttribute(_T("class"), wxEmptyString); if (klass == _T("wxBitmap") || klass == _T("wxIcon") || klass == _T("data") ) @@ -463,7 +463,7 @@ static bool NodeContainsFilename(wxXmlNode *node) // URLs in wxHtmlWindow: if ( name == _T("url") && parent != NULL && - parent->GetPropVal(_T("class"), _T("")) == _T("wxHtmlWindow") ) + parent->GetAttribute(_T("class"), _T("")) == _T("wxHtmlWindow") ) { // FIXME: this is wrong for e.g. http:// URLs return true; @@ -917,7 +917,7 @@ wxArrayString XmlResApp::FindStrings(wxXmlNode *node) // ...and known to contain translatable string { if (!flagGettext || - node->GetPropVal(_T("translate"), _T("1")) != _T("0")) + node->GetAttribute(_T("translate"), _T("1")) != _T("0")) { arr.Add(ConvertText(n->GetContent())); } -- 2.47.2