Add wxXmlResourceHandler::GetNodeAttribute()

Add another helper function that can be used in XRC handlers without
using wxXmlNode directly.
This commit is contained in:
Vadim Zeitlin 2024-02-03 19:55:35 +01:00
parent 921018cfc8
commit fe599e4757
4 changed files with 34 additions and 0 deletions

View file

@ -511,6 +511,11 @@ public:
// Returns the name of the node, e.g. "object" or "sizeritem".
wxString GetNodeName(const wxXmlNode *node) const override;
// Returns the value of the given attribute under the node.
wxString GetNodeAttribute(const wxXmlNode *node,
const wxString& attrName,
const wxString& defaultValue) const override;
// Gets node content from wxXML_ENTITY_NODE
// The problem is, <tag>content<tag> is represented as
// wxXML_ENTITY_NODE name="tag", content=""

View file

@ -62,6 +62,9 @@ public:
virtual bool IsOfClass(wxXmlNode *node, const wxString& classname) const = 0;
virtual bool IsObjectNode(const wxXmlNode *node) const = 0;
virtual wxString GetNodeName(const wxXmlNode *node) const = 0;
virtual wxString GetNodeAttribute(const wxXmlNode *node,
const wxString& attrName,
const wxString& defaultValue) const = 0;
virtual wxString GetNodeContent(const wxXmlNode *node) const = 0;
virtual wxXmlNode *GetNodeParent(const wxXmlNode *node) const = 0;
virtual wxXmlNode *GetNodeNext(const wxXmlNode *node) const = 0;
@ -247,6 +250,13 @@ protected:
return GetImpl()->GetNodeName(node);
}
wxString GetNodeAttribute(const wxXmlNode *node,
const wxString& attrName,
const wxString& defaultValue = {}) const
{
return GetImpl()->GetNodeAttribute(node, attrName, defaultValue);
}
wxString GetNodeContent(const wxXmlNode *node) const
{
return GetImpl()->GetNodeContent(node);