From 35119a9d3750bf786e841c25a46cd59ea2117462 Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Sat, 20 Jul 2024 19:37:39 +0200 Subject: wip --- modules/codec/c++/transport.hpp | 36 +++++++++++++++++++++++++++++++++++ modules/core/c++/buffer.hpp | 17 +++++++++++++++++ modules/core/c++/common.hpp | 4 ++++ modules/io_codec/c++/io_peer.tmpl.hpp | 6 +++--- 4 files changed, 60 insertions(+), 3 deletions(-) create mode 100644 modules/codec/c++/transport.hpp (limited to 'modules') diff --git a/modules/codec/c++/transport.hpp b/modules/codec/c++/transport.hpp new file mode 100644 index 0000000..db277d1 --- /dev/null +++ b/modules/codec/c++/transport.hpp @@ -0,0 +1,36 @@ +#pragma once + +namespace saw { +namespace transport { +template +struct FixedLength {}; + +template +struct VarLength {}; + +struct NewLine {}; +struct CarriageReturnNewLine {}; +} + +template +struct transport { +private: + static_assert(always_false, "Transport kind not supported."); +public: + + +template +struct transport> { +private: +public: + error_or view_slice(const buffer& buff) const { + (void) buff; + return make_error(); + } + + error_or chain_slice(buffer& buff) const { + (void) buff; + return make_error(); + } +}; +} diff --git a/modules/core/c++/buffer.hpp b/modules/core/c++/buffer.hpp index f62e7ad..87c54a6 100644 --- a/modules/core/c++/buffer.hpp +++ b/modules/core/c++/buffer.hpp @@ -194,5 +194,22 @@ public: const uint8_t &write(size_t i = 0) const override; error write_require_length(size_t bytes) override; + + /** + */ + error_or extract_front(uint64_t size) { + if(buffer_.empty()){ + return make_error("Chain Array buffer is empty."); + } + + auto& arr_front = buffer_.front(); + if(size != arr_front.size()){ + return make_error("Can't extract array buffer. Size doesn't match. Use view and copy."); + } + + auto arr = std::move(buffer_.front()); + buffer_.pop_front(); + return std::move(arr); + } }; } // namespace saw diff --git a/modules/core/c++/common.hpp b/modules/core/c++/common.hpp index ebca498..f63c531 100644 --- a/modules/core/c++/common.hpp +++ b/modules/core/c++/common.hpp @@ -46,6 +46,10 @@ private: T* ptr_; public: + ptr(): + ptr_{nullptr} + {} + ptr(T& ptr__): ptr_{&ptr__} {} diff --git a/modules/io_codec/c++/io_peer.tmpl.hpp b/modules/io_codec/c++/io_peer.tmpl.hpp index 2babb1c..d9dfe04 100644 --- a/modules/io_codec/c++/io_peer.tmpl.hpp +++ b/modules/io_codec/c++/io_peer.tmpl.hpp @@ -1,8 +1,8 @@ namespace saw { -template -streaming_io_peer:: streaming_io_peer( own>> feed, @@ -10,7 +10,7 @@ streaming_io_peer -streaming_io_peer:: streaming_io_peer( own>> feed, -- cgit v1.2.3