Sort includes in C++ files
[babeltrace.git] / src / cpp-common / bt2 / field.hpp
index a59ac9fdf686305060b96f26327dd133bb23978b..5a3fdfd93ea106b82436dde1d97b8ef6f11bdeb1 100644 (file)
@@ -7,16 +7,18 @@
 #ifndef BABELTRACE_CPP_COMMON_BT2_FIELD_HPP
 #define BABELTRACE_CPP_COMMON_BT2_FIELD_HPP
 
-#include <type_traits>
 #include <cstdint>
+#include <type_traits>
+
 #include <babeltrace2/babeltrace.h>
 
 #include "common/assert.h"
-#include "internal/borrowed-obj.hpp"
-#include "internal/utils.hpp"
 #include "cpp-common/optional.hpp"
 #include "cpp-common/string_view.hpp"
+
 #include "field-class.hpp"
+#include "internal/borrowed-obj.hpp"
+#include "internal/utils.hpp"
 
 namespace bt2 {
 
@@ -649,6 +651,8 @@ public:
             internal::CommonFieldSpec<const bt_field>::cls(this->libObjPtr())};
     }
 
+    using CommonUnsignedIntegerField<LibObjT>::operator=;
+
     Class cls() noexcept
     {
         return Class {internal::CommonFieldSpec<LibObjT>::cls(this->libObjPtr())};
@@ -724,6 +728,8 @@ public:
         return *this;
     }
 
+    using CommonSignedIntegerField<LibObjT>::operator=;
+
     ConstSignedEnumerationFieldClass cls() const noexcept
     {
         return ConstSignedEnumerationFieldClass {
@@ -962,6 +968,22 @@ public:
         return *this = val.data();
     }
 
+    void append(const char * const begin, const std::uint64_t len)
+    {
+        static_assert(!std::is_const<LibObjT>::value, "`LibObjT` must NOT be `const`.");
+
+        const auto status = bt_field_string_append_with_length(this->libObjPtr(), begin, len);
+
+        if (status == BT_FIELD_STRING_APPEND_STATUS_MEMORY_ERROR) {
+            throw MemoryError {};
+        }
+    }
+
+    void append(const std::string& val)
+    {
+        this->append(val.data(), val.size());
+    }
+
     void clear() noexcept
     {
         static_assert(!std::is_const<LibObjT>::value, "`LibObjT` must NOT be `const`.");
@@ -1398,7 +1420,7 @@ public:
 
     bool hasField() const noexcept
     {
-        return this->field();
+        return this->field().has_value();
     }
 
     nonstd::optional<ConstField> field() const noexcept
This page took 0.023303 seconds and 4 git commands to generate.