Sort includes in C++ files
[babeltrace.git] / src / cpp-common / bt2 / field-path.hpp
index b91d91135ba95aed791ba64853a6d241abf327a5..0a68927cf9dfc2e56fa82b1557b0907777a3cacf 100644 (file)
@@ -8,10 +8,14 @@
 #define BABELTRACE_CPP_COMMON_BT2_FIELD_PATH_HPP
 
 #include <cstdint>
+
 #include <babeltrace2/babeltrace.h>
 
 #include "common/assert.h"
+
+#include "common-iter.hpp"
 #include "internal/borrowed-obj.hpp"
+#include "internal/shared-obj.hpp"
 
 namespace bt2 {
 
@@ -66,7 +70,7 @@ public:
 private:
     bt_field_path_item_type _libType() const noexcept
     {
-        return bt_field_path_item_get_type(this->_libObjPtr());
+        return bt_field_path_item_get_type(this->libObjPtr());
     }
 };
 
@@ -92,14 +96,14 @@ public:
 
     std::uint64_t index() const noexcept
     {
-        return bt_field_path_item_index_get_index(this->_libObjPtr());
+        return bt_field_path_item_index_get_index(this->libObjPtr());
     }
 };
 
 inline ConstIndexFieldPathItem ConstFieldPathItem::asIndex() const noexcept
 {
     BT_ASSERT_DBG(this->isIndex());
-    return ConstIndexFieldPathItem {this->_libObjPtr()};
+    return ConstIndexFieldPathItem {this->libObjPtr()};
 }
 
 namespace internal {
@@ -117,7 +121,7 @@ struct FieldPathRefFuncs final
     }
 };
 
-} // namespace internal
+} /* namespace internal */
 
 class ConstFieldPath final : public internal::BorrowedObj<const bt_field_path>
 {
@@ -125,6 +129,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,
@@ -137,38 +143,48 @@ public:
     {
     }
 
-    ConstFieldPath(const ConstFieldPath& clkSnapshot) noexcept : _ThisBorrowedObj {clkSnapshot}
+    ConstFieldPath(const ConstFieldPath& fieldPath) noexcept : _ThisBorrowedObj {fieldPath}
     {
     }
 
-    ConstFieldPath& operator=(const ConstFieldPath& clkSnapshot) noexcept
+    ConstFieldPath& operator=(const ConstFieldPath& fieldPath) noexcept
     {
-        _ThisBorrowedObj::operator=(clkSnapshot);
+        _ThisBorrowedObj::operator=(fieldPath);
         return *this;
     }
 
     Scope rootScope() const noexcept
     {
-        return static_cast<Scope>(bt_field_path_get_root_scope(this->_libObjPtr()));
+        return static_cast<Scope>(bt_field_path_get_root_scope(this->libObjPtr()));
     }
 
     std::uint64_t size() const noexcept
     {
-        return bt_field_path_get_item_count(this->_libObjPtr());
+        return bt_field_path_get_item_count(this->libObjPtr());
     }
 
     ConstFieldPathItem operator[](const std::uint64_t index) const noexcept
     {
         return ConstFieldPathItem {
-            bt_field_path_borrow_item_by_index_const(this->_libObjPtr(), index)};
+            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};
+        return Shared::createWithRef(*this);
     }
 };
 
-} // namespace bt2
+} /* namespace bt2 */
 
-#endif // BABELTRACE_CPP_COMMON_BT2_FIELD_PATH_HPP
+#endif /* BABELTRACE_CPP_COMMON_BT2_FIELD_PATH_HPP */
This page took 0.025997 seconds and 4 git commands to generate.