AnCH Framework 0.2
Another C++ Hack: C++23 utility libraries
Loading...
Searching...
No Matches
format.hpp
1/*
2 ANCH Framework: ANother C++ Hack is a C++ framework based on C++23 standard
3 Copyright (C) 2026 Vincent Lachenal
4
5 This file is part of ANCH Framework.
6
7 ANCH Framework is free software: you can redistribute it and/or modify
8 it under the terms of the GNU Lesser General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11
12 ANCH Framework is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public License
18 along with ANCH Framework. If not, see <https://www.gnu.org/licenses/>.
19*/
20#pragma once
21
22#include <istream>
23#include <ostream>
24#include <ranges>
25#include <string_view>
26#include <vector>
27
28#include "mapping.hpp"
29
30#include "csv/csv.hpp"
31#include "csv/options.hpp"
32
33namespace anch::csv {
34
46 struct CsvFormat {
47
50
52 static constexpr std::string_view MEDIA_TYPE = "text/csv";
53
59 static const Options& defaultOptions() noexcept;
60
70 template<std::ranges::input_range R>
71 requires anch::Described<std::remove_cvref_t<std::ranges::range_value_t<R>>>
72 static void serialize(const R& values, std::ostream& out, const Options& options);
73
83 template<anch::Described T>
84 static void deserialize(std::vector<T>& values, std::istream& input, const Options& options);
85
86 };
87
88}
89
90namespace anch::csv {
91
92 inline const CsvFormat::Options&
94 static const Options options;
95 return options;
96 }
97
98 template<std::ranges::input_range R>
100 void
101 CsvFormat::serialize(const R& values, std::ostream& out, const Options& options) {
102 anch::csv::serialize(values, out, options);
103 }
104
105 template<anch::Described T>
106 void
107 CsvFormat::deserialize(std::vector<T>& values, std::istream& input, const Options& options) {
108 anch::csv::deserialize(values, input, options);
109 }
110
111}
Type described by an anch::Mapping specialization.
Definition mapping.hpp:66
AnCH CSV library namespace.
void serialize(const R &values, std::ostream &out, const anch::csv::Options &options=anch::csv::Options())
void deserialize(std::vector< T > &values, std::istream &input, const anch::csv::Options &options=anch::csv::Options())
AnCH framework base namespace.
Definition app.hpp:30
CSV format: serialization and deserialization of lists of described objects with options.
Definition format.hpp:46
static const Options & defaultOptions() noexcept
Definition format.hpp:93
static void serialize(const R &values, std::ostream &out, const Options &options)
Definition format.hpp:101
static void deserialize(std::vector< T > &values, std::istream &input, const Options &options)
Definition format.hpp:107
static constexpr std::string_view MEDIA_TYPE
Definition format.hpp:52
anch::csv::Options Options
Definition format.hpp:49
Definition options.hpp:35