diff options
author | Robin Gareus <robin@gareus.org> | 2016-05-03 02:07:40 +0200 |
---|---|---|
committer | Robin Gareus <robin@gareus.org> | 2016-05-03 03:03:00 +0200 |
commit | 255b5174c4f162006d564327fb54f48bbd7ddc09 (patch) | |
tree | b8157265870f0ab5cccbd5b7b520ccf524f8a87c /libs/pbd/xml++.cc | |
parent | c2e4cd2c6a614718c8bc6a795d56fd4e6232bd84 (diff) |
add a const method to check for existing key/value properties
handy to lookup up XMLNodes with "id" == ID w/o allocating memory.
Diffstat (limited to 'libs/pbd/xml++.cc')
-rw-r--r-- | libs/pbd/xml++.cc | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/libs/pbd/xml++.cc b/libs/pbd/xml++.cc index 6d260f2525..580ad8dc8b 100644 --- a/libs/pbd/xml++.cc +++ b/libs/pbd/xml++.cc @@ -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) { |