diff options
author | Claudius Holeksa <mail@keldu.de> | 2023-06-28 11:22:13 +0200 |
---|---|---|
committer | Claudius Holeksa <mail@keldu.de> | 2023-06-28 11:22:13 +0200 |
commit | 8c9d5c54a4510a992ca7c409ccd4d359ed499250 (patch) | |
tree | 6d9c01c7b540ac08705d92d81cff3006ff5c38cd /src | |
parent | 0bd38cdec70c3a07467fccd81b570b754996eb95 (diff) |
c++,codec-json: Fixed bugs relating to wrong buffer calls and missing
return call
Diffstat (limited to 'src')
-rw-r--r-- | src/codec-json/json.tmpl.h | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/codec-json/json.tmpl.h b/src/codec-json/json.tmpl.h index 4f4d6f4..4ef8676 100644 --- a/src/codec-json/json.tmpl.h +++ b/src/codec-json/json.tmpl.h @@ -391,7 +391,7 @@ struct json_decode<schema::Primitive<T,N>, RootSchema, ToDecode> { template<typename RootSchema, typename ToDecode> struct json_decode<schema::String, RootSchema, ToDecode> { static error_or<void> decode(buffer_view& buff, data<schema::String, ToDecode>& to){ - assert(buff.read('"')); + assert(buff.read() == '"'); buff.read_advance(1); std::stringstream iss; @@ -493,9 +493,9 @@ struct json_decode<schema::Array<T,D>, RootSchema, ToDecode> { } ++index[Level]; - if(buff.read(',')){ + if(buff.read() == ','){ buff.read_advance(1); - } else if(buff.read(']')){ + } else if(buff.read() == ']'){ buff.read_advance(1); break; } else { @@ -516,9 +516,10 @@ struct json_decode<schema::Array<T,D>, RootSchema, ToDecode> { } template<std::size_t Level> - static error_or<void> decode_unflat_level(const std::vector<data<T,encode::Native>>& flat, data<schema::Array<T,D>, ToDecode>& to, std::array<std::size_t, D>& index, std::size_t& flat_index) { + static error_or<void> decode_unflat_level(std::vector<data<T,encode::Native>>& flat, data<schema::Array<T,D>, ToDecode>& to, std::array<std::size_t, D>& index, std::size_t& flat_index) { if constexpr ( Level == D ){ - to.at(index) = flat.at(flat_index); + auto& flat_data = flat.at(flat_index); + to.at(index) = std::move(flat_data); ++flat_index; }else { const std::size_t dim_size = to.get_dim_size(Level); @@ -530,6 +531,7 @@ struct json_decode<schema::Array<T,D>, RootSchema, ToDecode> { } } } + return void_t{}; } static error_or<void> decode(buffer_view& buff, data<schema::Array<T,D>, ToDecode>& to){ |