diff options
author | Claudius "keldu" Holeksa <mail@keldu.de> | 2024-01-10 17:10:26 +0100 |
---|---|---|
committer | Claudius "keldu" Holeksa <mail@keldu.de> | 2024-01-10 17:10:26 +0100 |
commit | 9a0bd3f93dbb1babc3149e3ba6348810a909fd4f (patch) | |
tree | 4b4682f03df7694b8edb29ed0f365cb1d030d8e2 /modules/codec/c++ | |
parent | c37a2a9aa037d6c47472c3a052e472e02510fed8 (diff) |
codec: Fixing minor issues csv and data definitions
Diffstat (limited to 'modules/codec/c++')
-rw-r--r-- | modules/codec/c++/csv.h | 3 | ||||
-rw-r--r-- | modules/codec/c++/data.h | 17 |
2 files changed, 18 insertions, 2 deletions
diff --git a/modules/codec/c++/csv.h b/modules/codec/c++/csv.h index 7a3a18e..d35bb2d 100644 --- a/modules/codec/c++/csv.h +++ b/modules/codec/c++/csv.h @@ -118,7 +118,7 @@ struct csv_encode<schema::Struct<schema::Member<V,K>...>, FromDecode> { return eov; } } - return encode_header(to); + return encode_i<i+1>(from, to); } { /** @@ -162,7 +162,6 @@ struct csv_encode<schema::Primitive<T,N>, FromDecode> { static error_or<void> encode(const data<Schema, FromDecode>& from, buffer& to){ std::string to_str; - try { to_str = std::to_string(from.get()); }catch(const std::exception& ){ diff --git a/modules/codec/c++/data.h b/modules/codec/c++/data.h index 2dffdbe..eb24841 100644 --- a/modules/codec/c++/data.h +++ b/modules/codec/c++/data.h @@ -383,6 +383,7 @@ private: typename native_data_type<schema::Primitive<T,N>>::type value_; public: data():value_{}{} + SAW_DEFAULT_COPY(data); SAW_DEFAULT_MOVE(data); @@ -394,6 +395,22 @@ public: } typename native_data_type<schema::Primitive<T,N>>::type get() const {return value_;} + + data<schema::Primitive<T,N>, encode::Native> operator*(const saw::data<schema::Primitive<T,N>, encode::Native>& rhs)const{ + return {get() * rhs.get()}; + } + + data<schema::Primitive<T,N>, encode::Native> operator/(const saw::data<schema::Primitive<T,N>, encode::Native>& rhs)const{ + return {get() / rhs.get()}; + } + + data<schema::Primitive<T,N>, encode::Native> operator+(const saw::data<schema::Primitive<T,N>, encode::Native>& rhs)const{ + return {get() + rhs.get()}; + } + + data<schema::Primitive<T,N>, encode::Native> operator-(const saw::data<schema::Primitive<T,N>, encode::Native>& rhs)const{ + return {get() - rhs.get()}; + } }; |