8#ifndef GRIDFORMAT_COMMON_ENCODING_RAW_HPP_
9#define GRIDFORMAT_COMMON_ENCODING_RAW_HPP_
14#include <gridformat/common/serialization.hpp>
15#include <gridformat/common/output_stream.hpp>
24 Serialization decode_from(std::istream& stream, std::size_t num_decoded_bytes)
const {
25 Serialization result{num_decoded_bytes};
26 auto chars = result.template as_span_of<char>();
27 stream.read(chars.data(), chars.size());
28 if (stream.gcount() !=
static_cast<std::istream::pos_type
>(chars.size()))
29 throw IOError(
"Could not read the requested number of bytes from input stream");
33 template<std::
size_t s>
34 std::size_t decode(std::span<char, s> chars)
const {
40template<
typename OStream>
42 using Byte = std::byte;
45 : OutputStreamWrapperBase<OStream>(s)
48 template<
typename T, std::
size_t size>
49 void write(std::span<T, size> data) {
50 this->_write_raw(data);
58namespace GridFormat::Encoding {
66 constexpr auto operator()(S& s)
const noexcept {
constexpr RawBinary raw
Instance of the raw binary encoder.
Definition: raw.hpp:72