#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 {
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());
}
};
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 {
}
};
-} // namespace internal
+} /* namespace internal */
class ConstFieldPath final : public internal::BorrowedObj<const bt_field_path>
{
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,
{
}
- 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 */