add a Node::ContainsKey function for quick checking of subordinated

This commit is contained in:
marcel 2021-08-30 14:15:48 +02:00
parent 6bd373fb8a
commit 737117332d
2 changed files with 12 additions and 0 deletions

View File

@ -350,6 +350,16 @@ std::string key_to_string(const Key& key) {
}
// indexing
template <typename Key>
inline bool Node::ContainsKey(const Key& key) const {
EnsureNodeExists();
if (! IsMap())
return false;
detail::node* value =
static_cast<const detail::node&>(*m_pNode).get(key, m_pMemory);
return (bool)value;
}
template <typename Key>
inline const Node Node::operator[](const Key& key) const {
EnsureNodeExists();

View File

@ -99,6 +99,8 @@ class YAML_CPP_API Node {
// indexing
template <typename Key>
bool ContainsKey(const Key& key) const;
template <typename Key>
const Node operator[](const Key& key) const;
template <typename Key>
Node operator[](const Key& key);