OpenCBDC Transaction Processor
Loading...
Searching...
No Matches
istream_serializer.hpp
Go to the documentation of this file.
1// Copyright (c) 2021 MIT Digital Currency Initiative,
2// Federal Reserve Bank of Boston
3// Distributed under the MIT software license, see the accompanying
4// file COPYING or http://www.opensource.org/licenses/mit-license.php.
5
6#ifndef OPENCBDC_TX_SRC_SERIALIZATION_ISTREAM_SERIALIZER_H_
7#define OPENCBDC_TX_SRC_SERIALIZATION_ISTREAM_SERIALIZER_H_
8
10
11#include <istream>
12
13namespace cbdc {
17 public:
20 explicit istream_serializer(std::istream& s);
21
24 [[nodiscard]] auto end_of_buffer() const -> bool final;
25
28 void advance_cursor(size_t len) final;
29
31 void reset() final;
32
35 auto write(const void* data, size_t len) -> bool final;
36
43 auto read(void* data, size_t len) -> bool final;
44
45 private:
46 std::istream& m_str;
47
48 using off_type = std::remove_reference_t<decltype(m_str)>::off_type;
49 };
50}
51
52#endif
Implementation of serializer for reading from a std::istream.
auto read(void *data, size_t len) -> bool final
Attempts to read the given number of bytes from the current position in the stream.
void advance_cursor(size_t len) final
Moves the stream forward without reading from the stream.
auto write(const void *data, size_t len) -> bool final
Not implemented for istream.
istream_serializer(std::istream &s)
Constructor.
void reset() final
Seeks the stream position to the beginning.
auto end_of_buffer() const -> bool final
Indicates whether the serializer has reached the end of the stream.
Implementation of serializer for std::ios.