8#ifndef SEN_CORE_IO_INPUT_STREAM_H
9#define SEN_CORE_IO_INPUT_STREAM_H
38 [[nodiscard]]
const uint8_t*
advance(std::size_t bytes);
39 [[nodiscard]] std::pair<const uint8_t*, std::size_t>
tryAdvance(std::size_t bytes);
40 [[nodiscard]]
bool atEnd() const noexcept {
return cursor_ == buffer_.size(); }
41 [[nodiscard]] std::size_t
getPosition() const noexcept {
return cursor_; }
45 void reverse(std::size_t bytes)
noexcept { cursor_ -= bytes; }
49 std::size_t cursor_ = 0U;
55template <
typename BufferEndian>
81 impl::IfBasic<T, void> readBasic(T& val);
92template <
typename BufferEndian>
95 impl::BoolTransportType tmp;
100template <
typename BufferEndian>
103 constexpr std::size_t size =
sizeof(val);
104 std::memcpy(&val,
advance(size), size);
107template <
typename BufferEndian>
110 constexpr std::size_t size =
sizeof(val);
111 std::memcpy(&val,
advance(size), size);
114template <
typename BufferEndian>
126template <
typename BufferEndian>
144 std::memcpy(val.data(),
advance(size), size);
147template <
typename BufferEndian>
149inline impl::IfBasic<T, void> InputStreamTemplate<BufferEndian>::readBasic(T& val)
151 static_assert(std::is_trivially_copyable_v<T>);
152 constexpr std::size_t size =
sizeof(T);
155 std::memcpy(&val, advance(size), size);
158 ::sen::impl::swapBytesIfNeeded(val, BufferEndian {});
Contiguous view of elements of type T. Inspired by http://www.open-std.org/jtc1/sc22/wg21/docs/papers...
Definition span.h:34
A point in time.
Definition timestamp.h:26
InputStreamTemplate< LittleEndian > InputStream
Definition input_stream.h:84
float float32_t
Definition numbers.h:16
double float64_t
Definition numbers.h:17