GridFormat 0.4.0
I/O-Library for grid-like data structures
Loading...
Searching...
No Matches
concepts.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2022-2023 Dennis Gläser <dennis.glaeser@iws.uni-stuttgart.de>
2// SPDX-License-Identifier: MIT
8#ifndef GRIDFORMAT_ENCODING_CONCEPTS_HPP_
9#define GRIDFORMAT_ENCODING_CONCEPTS_HPP_
10
11#include <cstddef>
12#include <istream>
13#include <span>
14
15#include <gridformat/common/concepts.hpp>
16#include <gridformat/common/serialization.hpp>
17
18namespace GridFormat::Concepts {
19
25template<typename T, typename S>
26concept Encoder = requires(const T& encoder, S& stream) {
27 { encoder(stream) } -> WriterFor<std::span<const std::byte>>;
28};
29
34template<typename T>
35concept Decoder = requires(const T& decoder,
36 std::istream& input_stream,
37 std::span<char> characters) {
38 { decoder.decode(characters) } -> std::convertible_to<std::size_t>;
39 { decoder.decode_from(input_stream, std::size_t{}) } -> std::same_as<Serialization>;
40};
41
42} // namespace GridFormat::Concepts
43
44#endif // GRIDFORMAT_ENCODING_CONCEPTS_HPP_
Decoders allow decoding spans of characters or directly from an input stream.
Definition: concepts.hpp:35
Encoders allow wrapping of an output stream, yielding a stream that allows writing spans of data to i...
Definition: concepts.hpp:26