From 6549acd69973cee030c9c73e55470094221b212e Mon Sep 17 00:00:00 2001 From: Claudius 'keldu' Holeksa Date: Wed, 4 Sep 2024 15:36:17 +0200 Subject: Preparing csv to work --- modules/codec/c++/csv.hpp | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) (limited to 'modules/codec/c++') diff --git a/modules/codec/c++/csv.hpp b/modules/codec/c++/csv.hpp index 82010d7..240ed75 100644 --- a/modules/codec/c++/csv.hpp +++ b/modules/codec/c++/csv.hpp @@ -97,7 +97,7 @@ struct csv_encode...>, FromDecode> { /** * Replace this with row separator */ - constexpr std::string_view lit = "\r\n"; + constexpr std::string_view lit = "\n"; for(int8_t iter : lit){ auto eov = stream_value::encode(iter, to); if ( eov.is_error()){ @@ -110,7 +110,10 @@ struct csv_encode...>, FromDecode> { } static error_or encode_header(buffer& to){ - return encode_header_i<0>(to); + if constexpr (sizeof...(V) > 0u){ + return encode_header_i<0u>(to); + } + return make_void(); } template @@ -225,12 +228,18 @@ struct csv_decode, FromDecode> { template class data { private: - ring_buffer buffer_; + own buffer_; public: - data() = default; + data(): + buffer_{heap()} + {} + + data(own buffer__): + buffer_{std::move(buffer__)} + {} buffer& get_buffer(){ - return buffer_; + return *buffer_; } }; @@ -253,10 +262,15 @@ public: template static error_or decode(data& from, data& to){ - (void) to; - (void) from; + auto& buff = from.get_buffer(); + buffer_view buff_v{buff}; + auto eov = impl::csv_decode::decode(buff_v, to); + if(eov.is_error()){ + return eov; + } + buff.write_advance(buff_v.write_offset()); - return make_error(); + return eov; } }; } -- cgit v1.2.3