table: make NameTree enumeration usable with range-based for
NameTree::fullEnumerate and NameTree::partialEnumerate are changed
to return a type usable with range-based for.
NameTree enumeration test cases are also simplified.
refs #2155
Change-Id: I315d9502d2194670aa7054ab956ededefb0c7ca0
diff --git a/daemon/table/name-tree.hpp b/daemon/table/name-tree.hpp
index 2ef032e..b4e12ed 100644
--- a/daemon/table/name-tree.hpp
+++ b/daemon/table/name-tree.hpp
@@ -191,16 +191,34 @@
const name_tree::EntrySelector& entrySelector = name_tree::AnyEntry()) const;
public: // enumeration
- /**
- * \brief Enumerate all the name prefixes stored in the Name Tree.
+ /** \brief Enumerate all entries, optionally filtered by an EntrySelector.
+ * \return an unspecified type that have .begin() and .end() methods
+ * and is usable with range-based for
+ *
+ * Example:
+ * \code{.cpp}
+ * auto&& enumerable = nt.fullEnumerate();
+ * for (const name_tree::Entry& nte : enumerable) {
+ * ...
+ * }
+ * \endcode
*/
- const_iterator
+ Range
fullEnumerate(const name_tree::EntrySelector& entrySelector = name_tree::AnyEntry()) const;
- /**
- * \brief Enumerate all the name prefixes that satisfies the EntrySubTreeSelector.
- */
- const_iterator
+ /** \brief Enumerate all entries under a prefix, optionally filtered by an EntrySubTreeSelector.
+ * \return an unspecified type that have .begin() and .end() methods
+ * and is usable with range-based for
+ *
+ * Example:
+ * \code{.cpp}
+ * auto&& enumerable = nt.partialEnumerate(Name("/A/B/C"));
+ * for (const name_tree::Entry& nte : enumerable) {
+ * ...
+ * }
+ * \endcode
+ */
+ Range
partialEnumerate(const Name& prefix,
const name_tree::EntrySubTreeSelector& entrySubTreeSelector =
name_tree::AnyEntrySubTree()) const;
@@ -364,7 +382,7 @@
inline NameTree::const_iterator
NameTree::begin() const
{
- return fullEnumerate();
+ return fullEnumerate().begin();
}
inline NameTree::const_iterator