add a const method to check for existing key/value properties
handy to lookup up XMLNodes with "id" == ID w/o allocating memory.
This commit is contained in:
parent
c2e4cd2c6a
commit
255b5174c4
@ -119,8 +119,10 @@ public:
|
||||
const XMLPropertyList& properties() const { return _proplist; }
|
||||
XMLProperty* property(const char*);
|
||||
XMLProperty* property(const std::string&);
|
||||
const XMLProperty* property(const char* n) const { return const_cast<XMLNode*>(this)->property(n); }
|
||||
const XMLProperty* property(const std::string& n) const { return const_cast<XMLNode*>(this)->property(n); }
|
||||
const XMLProperty* property(const char* n) const { return const_cast<XMLNode*>(this)->property(n); }
|
||||
const XMLProperty* property(const std::string& n) const { return const_cast<XMLNode*>(this)->property(n); }
|
||||
|
||||
bool has_property_with_value (const std::string&, const std::string&) const;
|
||||
|
||||
XMLProperty* add_property(const char* name, const std::string& value);
|
||||
XMLProperty* add_property(const char* name, const char* value = "");
|
||||
|
@ -429,6 +429,17 @@ XMLNode::property(const string& ns)
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool
|
||||
XMLNode::has_property_with_value (const string& key, const string& value) const
|
||||
{
|
||||
map<string,XMLProperty*>::const_iterator iter = _propmap.find(key);
|
||||
if (iter != _propmap.end()) {
|
||||
const XMLProperty* p = (iter->second);
|
||||
return (p && p->value() == value);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
XMLProperty*
|
||||
XMLNode::add_property(const char* n, const string& v)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user