OpenCBDC Transaction Processor
Loading...
Searching...
No Matches
size_serializer.cpp
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#include "size_serializer.hpp"
7
8namespace cbdc {
9 size_serializer::operator bool() const {
10 return true;
11 }
12
14 m_cursor += len;
15 }
16
18 m_cursor = 0;
19 }
20
21 [[nodiscard]] auto size_serializer::end_of_buffer() const -> bool {
22 return false;
23 }
24
25 auto size_serializer::write(const void* /* data */, size_t len) -> bool {
26 m_cursor += len;
27 return true;
28 }
29
30 auto size_serializer::read(void* /* data */, size_t /* len */) -> bool {
31 return false;
32 }
33
34 [[nodiscard]] auto size_serializer::size() const -> size_t {
35 return m_cursor;
36 }
37}
auto size() const -> size_t
Returns the number of bytes accumulated in the size counter during mock serialization.
auto read(void *data, size_t len) -> bool final
Read is not implemented for size serializer.
auto end_of_buffer() const -> bool final
Size serializer has no underlying buffer so this method always returns false.
void reset() final
Resets the size counter to zero.
void advance_cursor(size_t len) final
Increases the size counter by the given number of bytes.
auto write(const void *data, size_t len) -> bool final
Increases size counter by the given number of bytes.