summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--modules/codec/c++/transport.hpp36
-rw-r--r--modules/core/c++/buffer.hpp17
-rw-r--r--modules/core/c++/common.hpp4
-rw-r--r--modules/io_codec/c++/io_peer.tmpl.hpp6
4 files changed, 60 insertions, 3 deletions
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<uint64_t Len = 8u>
+struct FixedLength {};
+
+template<uint64_t Len = 8u>
+struct VarLength {};
+
+struct NewLine {};
+struct CarriageReturnNewLine {};
+}
+
+template<typename Transport>
+struct transport {
+private:
+ static_assert(always_false<Transport>, "Transport kind not supported.");
+public:
+
+
+template<uint64_t Len>
+struct transport<transport::FixedLength<Len>> {
+private:
+public:
+ error_or<buffer_view> view_slice(const buffer& buff) const {
+ (void) buff;
+ return make_error<err::not_implemented>();
+ }
+
+ error_or<array_buffer> chain_slice(buffer& buff) const {
+ (void) buff;
+ return make_error<err::not_implemented>();
+ }
+};
+}
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<array_buffer> extract_front(uint64_t size) {
+ if(buffer_.empty()){
+ return make_error<err::recoverable>("Chain Array buffer is empty.");
+ }
+
+ auto& arr_front = buffer_.front();
+ if(size != arr_front.size()){
+ return make_error<err::invalid_state>("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 <typename Incoming, typename Outgoing, typename Encoding,
+template <typename Incoming, typename Outgoing, typename TransportEncoding, typename ContentEncoding
typename BufferT>
-streaming_io_peer<Incoming, Outgoing, Encoding,
+streaming_io_peer<Incoming, Outgoing, TransportEncoding, ContentEncoding,
BufferT>::
streaming_io_peer(
own<conveyor_feeder<data<Incoming, Encoding>>> feed,
@@ -10,7 +10,7 @@ streaming_io_peer<Incoming, Outgoing, Encoding,
: streaming_io_peer{std::move(feed), std::move(str), {}, {}, {}, {}} {}
template <typename Incoming, typename Outgoing, typename TransportEncoding, ContentEncoding, typename BufferT>
-streaming_io_peer<Incoming, Outgoing, Encoding,
+streaming_io_peer<Incoming, Outgoing, TransportEncoding, ContentEncoding,
BufferT>::
streaming_io_peer(
own<conveyor_feeder<data<Incoming, Encoding>>> feed,