Go to the documentation of this file.
    9 #ifndef EAGINE_SERIALIZE_DATA_SOURCE_HPP 
   10 #define EAGINE_SERIALIZE_DATA_SOURCE_HPP 
   12 #include "../interface.hpp" 
   13 #include "../memory/buffer.hpp" 
   14 #include "../memory/span_algo.hpp" 
   15 #include "../string_span.hpp" 
   16 #include "../valid_if/nonnegative.hpp" 
   17 #include "../valid_if/positive.hpp" 
   42     template <
typename Function>
 
   51         while(
auto blk = 
top(total)) {
 
   53                 return {start + 
extract(found)};
 
   55             if(blk.size() < total) {
 
   77         return scan_until([what](
byte b) { 
return b == what; }, max, step);
 
   96 #endif // EAGINE_SERIALIZE_DATA_SOURCE_HPP 
  
std::ptrdiff_t span_size_t
Signed span size type used by eagine.
Definition: types.hpp:36
Common code is placed in this namespace.
Definition: eagine.hpp:21
static constexpr auto cover(T *addr, S size) noexcept -> span_if_mutable< T >
Creates a span starting at the specified pointer and specified length.
Definition: span.hpp:465
static constexpr auto extract(api_result_value< Result, api_result_validity::never > &) noexcept -> Result &
Overload of extract for api_result_value.
Definition: c_api_wrap.hpp:270
virtual void pop(span_size_t size)=0
Returns the specified amount of data of the top of the source.
Primary template for conditionally valid values.
Definition: decl.hpp:49
static constexpr auto find_element_if(basic_span< T, P, S > spn, F predicate) noexcept -> optionally_valid< S >
Finds the position of the first element satisfying predicate in a span.
Definition: span_algo.hpp:299
Base template for abstract interfaces, implements common functionality.
Definition: interface.hpp:18
auto enlarge_by(span_size_t inc_size) -> auto &
Enlarges the buffer by the specified number of bytes.
Definition: buffer.hpp:139
auto scan_until(Function predicate, const valid_if_positive< span_size_t > &max, const valid_if_positive< span_size_t > &step={256}) -> valid_if_nonnegative< span_size_t >
Returns the position of the first byte where predicate is true.
Definition: data_source.hpp:43
Reallocatable owning byte buffer.
Definition: buffer.hpp:22
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
auto scan_for(byte what, const valid_if_positive< span_size_t > &max, const valid_if_positive< span_size_t > &step={256}) -> valid_if_nonnegative< span_size_t >
Returns the position of the first occurrence of the specified byte.
Definition: data_source.hpp:72
virtual auto top(span_size_t size) -> memory::const_block=0
Returns a block covering the specified amount of data of the top.
auto size() const noexcept -> span_size_t
Returns the size of the buffer in bytes.
Definition: buffer.hpp:81
void fetch_all(memory::buffer &dst, valid_if_positive< span_size_t > step={256})
Fetches all the remaining data into a buffer.
Definition: data_source.hpp:81