diff options
author | Claudius Holeksa <mail@keldu.de> | 2023-06-07 20:40:33 +0200 |
---|---|---|
committer | Claudius Holeksa <mail@keldu.de> | 2023-06-07 20:40:33 +0200 |
commit | b670001ca80dbc0e1a51b4a08776eb41dabc2a9e (patch) | |
tree | 7d71dcfbc6eabc51ce551b71191a80727e58e2b2 /src | |
parent | 07fd10c0584c7f0827dfd3ff8319e4cb174e5973 (diff) |
codec-json,c++: Progress on design issues
Diffstat (limited to 'src')
-rw-r--r-- | src/codec-json/json.h | 14 | ||||
-rw-r--r-- | src/codec-json/json.tmpl.h | 22 |
2 files changed, 26 insertions, 10 deletions
diff --git a/src/codec-json/json.h b/src/codec-json/json.h index 0ba7a2d..2a0bea9 100644 --- a/src/codec-json/json.h +++ b/src/codec-json/json.h @@ -4,6 +4,8 @@ #include <forstio/core/common.h> #include <forstio/codec/data.h> +#include "json.tmpl.h" + #include <algorithm> namespace saw { @@ -18,23 +20,15 @@ private: public: data() = default; - void reserve(std::size_t i){ - buffer_.reserve(i); - } - - void concat(int8_t c){ - buffer_.emplace_back(c); - } - std::size_t get_size() const { return buffer_.size(); } - int8_t& at(std::size_t i){ + uint8_t& at(std::size_t i){ return buffer_.at(i); } - const int8_t& at(std::size_t i) const { + const uint8_t& at(std::size_t i) const { return buffer_.at(i); } }; diff --git a/src/codec-json/json.tmpl.h b/src/codec-json/json.tmpl.h new file mode 100644 index 0000000..d29f29c --- /dev/null +++ b/src/codec-json/json.tmpl.h @@ -0,0 +1,22 @@ +#pragma once + +#include <charconv> + +namespace saw { +namespace impl { +template<typename Schema, typename RootSchema, typename FromEncode> +class json_encode_impl { + static_assert(always_false<Schema, RootSchema, FromEncode>, "This schema type is not being handle by the json encoding."); +}; + +template<size_t N, typename RootSchema, typename FromEncode> +class json_encode_impl<saw::schema::Primitive<schema::FloatingPoint,N>, RootSchema, FromEncode> { + static ErrorOr<void> encode(const data<Schema, FromEncode>& from, data<Schema, encode::Json>& to, size_t ptr) { + auto val = from.get(); + auto tc_result = std::to_chars(); + + return Void{}; + } +}; +} +} |