cpp-common/bt2: field.hpp: Add assignment operator for Enum field
[babeltrace.git] / src / cpp-common / bt2 / field.hpp
index 7b6777182fd7fca144cf371811f60753a943aedc..4b3853826b2871478eb9f634d9cc39dfd73d8b76 100644 (file)
@@ -402,7 +402,7 @@ struct TypeDescr<ConstBitArrayField> : public BitArrayFieldTypeDescr
 } /* namespace internal */
 
 template <typename LibObjT>
-class CommonUnsignedIntegerField final : public CommonField<LibObjT>
+class CommonUnsignedIntegerField : public CommonField<LibObjT>
 {
 private:
     using typename CommonField<LibObjT>::_ThisCommonField;
@@ -491,7 +491,7 @@ struct TypeDescr<ConstUnsignedIntegerField> : public UnsignedIntegerFieldTypeDes
 } /* namespace internal */
 
 template <typename LibObjT>
-class CommonSignedIntegerField final : public CommonField<LibObjT>
+class CommonSignedIntegerField : public CommonField<LibObjT>
 {
 private:
     using typename CommonField<LibObjT>::_ThisCommonField;
@@ -501,7 +501,7 @@ protected:
     using _ThisCommonSignedIntegerField = CommonSignedIntegerField<LibObjT>;
 
 public:
-    using Value = std::uint64_t;
+    using Value = std::int64_t;
 
     using Class = typename std::conditional<std::is_const<LibObjT>::value, ConstIntegerFieldClass,
                                             IntegerFieldClass>::type;
@@ -649,6 +649,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 +726,8 @@ public:
         return *this;
     }
 
+    using CommonSignedIntegerField<LibObjT>::operator=;
+
     ConstSignedEnumerationFieldClass cls() const noexcept
     {
         return ConstSignedEnumerationFieldClass {
@@ -881,13 +885,13 @@ public:
     {
         static_assert(!std::is_const<LibObjT>::value, "`LibObjT` must NOT be `const`.");
 
-        bt_field_real_single_precision_set_value(this->libObjPtr(), val);
+        bt_field_real_double_precision_set_value(this->libObjPtr(), val);
         return *this;
     }
 
     Value value() const noexcept
     {
-        return bt_field_real_single_precision_get_value(this->libObjPtr());
+        return bt_field_real_double_precision_get_value(this->libObjPtr());
     }
 
     operator Value() const noexcept
@@ -944,7 +948,7 @@ public:
         return *this;
     }
 
-    CommonStringField<LibObjT>& operator=(const char * const val) noexcept
+    CommonStringField<LibObjT>& operator=(const char * const val)
     {
         static_assert(!std::is_const<LibObjT>::value, "`LibObjT` must NOT be `const`.");
 
@@ -957,11 +961,27 @@ public:
         return *this;
     }
 
-    CommonStringField<LibObjT>& operator=(const std::string& val) noexcept
+    CommonStringField<LibObjT>& operator=(const std::string& val)
     {
         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`.");
This page took 0.025784 seconds and 4 git commands to generate.