mirror of
https://github.com/tristanpenman/valijson.git
synced 2024-12-13 10:32:58 +01:00
Simplify implementation of YamlCppObject::find()
This commit is contained in:
parent
375eaae06c
commit
c4355eaa47
@ -681,16 +681,13 @@ inline YamlCppObjectMemberIterator YamlCppObject::end() const
|
||||
inline YamlCppObjectMemberIterator
|
||||
YamlCppObject::find(const std::string &propertyName) const
|
||||
{
|
||||
YAML::Node result = m_value[propertyName];
|
||||
if (!result.IsDefined())
|
||||
return end();
|
||||
for (auto itr = begin(); itr != end(); ++itr) {
|
||||
if (itr->first == propertyName) {
|
||||
return itr;
|
||||
}
|
||||
}
|
||||
|
||||
// yaml-cpp does not offer an iterator-based lookup,
|
||||
// so instead we create a new placeholder object and
|
||||
// return an iterator to that container instead.
|
||||
YAML::Node wrapper = YAML::Node(YAML::NodeType::Map);
|
||||
wrapper[propertyName] = result;
|
||||
return YamlCppObjectMemberIterator(wrapper.begin());
|
||||
return end();
|
||||
}
|
||||
|
||||
} // namespace adapters
|
||||
|
Loading…
Reference in New Issue
Block a user