Codec of a data format: media type, options of each side ( FormatPolicy ), serialization and deserialization ( Serializer , Deserializer concepts).
More...
#include <formatCodec.hpp>
|
| using | Options = typename F::Options |
|
| static std::string_view | mediaType () noexcept |
| static Options & | options (anch::codec::Side side) |
template<typename T>
requires anch::codec::FormatSerializer<F, T> |
| static void | serialize (const T &value, std::ostream &out) |
template<typename T>
requires anch::codec::FormatSerializer<F, T> |
| static void | serialize (const T &value, std::ostream &out, anch::codec::Side side) |
template<typename T>
requires anch::codec::FormatDeserializer<F, T> |
| static void | deserialize (T &value, std::istream &input) |
template<typename T>
requires anch::codec::FormatDeserializer<F, T> |
| static void | deserialize (T &value, std::istream &input, anch::codec::Side side) |
Codec of a data format: media type, options of each side ( FormatPolicy ), serialization and deserialization ( Serializer , Deserializer concepts).
Values are handled when the format handles them ( FormatSerializer , FormatDeserializer ): formats constrain their types (described objects for anch-json and anch-csv), so that values described by an external schema (Protobuf messages, Thrift structures) are left to the codecs of their format. Options of each side are shared by the program: a codec plugin instantiates its FormatCodec in its library ( anch::codec::Json is FormatCodec<anch::json::JsonFormat> , anch::codec::Csv is FormatCodec<anch::csv::CsvFormat> ).
- Template Parameters
-
- Author
- Vincent Lachenal
- Since
- 0.3
◆ Options
◆ deserialize() [1/2]
Deserialize value with the format default options
- Parameters
-
| value | the value to fill |
| input | the input stream |
◆ deserialize() [2/2]
Deserialize value with the options of a side
- Parameters
-
| value | the value to fill |
| input | the input stream |
| side | the side |
- Exceptions
-
◆ mediaType()
Media type
- Returns
F::MEDIA_TYPE
◆ options()
Options of a side: copied from F::defaultOptions() on first use, then configured by FormatPolicy . They can be changed at application initialization (they are not protected against concurrent changes).
- Parameters
-
- Returns
- the options of the side
◆ serialize() [1/2]
Serialize value with the format default options
- Parameters
-
| value | the value |
| out | the output stream |
◆ serialize() [2/2]
Serialize value with the options of a side
- Parameters
-
| value | the value |
| out | the output stream |
| side | the side |
The documentation for this struct was generated from the following file: