diff options
author | Roman Smrž <roman.smrz@seznam.cz> | 2023-01-08 13:20:26 +0100 |
---|---|---|
committer | Roman Smrž <roman.smrz@seznam.cz> | 2023-01-08 17:20:29 +0100 |
commit | 5b1887367680c494e27794252fee8d1aacf088ef (patch) | |
tree | f4c97d2e98cb81a2ce58cd681ebb2898c1db66de /src/merge.cpp | |
parent | 7ec9843046705368f7a0888f8f95f8a0400862ba (diff) |
Property lookup helpers
Diffstat (limited to 'src/merge.cpp')
-rw-r--r-- | src/merge.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/merge.cpp b/src/merge.cpp new file mode 100644 index 0000000..040ebb4 --- /dev/null +++ b/src/merge.cpp @@ -0,0 +1,26 @@ +#include <erebos/merge.h> + +namespace erebos { + +static void findPropertyObjects(vector<Stored<Object>> & candidates, const Stored<Object> & obj, const string & prop) +{ + if (auto rec = obj->asRecord()) { + if (rec->item(prop)) { + candidates.push_back(obj); + } else { + for (const auto & r : obj.ref().previous()) + findPropertyObjects(candidates, Stored<Object>::load(r), prop); + } + } +} + +vector<Stored<Object>> findPropertyObjects(const vector<Stored<Object>> & leaves, const string & prop) +{ + vector<Stored<Object>> candidates; + for (const auto & obj : leaves) + findPropertyObjects(candidates, obj, prop); + filterAncestors(candidates); + return candidates; +} + +} |