AnCH Framework 0.2
Another C++ Hack: C++23 utility libraries
Loading...
Searching...
No Matches
anch::csv::CsvFormat Struct Reference

CSV format: serialization and deserialization of lists of described objects with options. More...

#include <format.hpp>

Collaboration diagram for anch::csv::CsvFormat:

Public Types

using Options = anch::csv::Options

Static Public Member Functions

static const Options & defaultOptions () noexcept
template<std::ranges::input_range R>
requires anch::Described<std::remove_cvref_t<std::ranges::range_value_t<R>>>
static void serialize (const R &values, std::ostream &out, const Options &options)
template<anch::Described T>
static void deserialize (std::vector< T > &values, std::istream &input, const Options &options)

Static Public Attributes

static constexpr std::string_view MEDIA_TYPE = "text/csv"

Detailed Description

CSV format: serialization and deserialization of lists of described objects with options.

It is the format type used by generic codecs ( anch::codec::FormatCodec , anch-codec): it does not depend on them (its members follow the anch::codec::DataFormat concept). Values are lists of described objects ( anch::Mapping ): one record per object.

Author
Vincent Lachenal
Since
0.3

Member Typedef Documentation

◆ Options

Member Function Documentation

◆ defaultOptions()

const CsvFormat::Options & anch::csv::CsvFormat::defaultOptions ( )
inlinestaticnoexcept

Default options (RFC 4180)

Returns
the default options

◆ deserialize()

template<anch::Described T>
void anch::csv::CsvFormat::deserialize ( std::vector< T > & values,
std::istream & input,
const Options & options )
static

Deserialize objects

Parameters
valuesthe objects (replaced)
inputthe input stream
optionsthe options
Exceptions
CsvErroron invalid CSV, conversion error or constraint violation
Here is the call graph for this function:

◆ serialize()

template<std::ranges::input_range R>
requires anch::Described<std::remove_cvref_t<std::ranges::range_value_t<R>>>
void anch::csv::CsvFormat::serialize ( const R & values,
std::ostream & out,
const Options & options )
static

Serialize objects (header, then one record per object)

Parameters
valuesthe objects
outthe output stream
optionsthe options
Exceptions
CsvErroron constraint violation (with Options::writeCheckConstraints )
Here is the call graph for this function:

Member Data Documentation

◆ MEDIA_TYPE

std::string_view anch::csv::CsvFormat::MEDIA_TYPE = "text/csv"
staticconstexpr

Media type


The documentation for this struct was generated from the following file: