OGLplus  (0.59.0) a C++ wrapper for rendering APIs

block_source.hpp
Go to the documentation of this file.
1 
9 #ifndef EAGINE_SERIALIZE_BLOCK_SOURCE_HPP
10 #define EAGINE_SERIALIZE_BLOCK_SOURCE_HPP
11 
12 #include "../memory/block.hpp"
13 #include "../memory/span_algo.hpp"
14 #include "data_source.hpp"
15 #include <istream>
16 
17 namespace eagine {
18 //------------------------------------------------------------------------------
24 public:
26  block_data_source() noexcept = default;
27 
30  : _src{src} {}
31 
35  _src = src;
36  _done = 0;
37  }
38 
39  auto top(span_size_t req_size) -> memory::const_block final {
40  return head(skip(_src, _done), req_size);
41  }
42 
43  void pop(span_size_t del_size) final {
44  _done += del_size;
45  }
46 
47  auto remaining() const noexcept -> memory::const_block {
48  return skip(_src, _done);
49  }
50 
51 private:
52  memory::const_block _src{};
53  span_size_t _done{0};
54 };
55 //------------------------------------------------------------------------------
56 } // namespace eagine
57 
58 #endif // EAGINE_SERIALIZE_BLOCK_SOURCE_HPP
block_data_source(memory::const_block src) noexcept
Constructor setting the backing block.
Definition: block_source.hpp:29
std::ptrdiff_t span_size_t
Signed span size type used by eagine.
Definition: types.hpp:36
auto top(span_size_t req_size) -> memory::const_block final
Returns a block covering the specified amount of data of the top.
Definition: block_source.hpp:39
Common code is placed in this namespace.
Definition: eagine.hpp:21
basic_block< true > const_block
Alias for const byte memory span.
Definition: block.hpp:32
Deserialization data source backed by a pre-allocated memory block.
Definition: block_source.hpp:23
static constexpr auto head(basic_span< T, P, S > s, L l) noexcept -> basic_span< T, P, S >
Returns the first l elements from the front of a span.
Definition: span_algo.hpp:99
void pop(span_size_t del_size) final
Returns the specified amount of data of the top of the source.
Definition: block_source.hpp:43
block_data_source() noexcept=default
Default constructor.
Non-owning view of a contiguous range of memory with ValueType elements.
Definition: flatten_fwd.hpp:16
static constexpr auto skip(basic_span< T, P, S > s, L l) noexcept -> basic_span< T, P, S >
Skips a specified count of elements from the front of a span.
Definition: span_algo.hpp:60
Abstract base class for deserialization data sources.
Definition: data_source.hpp:25
void reset(memory::const_block src)
Resets the backing block.
Definition: block_source.hpp:34

Copyright © 2015-2021 Matúš Chochlík.
<chochlik -at -gmail.com>
Documentation generated on Tue Apr 13 2021 by Doxygen (version 1.8.17).