cpp-common: add `begin()` and `end()` to bt2::ConstFieldPath
authorFrancis Deslauriers <francis.deslauriers@efficios.com>
Wed, 9 Mar 2022 22:42:44 +0000 (17:42 -0500)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Mon, 11 Sep 2023 15:24:02 +0000 (11:24 -0400)
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: Ie442f80bf1d5b055f6707ff516a8094417ff6c1d
Reviewed-on: https://review.lttng.org/c/babeltrace/+/7553
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/10792
Tested-by: jenkins <jenkins@lttng.org>
CI-Build: Philippe Proulx <eeppeliteloop@gmail.com>

src/cpp-common/bt2/field-path.hpp

index 6bb912113ba93fc1cb50ba1c3fb118a283114855..75f98c68ea548dbe6f9accaa098cdde0fcd0ed16 100644 (file)
@@ -11,6 +11,7 @@
 #include <babeltrace2/babeltrace.h>
 
 #include "common/assert.h"
+#include "common-iter.hpp"
 #include "internal/borrowed-obj.hpp"
 #include "internal/shared-obj.hpp"
 
@@ -126,6 +127,8 @@ public:
     using Shared =
         internal::SharedObj<ConstFieldPath, const bt_field_path, internal::FieldPathRefFuncs>;
 
+    using Iterator = CommonIterator<ConstFieldPath, ConstFieldPathItem>;
+
     enum class Scope
     {
         PACKET_CONTEXT = BT_FIELD_PATH_SCOPE_PACKET_CONTEXT,
@@ -164,6 +167,16 @@ public:
             bt_field_path_borrow_item_by_index_const(this->libObjPtr(), index)};
     }
 
+    Iterator begin() const noexcept
+    {
+        return Iterator {*this, 0};
+    }
+
+    Iterator end() const noexcept
+    {
+        return Iterator {*this, this->size()};
+    }
+
     Shared shared() const noexcept
     {
         return Shared {*this};
This page took 0.026222 seconds and 4 git commands to generate.