diff options
author | Claudius "keldu" Holeksa <mail@keldu.de> | 2023-06-10 23:45:17 +0200 |
---|---|---|
committer | Claudius "keldu" Holeksa <mail@keldu.de> | 2023-06-10 23:45:17 +0200 |
commit | 73fac05aa07a0dd16f7061baddd4b934c7855fed (patch) | |
tree | a604b60635052450755729beaa8450c402ab05a6 /src/codec-json/json.h | |
parent | 6c8e3d1786a5de4ae562c03693b8dad9dd0ab26e (diff) |
c++: Setting up testing progress
Diffstat (limited to 'src/codec-json/json.h')
-rw-r--r-- | src/codec-json/json.h | 40 |
1 files changed, 21 insertions, 19 deletions
diff --git a/src/codec-json/json.h b/src/codec-json/json.h index f23aff9..c8456b5 100644 --- a/src/codec-json/json.h +++ b/src/codec-json/json.h @@ -4,40 +4,43 @@ #include <forstio/core/common.h> #include <forstio/codec/data.h> -#include "json.tmpl.h" - #include <algorithm> namespace saw { namespace encode { struct Json {}; } +} + +#include "json.tmpl.h" + +namespace saw { template<typename Schema> class data<Schema, encode::Json> { private: - own<buffer> buffer_; + ring_buffer buffer_; public: - - data(): - buffer_{heap<ring_buffer>()} - {} + data():buffer_{}{} buffer& get_buffer(){ - assert(buffer_); - return *buffer_; + return buffer_; + } + + void push(uint8_t val){ + buffer_.push(val); } std::size_t get_size() const { - return buffer_.size(); + return buffer_.read_composite_length(); } uint8_t& at(std::size_t i){ - return buffer_.at(i); + return buffer_.read(i); } const uint8_t& at(std::size_t i) const { - return buffer_.at(i); + return buffer_.read(i); } }; @@ -57,7 +60,7 @@ public: /** * Default constructor */ - config(){} + codec(){} /** * Constructor @@ -68,16 +71,15 @@ public: SAW_DEFAULT_MOVE(codec); template <typename FromEncoding> - ErrorOr<void> encode(const data<Schema, FromEncoding>& from_encode, data<Schema, encode::Json>& to_encode){ + error_or<void> encode(const data<Schema, FromEncoding>& from_encode, data<Schema, encode::Json>& to_encode){ // To Be encoded - - - return Void {}; + return impl::json_encode<Schema, Schema, FromEncoding>::encode(from_encode, to_encode); } template <typename ToEncoding> - ErrorOr<void> decode(const data<Schema, encode::Json>& from_decode, data<Schema, ToEncoding>& to_decode){ - return Void {}; + error_or<void> decode(const data<Schema, encode::Json>& from_decode, data<Schema, ToEncoding>& to_decode){ + return void_t {}; } }; } + |