2020-12-10 19:26:56 +01:00
|
|
|
#pragma once
|
|
|
|
|
2023-08-12 21:15:44 +02:00
|
|
|
// TODO remove or rename
|
|
|
|
#define likely(x) __builtin_expect(!!(x), 1)
|
|
|
|
#define unlikely(x) __builtin_expect(!!(x), 0)
|
|
|
|
|
|
|
|
#define U_IF(OP) if (unlikely(OP))
|
|
|
|
#define L_IF(OP) if (likely(OP))
|
|
|
|
|
2021-02-21 22:22:18 +01:00
|
|
|
#include "common.hpp"
|
2020-12-10 19:26:56 +01:00
|
|
|
#include "converter.hpp"
|
2023-06-29 23:41:03 +02:00
|
|
|
#include "exception.hpp"
|
2020-12-10 19:26:56 +01:00
|
|
|
#include "extract.hpp"
|
|
|
|
#include "restrictions.hpp"
|
2021-01-10 23:51:20 +01:00
|
|
|
#include <cstdlib>
|
2020-12-10 19:26:56 +01:00
|
|
|
#include <cstring>
|
2023-08-14 01:12:15 +02:00
|
|
|
#include <iostream>
|
2020-12-12 23:32:06 +01:00
|
|
|
#include <optional>
|
2020-12-10 19:26:56 +01:00
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
namespace ss {
|
|
|
|
|
2023-06-29 23:41:03 +02:00
|
|
|
template <typename... Options>
|
2020-12-10 19:26:56 +01:00
|
|
|
class parser {
|
2023-06-29 23:41:03 +02:00
|
|
|
constexpr static auto string_error = setup<Options...>::string_error;
|
|
|
|
constexpr static auto throw_on_error = setup<Options...>::throw_on_error;
|
2021-02-13 01:14:25 +01:00
|
|
|
|
2023-06-29 23:41:03 +02:00
|
|
|
using multiline = typename setup<Options...>::multiline;
|
2023-02-12 12:45:49 +01:00
|
|
|
using error_type = std::conditional_t<string_error, std::string, bool>;
|
2021-02-13 01:14:25 +01:00
|
|
|
|
2021-02-21 02:49:23 +01:00
|
|
|
constexpr static bool escaped_multiline_enabled =
|
2023-06-29 23:41:03 +02:00
|
|
|
multiline::enabled && setup<Options...>::escape::enabled;
|
2021-02-21 02:49:23 +01:00
|
|
|
|
|
|
|
constexpr static bool quoted_multiline_enabled =
|
2023-06-29 23:41:03 +02:00
|
|
|
multiline::enabled && setup<Options...>::quote::enabled;
|
2021-02-21 02:49:23 +01:00
|
|
|
|
2023-06-29 23:41:03 +02:00
|
|
|
constexpr static bool ignore_header = setup<Options...>::ignore_header;
|
2022-03-27 21:04:02 +02:00
|
|
|
|
2023-06-29 23:41:03 +02:00
|
|
|
constexpr static bool ignore_empty = setup<Options...>::ignore_empty;
|
2022-03-28 19:11:41 +02:00
|
|
|
|
2020-12-26 00:46:42 +01:00
|
|
|
public:
|
2021-02-07 21:12:13 +01:00
|
|
|
parser(const std::string& file_name,
|
|
|
|
const std::string& delim = ss::default_delimiter)
|
|
|
|
: file_name_{file_name}, reader_{file_name_, delim} {
|
|
|
|
if (reader_.file_) {
|
2023-08-12 21:15:44 +02:00
|
|
|
// read_line();
|
2022-03-27 21:04:02 +02:00
|
|
|
if constexpr (ignore_header) {
|
|
|
|
ignore_next();
|
|
|
|
} else {
|
2023-08-12 21:15:44 +02:00
|
|
|
// TODO handle
|
|
|
|
// raw_header_ = reader_.get_buffer();
|
2022-03-27 21:04:02 +02:00
|
|
|
}
|
2020-12-26 00:46:42 +01:00
|
|
|
} else {
|
2023-08-05 11:45:31 +02:00
|
|
|
handle_error_file_not_open();
|
2023-08-14 01:12:15 +02:00
|
|
|
// TODO set within reader
|
|
|
|
reader_.eof_ = true;
|
2020-12-10 19:26:56 +01:00
|
|
|
}
|
2020-12-26 00:46:42 +01:00
|
|
|
}
|
|
|
|
|
2021-02-07 21:12:13 +01:00
|
|
|
parser(parser&& other) = default;
|
|
|
|
parser& operator=(parser&& other) = default;
|
|
|
|
|
|
|
|
parser() = delete;
|
|
|
|
parser(const parser& other) = delete;
|
|
|
|
parser& operator=(const parser& other) = delete;
|
2020-12-26 00:46:42 +01:00
|
|
|
|
|
|
|
bool valid() const {
|
2021-02-13 01:14:25 +01:00
|
|
|
if constexpr (string_error) {
|
|
|
|
return error_.empty();
|
2023-07-16 20:26:09 +02:00
|
|
|
} else if constexpr (throw_on_error) {
|
|
|
|
return true;
|
2021-02-13 01:14:25 +01:00
|
|
|
} else {
|
|
|
|
return !error_;
|
|
|
|
}
|
2020-12-26 00:46:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
const std::string& error_msg() const {
|
2021-02-14 01:59:06 +01:00
|
|
|
assert_string_error_defined<string_error>();
|
2021-02-13 01:14:25 +01:00
|
|
|
return error_;
|
2020-12-26 00:46:42 +01:00
|
|
|
}
|
|
|
|
|
2022-02-27 19:40:23 +01:00
|
|
|
bool eof() const {
|
2023-08-14 01:12:15 +02:00
|
|
|
return reader_.eof_;
|
2022-02-27 19:40:23 +01:00
|
|
|
}
|
2020-12-26 00:46:42 +01:00
|
|
|
|
2023-08-14 01:12:15 +02:00
|
|
|
// TODO update
|
2022-02-27 19:40:23 +01:00
|
|
|
bool ignore_next() {
|
2023-08-14 01:12:15 +02:00
|
|
|
reader_.read_next();
|
|
|
|
return reader_.eof_;
|
2022-02-27 19:40:23 +01:00
|
|
|
}
|
2020-12-26 00:46:42 +01:00
|
|
|
|
|
|
|
template <typename T, typename... Ts>
|
|
|
|
T get_object() {
|
|
|
|
return to_object<T>(get_next<Ts...>());
|
|
|
|
}
|
|
|
|
|
2022-02-27 19:40:23 +01:00
|
|
|
size_t line() const {
|
2023-08-12 21:15:44 +02:00
|
|
|
return reader_.line_number_;
|
2022-02-27 19:40:23 +01:00
|
|
|
}
|
|
|
|
|
2020-12-26 00:46:42 +01:00
|
|
|
template <typename T, typename... Ts>
|
|
|
|
no_void_validator_tup_t<T, Ts...> get_next() {
|
|
|
|
clear_error();
|
2023-08-13 19:44:52 +02:00
|
|
|
// TODO update
|
|
|
|
reader_.clear_error();
|
2023-07-10 02:39:24 +02:00
|
|
|
|
2023-08-14 01:12:15 +02:00
|
|
|
if (reader_.eof_) {
|
2023-08-05 11:45:31 +02:00
|
|
|
handle_error_eof_reached();
|
2020-12-26 00:46:42 +01:00
|
|
|
return {};
|
2020-12-10 19:26:56 +01:00
|
|
|
}
|
|
|
|
|
2023-08-05 18:11:13 +02:00
|
|
|
if constexpr (throw_on_error) {
|
|
|
|
try {
|
|
|
|
read_line();
|
2023-08-12 21:15:44 +02:00
|
|
|
return reader_.converter_.template convert<T, Ts...>(
|
|
|
|
reader_.split_data_);
|
2023-08-06 14:04:21 +02:00
|
|
|
} catch (const ss::exception& e) {
|
|
|
|
decorate_rethrow(e);
|
2023-08-05 18:11:13 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-08-12 21:15:44 +02:00
|
|
|
read_line();
|
2023-08-13 19:44:52 +02:00
|
|
|
|
|
|
|
// TODO update
|
|
|
|
if (!reader_.valid()) {
|
|
|
|
handle_error_invalid_read();
|
|
|
|
return {};
|
|
|
|
}
|
2023-08-12 21:15:44 +02:00
|
|
|
|
|
|
|
auto value =
|
|
|
|
reader_.converter_.template convert<T, Ts...>(reader_.split_data_);
|
2020-12-12 23:32:06 +01:00
|
|
|
|
2021-02-07 21:12:13 +01:00
|
|
|
if (!reader_.converter_.valid()) {
|
2023-08-05 11:45:31 +02:00
|
|
|
handle_error_invalid_conversion();
|
2020-12-12 23:32:06 +01:00
|
|
|
}
|
|
|
|
|
2020-12-26 00:46:42 +01:00
|
|
|
return value;
|
|
|
|
}
|
2020-12-10 19:26:56 +01:00
|
|
|
|
2022-02-27 19:40:23 +01:00
|
|
|
bool field_exists(const std::string& field) {
|
2023-08-05 13:30:14 +02:00
|
|
|
if (header_.empty()) {
|
|
|
|
split_header_data();
|
|
|
|
}
|
|
|
|
|
2022-03-28 19:30:39 +02:00
|
|
|
return header_index(field).has_value();
|
2022-02-27 19:40:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
template <typename... Ts>
|
|
|
|
void use_fields(const Ts&... fields_args) {
|
2022-03-27 21:04:02 +02:00
|
|
|
if constexpr (ignore_header) {
|
2023-08-05 11:45:31 +02:00
|
|
|
handle_error_header_ignored();
|
2022-03-27 21:04:02 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-08-05 13:30:14 +02:00
|
|
|
if (header_.empty()) {
|
|
|
|
split_header_data();
|
|
|
|
}
|
|
|
|
|
2022-02-27 19:40:23 +01:00
|
|
|
if (!valid()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto fields = std::vector<std::string>{fields_args...};
|
2023-08-04 21:22:23 +02:00
|
|
|
|
|
|
|
if (fields.empty()) {
|
2023-08-05 11:45:31 +02:00
|
|
|
handle_error_empty_mapping();
|
2023-08-04 21:22:23 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-02-27 19:40:23 +01:00
|
|
|
std::vector<size_t> column_mappings;
|
|
|
|
|
|
|
|
for (const auto& field : fields) {
|
|
|
|
if (std::count(fields.begin(), fields.end(), field) != 1) {
|
2023-08-05 11:45:31 +02:00
|
|
|
handle_error_field_used_multiple_times(field);
|
2022-02-27 19:40:23 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto index = header_index(field);
|
|
|
|
|
|
|
|
if (!index) {
|
2023-08-05 11:45:31 +02:00
|
|
|
handle_error_invalid_field(field);
|
2022-02-27 19:40:23 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
column_mappings.push_back(*index);
|
|
|
|
}
|
|
|
|
|
|
|
|
reader_.converter_.set_column_mapping(column_mappings, header_.size());
|
2023-08-04 21:22:23 +02:00
|
|
|
|
2023-08-06 19:56:28 +02:00
|
|
|
if (line() == 1) {
|
2022-02-27 19:40:23 +01:00
|
|
|
ignore_next();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-28 19:22:54 +01:00
|
|
|
////////////////
|
|
|
|
// iterator
|
|
|
|
////////////////
|
|
|
|
|
|
|
|
template <bool get_object, typename T, typename... Ts>
|
|
|
|
struct iterable {
|
|
|
|
struct iterator {
|
2023-02-12 12:45:49 +01:00
|
|
|
using value = std::conditional_t<get_object, T,
|
2023-06-29 23:41:03 +02:00
|
|
|
no_void_validator_tup_t<T, Ts...>>;
|
2021-02-28 19:22:54 +01:00
|
|
|
|
2023-08-06 15:55:23 +02:00
|
|
|
iterator() : parser_{nullptr}, value_{} {
|
2022-02-27 19:40:23 +01:00
|
|
|
}
|
2023-07-13 22:29:49 +02:00
|
|
|
|
2023-08-06 15:55:23 +02:00
|
|
|
iterator(parser<Options...>* parser) : parser_{parser}, value_{} {
|
2022-02-27 19:40:23 +01:00
|
|
|
}
|
2021-02-28 19:22:54 +01:00
|
|
|
|
2023-08-06 15:55:23 +02:00
|
|
|
iterator(const iterator& other) = default;
|
|
|
|
iterator(iterator&& other) = default;
|
|
|
|
|
2022-02-27 19:40:23 +01:00
|
|
|
value& operator*() {
|
|
|
|
return value_;
|
|
|
|
}
|
2023-07-13 22:29:49 +02:00
|
|
|
|
2022-02-27 19:40:23 +01:00
|
|
|
value* operator->() {
|
|
|
|
return &value_;
|
|
|
|
}
|
2021-02-28 19:22:54 +01:00
|
|
|
|
|
|
|
iterator& operator++() {
|
2023-08-06 15:55:23 +02:00
|
|
|
if (!parser_ || parser_->eof()) {
|
2021-02-28 19:22:54 +01:00
|
|
|
parser_ = nullptr;
|
|
|
|
} else {
|
|
|
|
if constexpr (get_object) {
|
|
|
|
value_ =
|
|
|
|
std::move(parser_->template get_object<T, Ts...>());
|
|
|
|
} else {
|
|
|
|
value_ =
|
|
|
|
std::move(parser_->template get_next<T, Ts...>());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2022-02-27 19:40:23 +01:00
|
|
|
iterator& operator++(int) {
|
|
|
|
return ++*this;
|
|
|
|
}
|
2021-02-28 19:22:54 +01:00
|
|
|
|
|
|
|
friend bool operator==(const iterator& lhs, const iterator& rhs) {
|
|
|
|
return (lhs.parser_ == nullptr && rhs.parser_ == nullptr) ||
|
|
|
|
(lhs.parser_ == rhs.parser_ &&
|
|
|
|
&lhs.value_ == &rhs.value_);
|
|
|
|
}
|
|
|
|
|
|
|
|
friend bool operator!=(const iterator& lhs, const iterator& rhs) {
|
|
|
|
return !(lhs == rhs);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2023-06-29 23:41:03 +02:00
|
|
|
parser<Options...>* parser_;
|
2023-08-06 15:55:23 +02:00
|
|
|
value value_;
|
2021-02-28 19:22:54 +01:00
|
|
|
};
|
|
|
|
|
2023-06-29 23:41:03 +02:00
|
|
|
iterable(parser<Options...>* parser) : parser_{parser} {
|
2022-02-27 19:40:23 +01:00
|
|
|
}
|
2021-02-28 19:22:54 +01:00
|
|
|
|
2022-02-27 19:40:23 +01:00
|
|
|
iterator begin() {
|
|
|
|
return ++iterator{parser_};
|
|
|
|
}
|
2023-07-13 22:29:49 +02:00
|
|
|
|
2022-02-27 19:40:23 +01:00
|
|
|
iterator end() {
|
|
|
|
return iterator{};
|
|
|
|
}
|
2021-02-28 19:22:54 +01:00
|
|
|
|
|
|
|
private:
|
2023-06-29 23:41:03 +02:00
|
|
|
parser<Options...>* parser_;
|
2021-02-28 19:22:54 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
template <typename... Ts>
|
|
|
|
auto iterate() {
|
|
|
|
return iterable<false, Ts...>{this};
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename... Ts>
|
|
|
|
auto iterate_object() {
|
|
|
|
return iterable<true, Ts...>{this};
|
|
|
|
}
|
|
|
|
|
2020-12-26 00:46:42 +01:00
|
|
|
////////////////
|
|
|
|
// composite conversion
|
|
|
|
////////////////
|
|
|
|
template <typename... Ts>
|
|
|
|
class composite {
|
|
|
|
public:
|
|
|
|
composite(std::tuple<Ts...>&& values, parser& parser)
|
2022-02-27 19:40:23 +01:00
|
|
|
: values_{std::move(values)}, parser_{parser} {
|
|
|
|
}
|
2020-12-10 19:26:56 +01:00
|
|
|
|
2020-12-26 00:46:42 +01:00
|
|
|
// tries to convert the same line with a different output type
|
|
|
|
// only if the previous conversion was not successful,
|
|
|
|
// returns composite containing itself and the new output
|
|
|
|
// as optional, additionally, if a parameter is passed, and
|
|
|
|
// that parameter can be invoked using the converted value,
|
|
|
|
// than it will be invoked in the case of a valid conversion
|
2020-12-26 00:56:39 +01:00
|
|
|
template <typename... Us, typename Fun = none>
|
2020-12-26 00:46:42 +01:00
|
|
|
composite<Ts..., std::optional<no_void_validator_tup_t<Us...>>> or_else(
|
2020-12-26 00:56:39 +01:00
|
|
|
Fun&& fun = none{}) {
|
2020-12-26 00:46:42 +01:00
|
|
|
using Value = no_void_validator_tup_t<Us...>;
|
|
|
|
std::optional<Value> value;
|
|
|
|
try_convert_and_invoke<Value, Us...>(value, fun);
|
|
|
|
return composite_with(std::move(value));
|
2020-12-10 19:26:56 +01:00
|
|
|
}
|
|
|
|
|
2020-12-26 00:46:42 +01:00
|
|
|
// same as or_else, but saves the result into a 'U' object
|
|
|
|
// instead of a tuple
|
2020-12-26 00:56:39 +01:00
|
|
|
template <typename U, typename... Us, typename Fun = none>
|
2021-01-02 02:31:45 +01:00
|
|
|
composite<Ts..., std::optional<U>> or_object(Fun&& fun = none{}) {
|
2020-12-26 00:46:42 +01:00
|
|
|
std::optional<U> value;
|
|
|
|
try_convert_and_invoke<U, Us...>(value, fun);
|
|
|
|
return composite_with(std::move(value));
|
2020-12-10 19:26:56 +01:00
|
|
|
}
|
|
|
|
|
2022-02-27 19:40:23 +01:00
|
|
|
std::tuple<Ts...> values() {
|
|
|
|
return values_;
|
|
|
|
}
|
2020-12-10 19:26:56 +01:00
|
|
|
|
2020-12-26 00:46:42 +01:00
|
|
|
template <typename Fun>
|
|
|
|
auto on_error(Fun&& fun) {
|
2023-08-04 16:48:07 +02:00
|
|
|
assert_throw_on_error_not_defined<throw_on_error>();
|
2020-12-26 00:46:42 +01:00
|
|
|
if (!parser_.valid()) {
|
|
|
|
if constexpr (std::is_invocable_v<Fun>) {
|
|
|
|
fun();
|
|
|
|
} else {
|
2021-02-13 01:14:25 +01:00
|
|
|
static_assert(string_error,
|
|
|
|
"to enable error messages within the "
|
|
|
|
"on_error method "
|
|
|
|
"callback string_error needs to be enabled");
|
2020-12-26 00:46:42 +01:00
|
|
|
std::invoke(std::forward<Fun>(fun), parser_.error_msg());
|
2020-12-12 23:32:06 +01:00
|
|
|
}
|
2020-12-26 00:46:42 +01:00
|
|
|
}
|
|
|
|
return *this;
|
|
|
|
}
|
2020-12-12 23:32:06 +01:00
|
|
|
|
2020-12-10 19:26:56 +01:00
|
|
|
private:
|
2020-12-26 00:46:42 +01:00
|
|
|
template <typename T>
|
|
|
|
composite<Ts..., T> composite_with(T&& new_value) {
|
|
|
|
auto merged_values =
|
|
|
|
std::tuple_cat(std::move(values_),
|
2021-01-10 23:51:20 +01:00
|
|
|
std::tuple<T>{parser_.valid()
|
2021-01-17 21:46:36 +01:00
|
|
|
? std::forward<T>(new_value)
|
|
|
|
: std::nullopt});
|
2020-12-26 00:46:42 +01:00
|
|
|
return {std::move(merged_values), parser_};
|
2020-12-15 22:32:34 +01:00
|
|
|
}
|
|
|
|
|
2020-12-26 00:56:39 +01:00
|
|
|
template <typename U, typename... Us, typename Fun = none>
|
2020-12-26 00:46:42 +01:00
|
|
|
void try_convert_and_invoke(std::optional<U>& value, Fun&& fun) {
|
|
|
|
if (!parser_.valid()) {
|
|
|
|
auto tuple_output = try_same<Us...>();
|
2021-01-03 17:27:21 +01:00
|
|
|
if (!parser_.valid()) {
|
|
|
|
return;
|
|
|
|
}
|
2021-02-14 01:59:06 +01:00
|
|
|
|
2020-12-26 00:46:42 +01:00
|
|
|
if constexpr (!std::is_same_v<U, decltype(tuple_output)>) {
|
2021-01-03 17:27:21 +01:00
|
|
|
value = to_object<U>(std::move(tuple_output));
|
2020-12-26 00:46:42 +01:00
|
|
|
} else {
|
2021-01-03 17:27:21 +01:00
|
|
|
value = std::move(tuple_output);
|
2020-12-26 00:46:42 +01:00
|
|
|
}
|
2021-02-14 01:59:06 +01:00
|
|
|
|
2021-01-03 17:27:21 +01:00
|
|
|
parser_.try_invoke(*value, std::forward<Fun>(fun));
|
2020-12-26 00:46:42 +01:00
|
|
|
}
|
2020-12-15 22:32:34 +01:00
|
|
|
}
|
|
|
|
|
2020-12-26 00:46:42 +01:00
|
|
|
template <typename U, typename... Us>
|
|
|
|
no_void_validator_tup_t<U, Us...> try_same() {
|
|
|
|
parser_.clear_error();
|
2023-08-13 11:36:56 +02:00
|
|
|
auto value = parser_.reader_.converter_.template convert<U, Us...>(
|
|
|
|
parser_.reader_.split_data_);
|
2021-02-07 21:12:13 +01:00
|
|
|
if (!parser_.reader_.converter_.valid()) {
|
2023-08-05 11:45:31 +02:00
|
|
|
parser_.handle_error_invalid_conversion();
|
2020-12-26 00:46:42 +01:00
|
|
|
}
|
|
|
|
return value;
|
|
|
|
}
|
2020-12-10 19:26:56 +01:00
|
|
|
|
2021-02-14 01:59:06 +01:00
|
|
|
////////////////
|
|
|
|
// members
|
|
|
|
////////////////
|
|
|
|
|
2020-12-26 00:46:42 +01:00
|
|
|
std::tuple<Ts...> values_;
|
|
|
|
parser& parser_;
|
|
|
|
};
|
|
|
|
|
|
|
|
// tries to convert a line and returns a composite which is
|
|
|
|
// able to try additional conversions in case of failure
|
2020-12-26 00:56:39 +01:00
|
|
|
template <typename... Ts, typename Fun = none>
|
2020-12-26 00:46:42 +01:00
|
|
|
composite<std::optional<no_void_validator_tup_t<Ts...>>> try_next(
|
2020-12-26 00:56:39 +01:00
|
|
|
Fun&& fun = none{}) {
|
2023-08-04 16:48:07 +02:00
|
|
|
assert_throw_on_error_not_defined<throw_on_error>();
|
2021-01-03 17:27:21 +01:00
|
|
|
using Ret = no_void_validator_tup_t<Ts...>;
|
|
|
|
return try_invoke_and_make_composite<
|
|
|
|
std::optional<Ret>>(get_next<Ts...>(), std::forward<Fun>(fun));
|
2021-01-19 20:26:36 +01:00
|
|
|
}
|
2020-12-26 00:46:42 +01:00
|
|
|
|
2021-01-01 23:52:14 +01:00
|
|
|
// identical to try_next but returns composite with object instead of a
|
|
|
|
// tuple
|
|
|
|
template <typename T, typename... Ts, typename Fun = none>
|
|
|
|
composite<std::optional<T>> try_object(Fun&& fun = none{}) {
|
2023-08-04 16:48:07 +02:00
|
|
|
assert_throw_on_error_not_defined<throw_on_error>();
|
2021-01-03 17:27:21 +01:00
|
|
|
return try_invoke_and_make_composite<
|
|
|
|
std::optional<T>>(get_object<T, Ts...>(), std::forward<Fun>(fun));
|
2021-01-19 20:26:36 +01:00
|
|
|
}
|
2021-01-01 23:52:14 +01:00
|
|
|
|
2020-12-26 00:46:42 +01:00
|
|
|
private:
|
|
|
|
// tries to invoke the given function (see below), if the function
|
|
|
|
// returns a value which can be used as a conditional, and it returns
|
|
|
|
// false, the function sets an error, and allows the invoke of the
|
|
|
|
// next possible conversion as if the validation of the current one
|
|
|
|
// failed
|
2020-12-26 00:56:39 +01:00
|
|
|
template <typename Arg, typename Fun = none>
|
2020-12-26 00:46:42 +01:00
|
|
|
void try_invoke(Arg&& arg, Fun&& fun) {
|
2020-12-26 00:56:39 +01:00
|
|
|
constexpr bool is_none = std::is_same_v<std::decay_t<Fun>, none>;
|
2020-12-26 00:46:42 +01:00
|
|
|
if constexpr (!is_none) {
|
|
|
|
using Ret = decltype(try_invoke_impl(arg, std::forward<Fun>(fun)));
|
|
|
|
constexpr bool returns_void = std::is_same_v<Ret, void>;
|
|
|
|
if constexpr (!returns_void) {
|
|
|
|
if (!try_invoke_impl(arg, std::forward<Fun>(fun))) {
|
2023-08-05 11:45:31 +02:00
|
|
|
handle_error_failed_check();
|
2020-12-10 19:26:56 +01:00
|
|
|
}
|
2020-12-26 00:46:42 +01:00
|
|
|
} else {
|
|
|
|
try_invoke_impl(arg, std::forward<Fun>(fun));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-12-26 00:56:39 +01:00
|
|
|
// tries to invoke the function if not none
|
2020-12-26 00:46:42 +01:00
|
|
|
// it first tries to invoke the function without arguments,
|
|
|
|
// than with one argument if the function accepts the whole tuple
|
|
|
|
// as an argument, and finally tries to invoke it with the tuple
|
|
|
|
// laid out as a parameter pack
|
2020-12-26 00:56:39 +01:00
|
|
|
template <typename Arg, typename Fun = none>
|
2020-12-26 00:46:42 +01:00
|
|
|
auto try_invoke_impl(Arg&& arg, Fun&& fun) {
|
2020-12-26 00:56:39 +01:00
|
|
|
constexpr bool is_none = std::is_same_v<std::decay_t<Fun>, none>;
|
2020-12-26 00:46:42 +01:00
|
|
|
if constexpr (!is_none) {
|
|
|
|
if constexpr (std::is_invocable_v<Fun>) {
|
|
|
|
return fun();
|
|
|
|
} else if constexpr (std::is_invocable_v<Fun, Arg>) {
|
|
|
|
return std::invoke(std::forward<Fun>(fun),
|
|
|
|
std::forward<Arg>(arg));
|
|
|
|
} else {
|
|
|
|
return std::apply(std::forward<Fun>(fun),
|
|
|
|
std::forward<Arg>(arg));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-12-10 19:26:56 +01:00
|
|
|
|
2021-01-03 17:27:21 +01:00
|
|
|
template <typename T, typename Fun = none>
|
|
|
|
composite<T> try_invoke_and_make_composite(T&& value, Fun&& fun) {
|
|
|
|
if (valid()) {
|
|
|
|
try_invoke(*value, std::forward<Fun>(fun));
|
|
|
|
}
|
|
|
|
return {valid() ? std::move(value) : std::nullopt, *this};
|
|
|
|
}
|
|
|
|
|
2022-02-27 19:40:23 +01:00
|
|
|
////////////////
|
|
|
|
// header
|
|
|
|
////////////////
|
|
|
|
|
2023-08-05 13:30:14 +02:00
|
|
|
void split_header_data() {
|
|
|
|
ss::splitter<Options...> splitter;
|
|
|
|
std::string raw_header_copy = raw_header_;
|
|
|
|
splitter.split(raw_header_copy.data(), reader_.delim_);
|
|
|
|
for (const auto& [begin, end] : splitter.split_data_) {
|
2023-08-06 15:55:23 +02:00
|
|
|
std::string field{begin, end};
|
|
|
|
if (std::find(header_.begin(), header_.end(), field) !=
|
|
|
|
header_.end()) {
|
|
|
|
handle_error_invalid_header(field);
|
|
|
|
header_.clear();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
header_.push_back(std::move(field));
|
2023-08-05 13:30:14 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-27 19:40:23 +01:00
|
|
|
std::optional<size_t> header_index(const std::string& field) {
|
|
|
|
auto it = std::find(header_.begin(), header_.end(), field);
|
|
|
|
|
|
|
|
if (it == header_.end()) {
|
|
|
|
return std::nullopt;
|
|
|
|
}
|
|
|
|
|
|
|
|
return std::distance(header_.begin(), it);
|
|
|
|
}
|
|
|
|
|
2020-12-26 00:46:42 +01:00
|
|
|
////////////////
|
2021-02-07 21:12:13 +01:00
|
|
|
// error
|
2020-12-26 00:46:42 +01:00
|
|
|
////////////////
|
2020-12-11 18:14:06 +01:00
|
|
|
|
2021-02-07 21:12:13 +01:00
|
|
|
void clear_error() {
|
2021-02-13 01:14:25 +01:00
|
|
|
if constexpr (string_error) {
|
|
|
|
error_.clear();
|
|
|
|
} else {
|
|
|
|
error_ = false;
|
|
|
|
}
|
2021-02-07 21:12:13 +01:00
|
|
|
}
|
2021-01-10 23:51:20 +01:00
|
|
|
|
2023-08-05 11:45:31 +02:00
|
|
|
void handle_error_failed_check() {
|
2023-07-10 02:39:24 +02:00
|
|
|
constexpr static auto error_msg = " failed check";
|
|
|
|
|
2021-02-13 01:14:25 +01:00
|
|
|
if constexpr (string_error) {
|
2023-08-05 11:45:31 +02:00
|
|
|
error_.clear();
|
2023-07-10 02:39:24 +02:00
|
|
|
error_.append(file_name_).append(error_msg);
|
|
|
|
} else if constexpr (throw_on_error) {
|
|
|
|
throw ss::exception{file_name_ + error_msg};
|
2021-02-07 21:12:13 +01:00
|
|
|
} else {
|
2021-02-13 01:14:25 +01:00
|
|
|
error_ = true;
|
2021-02-07 21:12:13 +01:00
|
|
|
}
|
|
|
|
}
|
2020-12-10 19:26:56 +01:00
|
|
|
|
2023-08-05 11:45:31 +02:00
|
|
|
void handle_error_file_not_open() {
|
2023-07-10 02:39:24 +02:00
|
|
|
constexpr static auto error_msg = " could not be opened";
|
|
|
|
|
2021-02-13 01:14:25 +01:00
|
|
|
if constexpr (string_error) {
|
2023-08-05 11:45:31 +02:00
|
|
|
error_.clear();
|
2023-07-30 22:59:37 +02:00
|
|
|
error_.append(file_name_).append(error_msg);
|
2023-07-10 02:39:24 +02:00
|
|
|
} else if constexpr (throw_on_error) {
|
|
|
|
throw ss::exception{file_name_ + error_msg};
|
2021-02-13 01:14:25 +01:00
|
|
|
} else {
|
|
|
|
error_ = true;
|
|
|
|
}
|
2021-02-07 21:12:13 +01:00
|
|
|
}
|
2021-01-31 23:08:46 +01:00
|
|
|
|
2023-08-05 11:45:31 +02:00
|
|
|
void handle_error_eof_reached() {
|
2023-07-30 22:59:37 +02:00
|
|
|
constexpr static auto error_msg = " read on end of file";
|
2023-07-10 02:39:24 +02:00
|
|
|
|
2021-02-13 01:14:25 +01:00
|
|
|
if constexpr (string_error) {
|
2023-08-05 11:45:31 +02:00
|
|
|
error_.clear();
|
2023-07-30 22:59:37 +02:00
|
|
|
error_.append(file_name_).append(error_msg);
|
2023-07-10 02:39:24 +02:00
|
|
|
} else if constexpr (throw_on_error) {
|
|
|
|
throw ss::exception{file_name_ + error_msg};
|
2021-02-07 21:12:13 +01:00
|
|
|
} else {
|
2021-02-13 01:14:25 +01:00
|
|
|
error_ = true;
|
2021-01-31 23:08:46 +01:00
|
|
|
}
|
2021-02-07 21:12:13 +01:00
|
|
|
}
|
2021-01-31 23:08:46 +01:00
|
|
|
|
2023-08-05 11:45:31 +02:00
|
|
|
void handle_error_invalid_conversion() {
|
2021-02-13 01:14:25 +01:00
|
|
|
if constexpr (string_error) {
|
2023-08-05 11:45:31 +02:00
|
|
|
error_.clear();
|
2021-02-13 01:14:25 +01:00
|
|
|
error_.append(file_name_)
|
2021-02-07 21:12:13 +01:00
|
|
|
.append(" ")
|
2021-02-27 20:18:38 +01:00
|
|
|
.append(std::to_string(reader_.line_number_))
|
2021-02-07 21:12:13 +01:00
|
|
|
.append(": ")
|
2023-08-04 21:22:23 +02:00
|
|
|
.append(reader_.converter_.error_msg());
|
2023-07-10 02:39:24 +02:00
|
|
|
} else if constexpr (!throw_on_error) {
|
2021-02-13 01:14:25 +01:00
|
|
|
error_ = true;
|
2021-01-31 23:08:46 +01:00
|
|
|
}
|
2021-02-07 21:12:13 +01:00
|
|
|
}
|
2021-01-31 23:08:46 +01:00
|
|
|
|
2023-08-13 19:44:52 +02:00
|
|
|
void handle_error_invalid_read() {
|
|
|
|
if constexpr (string_error) {
|
|
|
|
error_.clear();
|
|
|
|
error_.append(file_name_)
|
|
|
|
.append(" ")
|
|
|
|
.append(std::to_string(reader_.line_number_))
|
|
|
|
.append(": ")
|
|
|
|
.append(reader_.error_msg());
|
|
|
|
} else if constexpr (!throw_on_error) {
|
|
|
|
error_ = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-08-05 11:45:31 +02:00
|
|
|
void handle_error_header_ignored() {
|
2023-07-10 02:39:24 +02:00
|
|
|
constexpr static auto error_msg =
|
2023-08-05 13:30:14 +02:00
|
|
|
": the header row is ignored within the setup it cannot be used";
|
2023-07-10 02:39:24 +02:00
|
|
|
|
2022-03-27 21:04:02 +02:00
|
|
|
if constexpr (string_error) {
|
2023-08-05 11:45:31 +02:00
|
|
|
error_.clear();
|
2023-07-10 02:39:24 +02:00
|
|
|
error_.append(file_name_).append(error_msg);
|
|
|
|
} else if constexpr (throw_on_error) {
|
|
|
|
throw ss::exception{file_name_ + error_msg};
|
2022-03-27 21:04:02 +02:00
|
|
|
} else {
|
|
|
|
error_ = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-08-05 11:45:31 +02:00
|
|
|
void handle_error_invalid_field(const std::string& field) {
|
2023-07-10 02:39:24 +02:00
|
|
|
constexpr static auto error_msg =
|
|
|
|
": header does not contain given field: ";
|
|
|
|
|
2022-02-27 19:40:23 +01:00
|
|
|
if constexpr (string_error) {
|
2023-08-05 11:45:31 +02:00
|
|
|
error_.clear();
|
2023-07-10 02:39:24 +02:00
|
|
|
error_.append(file_name_).append(error_msg).append(field);
|
|
|
|
} else if constexpr (throw_on_error) {
|
|
|
|
throw ss::exception{file_name_ + error_msg + field};
|
2022-02-27 19:40:23 +01:00
|
|
|
} else {
|
|
|
|
error_ = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-08-05 11:45:31 +02:00
|
|
|
void handle_error_field_used_multiple_times(const std::string& field) {
|
2023-07-10 02:39:24 +02:00
|
|
|
constexpr static auto error_msg = ": given field used multiple times: ";
|
|
|
|
|
2022-02-27 19:40:23 +01:00
|
|
|
if constexpr (string_error) {
|
2023-08-05 11:45:31 +02:00
|
|
|
error_.clear();
|
2023-07-10 02:39:24 +02:00
|
|
|
error_.append(file_name_).append(error_msg).append(field);
|
|
|
|
} else if constexpr (throw_on_error) {
|
|
|
|
throw ss::exception{file_name_ + error_msg + field};
|
2022-02-27 19:40:23 +01:00
|
|
|
} else {
|
|
|
|
error_ = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-08-05 11:45:31 +02:00
|
|
|
void handle_error_empty_mapping() {
|
2023-08-04 21:22:23 +02:00
|
|
|
constexpr static auto error_msg = "received empty mapping";
|
|
|
|
|
|
|
|
if constexpr (string_error) {
|
|
|
|
error_.clear();
|
|
|
|
error_.append(error_msg);
|
|
|
|
} else if constexpr (throw_on_error) {
|
|
|
|
throw ss::exception{error_msg};
|
|
|
|
} else {
|
|
|
|
error_ = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-08-06 15:55:23 +02:00
|
|
|
void handle_error_invalid_header(const std::string& field) {
|
|
|
|
constexpr static auto error_msg = "header contains duplicates: ";
|
|
|
|
|
|
|
|
if constexpr (string_error) {
|
|
|
|
error_.clear();
|
|
|
|
error_.append(error_msg).append(error_msg);
|
|
|
|
} else if constexpr (throw_on_error) {
|
|
|
|
throw ss::exception{error_msg + field};
|
|
|
|
} else {
|
|
|
|
error_ = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-08-06 14:04:21 +02:00
|
|
|
void decorate_rethrow(const ss::exception& e) const {
|
|
|
|
static_assert(throw_on_error,
|
|
|
|
"throw_on_error needs to be enabled to use this method");
|
2023-08-06 19:56:28 +02:00
|
|
|
throw ss::exception{std::string{file_name_}
|
|
|
|
.append(" ")
|
|
|
|
.append(std::to_string(line()))
|
|
|
|
.append(": ")
|
|
|
|
.append(e.what())};
|
2023-08-06 14:04:21 +02:00
|
|
|
}
|
|
|
|
|
2021-02-07 21:12:13 +01:00
|
|
|
////////////////
|
|
|
|
// line reading
|
|
|
|
////////////////
|
2021-01-31 23:08:46 +01:00
|
|
|
|
2022-02-27 19:40:23 +01:00
|
|
|
void read_line() {
|
2023-08-14 01:12:15 +02:00
|
|
|
reader_.read_next();
|
2022-02-27 19:40:23 +01:00
|
|
|
}
|
2021-01-31 23:08:46 +01:00
|
|
|
|
2023-08-12 21:15:44 +02:00
|
|
|
////////////////
|
|
|
|
// new reader
|
|
|
|
////////////////
|
2021-02-07 21:29:12 +01:00
|
|
|
struct reader {
|
2023-08-12 21:15:44 +02:00
|
|
|
reader(const reader& other) = delete;
|
|
|
|
reader& operator=(const reader& other) = delete;
|
2021-01-31 23:08:46 +01:00
|
|
|
|
2023-08-12 21:15:44 +02:00
|
|
|
// TODO update
|
2021-02-07 21:12:13 +01:00
|
|
|
reader(reader&& other)
|
2023-08-12 21:15:44 +02:00
|
|
|
: delim_{std::move(other.delim_)}, file_{other.file_},
|
|
|
|
converter_{std::move(other.converter_)}, buff_{other.buff_},
|
|
|
|
line_number_{other.line_number_}, buff_size_{other.buff_size_},
|
|
|
|
buff_filled_{other.buff_filled_},
|
|
|
|
buff_processed_{other.buff_processed_},
|
|
|
|
delim_char_{other.delim_char_}, begin_{other.begin_},
|
|
|
|
curr_{other.curr_}, end_{other.end_},
|
|
|
|
last_read_{other.last_read_}, split_data_{
|
|
|
|
std::move(other.split_data_)} {
|
2021-02-07 21:12:13 +01:00
|
|
|
other.file_ = nullptr;
|
2023-08-12 21:15:44 +02:00
|
|
|
other.buff_ = nullptr;
|
2021-01-31 23:08:46 +01:00
|
|
|
}
|
|
|
|
|
2021-02-07 21:12:13 +01:00
|
|
|
reader& operator=(reader&& other) {
|
|
|
|
if (this != &other) {
|
|
|
|
delim_ = std::move(other.delim_);
|
|
|
|
file_ = other.file_;
|
2023-08-12 21:15:44 +02:00
|
|
|
converter_ = std::move(other.converter_);
|
|
|
|
buff_ = other.buff_;
|
2021-02-27 20:18:38 +01:00
|
|
|
line_number_ = other.line_number_;
|
2023-08-12 21:15:44 +02:00
|
|
|
buff_filled_ = other.buff_filled_;
|
|
|
|
buff_size_ = other.buff_size_;
|
|
|
|
buff_processed_ = other.buff_processed_;
|
|
|
|
delim_char_ = other.delim_char_;
|
|
|
|
begin_ = other.begin_;
|
|
|
|
curr_ = other.curr_;
|
|
|
|
end_ = other.end_;
|
|
|
|
last_read_ = other.last_read_;
|
|
|
|
split_data_ = std::move(other.split_data_);
|
2021-02-07 21:12:13 +01:00
|
|
|
|
|
|
|
other.file_ = nullptr;
|
2023-08-12 21:15:44 +02:00
|
|
|
other.buff_ = nullptr;
|
2021-01-31 23:08:46 +01:00
|
|
|
}
|
2021-02-07 21:12:13 +01:00
|
|
|
return *this;
|
2021-01-10 23:51:20 +01:00
|
|
|
}
|
|
|
|
|
2023-08-12 21:15:44 +02:00
|
|
|
reader(const std::string& file_name, const std::string& delim)
|
|
|
|
: delim_{delim} {
|
2021-02-07 21:12:13 +01:00
|
|
|
|
2023-08-12 21:15:44 +02:00
|
|
|
// TODO update
|
|
|
|
delim_char_ = delim_.at(0);
|
2020-12-11 18:14:06 +01:00
|
|
|
|
2023-08-12 21:15:44 +02:00
|
|
|
// TODO check file
|
|
|
|
file_ = std::fopen(file_name.c_str(), "rb");
|
2021-02-07 21:12:13 +01:00
|
|
|
|
2023-08-12 21:15:44 +02:00
|
|
|
if (!file_) {
|
|
|
|
return;
|
|
|
|
}
|
2022-03-28 19:11:41 +02:00
|
|
|
|
2023-08-12 21:15:44 +02:00
|
|
|
// TODO check buff_
|
|
|
|
buff_ = static_cast<char*>(std::malloc(buff_size_));
|
2022-03-28 19:11:41 +02:00
|
|
|
|
2023-08-12 21:15:44 +02:00
|
|
|
// TODO check buff_filled
|
|
|
|
buff_filled_ = std::fread(buff_, 1, buff_size_, file_);
|
2022-03-28 19:11:41 +02:00
|
|
|
|
2023-08-12 21:15:44 +02:00
|
|
|
if (buff_filled_ != buff_size_) {
|
|
|
|
last_read_ = true;
|
2020-12-26 00:46:42 +01:00
|
|
|
}
|
2020-12-12 23:32:06 +01:00
|
|
|
|
2023-08-12 21:15:44 +02:00
|
|
|
// TODO handle differently
|
|
|
|
if (buff_filled_ == 0 || (buff_filled_ == 1 && buff_[0] == '\n') ||
|
|
|
|
(buff_filled_ == 2 && buff_[0] == '\r' && buff_[1] == '\n')) {
|
2023-08-13 11:36:56 +02:00
|
|
|
fclose(file_);
|
2023-08-12 21:15:44 +02:00
|
|
|
file_ = nullptr;
|
|
|
|
}
|
2023-07-10 02:39:24 +02:00
|
|
|
|
2023-08-12 21:15:44 +02:00
|
|
|
begin_ = buff_;
|
|
|
|
curr_ = buff_;
|
2023-08-13 11:36:56 +02:00
|
|
|
shifted_curr_ = buff_;
|
2023-08-12 21:15:44 +02:00
|
|
|
end_ = buff_ + buff_filled_;
|
|
|
|
}
|
2021-01-31 23:08:46 +01:00
|
|
|
|
2023-08-12 21:15:44 +02:00
|
|
|
~reader() {
|
|
|
|
free(buff_);
|
2023-07-10 02:39:24 +02:00
|
|
|
|
2023-08-12 21:15:44 +02:00
|
|
|
if (file_) {
|
|
|
|
fclose(file_);
|
2020-12-26 00:46:42 +01:00
|
|
|
}
|
2023-08-12 21:15:44 +02:00
|
|
|
}
|
2020-12-10 19:26:56 +01:00
|
|
|
|
2023-08-12 21:15:44 +02:00
|
|
|
void shift_read_next() {
|
|
|
|
buff_filled_ -= buff_processed_;
|
2021-01-10 23:51:20 +01:00
|
|
|
|
2023-08-12 21:15:44 +02:00
|
|
|
// shift back data that is not processed
|
|
|
|
memcpy(buff_, buff_ + buff_processed_, buff_filled_);
|
2023-07-31 21:49:01 +02:00
|
|
|
|
2023-08-12 21:15:44 +02:00
|
|
|
// read data to fill the rest of the buffer
|
|
|
|
buff_filled_ +=
|
|
|
|
fread(buff_ + buff_filled_, 1, buff_processed_, file_);
|
|
|
|
}
|
2023-07-10 02:39:24 +02:00
|
|
|
|
2023-08-12 21:15:44 +02:00
|
|
|
void handle_buffer_end_reached() {
|
|
|
|
buff_size_ *= 8;
|
|
|
|
|
|
|
|
// TODO handle NULL
|
|
|
|
buff_ = static_cast<char*>(std::realloc(buff_, buff_size_));
|
|
|
|
|
|
|
|
// fill the rest of the buffer
|
|
|
|
buff_filled_ += fread(buff_ + buff_filled_, 1,
|
|
|
|
buff_size_ - buff_filled_, file_);
|
|
|
|
|
|
|
|
if (buff_filled_ != buff_size_) {
|
|
|
|
last_read_ = true;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2023-08-13 11:36:56 +02:00
|
|
|
// TODO move
|
|
|
|
using quote = typename setup<Options...>::quote;
|
|
|
|
using trim_left = typename setup<Options...>::trim_left;
|
|
|
|
using trim_right = typename setup<Options...>::trim_right;
|
|
|
|
using escape = typename setup<Options...>::escape;
|
|
|
|
using multiline = typename setup<Options...>::multiline;
|
2021-02-21 02:49:23 +01:00
|
|
|
|
2023-08-13 11:36:56 +02:00
|
|
|
constexpr static auto is_const_line =
|
|
|
|
!quote::enabled && !escape::enabled;
|
|
|
|
using line_ptr_type =
|
|
|
|
std::conditional_t<is_const_line, const char*, char*>;
|
2021-02-21 02:49:23 +01:00
|
|
|
|
2023-08-13 19:44:52 +02:00
|
|
|
using error_type = std::conditional_t<string_error, std::string, bool>;
|
|
|
|
|
|
|
|
bool valid() const {
|
|
|
|
if constexpr (string_error) {
|
|
|
|
return error_.empty();
|
|
|
|
} else if constexpr (throw_on_error) {
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return !error_;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const std::string& error_msg() const {
|
|
|
|
assert_string_error_defined<string_error>();
|
|
|
|
return error_;
|
|
|
|
}
|
|
|
|
|
|
|
|
void clear_error() {
|
|
|
|
if constexpr (string_error) {
|
|
|
|
error_.clear();
|
|
|
|
} else if constexpr (!throw_on_error) {
|
|
|
|
error_ = false;
|
|
|
|
}
|
|
|
|
unterminated_quote_ = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void handle_error_mismatched_quote() {
|
|
|
|
constexpr static auto error_msg = "mismatched quote";
|
|
|
|
|
|
|
|
if constexpr (string_error) {
|
|
|
|
error_.clear();
|
|
|
|
error_.append(error_msg);
|
|
|
|
} else if constexpr (throw_on_error) {
|
|
|
|
throw ss::exception{error_msg};
|
|
|
|
} else {
|
|
|
|
error_ = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-08-13 11:36:56 +02:00
|
|
|
bool match(const char* const curr, char delim) {
|
|
|
|
return *curr == delim;
|
|
|
|
};
|
|
|
|
|
|
|
|
// todo test for huge delimiters
|
|
|
|
bool match(const char* const curr, const std::string& delim) {
|
|
|
|
return strncmp(curr, delim.c_str(), delim.size()) == 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
size_t delimiter_size(char) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t delimiter_size(const std::string& delim) {
|
|
|
|
return delim.size();
|
|
|
|
}
|
|
|
|
|
|
|
|
void trim_left_if_enabled(line_ptr_type& curr) {
|
|
|
|
if constexpr (trim_left::enabled) {
|
|
|
|
while (trim_left::match(*curr)) {
|
|
|
|
++curr;
|
2021-01-31 23:08:46 +01:00
|
|
|
}
|
|
|
|
}
|
2023-08-13 11:36:56 +02:00
|
|
|
}
|
2020-12-10 19:26:56 +01:00
|
|
|
|
2023-08-13 11:36:56 +02:00
|
|
|
void trim_right_if_enabled(line_ptr_type& curr) {
|
|
|
|
if constexpr (trim_right::enabled) {
|
|
|
|
while (trim_right::match(*curr)) {
|
|
|
|
++curr;
|
2021-02-20 15:53:18 +01:00
|
|
|
}
|
2023-08-13 11:36:56 +02:00
|
|
|
}
|
|
|
|
}
|
2021-02-20 15:53:18 +01:00
|
|
|
|
2023-08-13 11:36:56 +02:00
|
|
|
// matches delimiter taking spacing into account
|
|
|
|
// returns {spacing + delimiter size, is delimiter}
|
|
|
|
template <typename Delim>
|
|
|
|
std::tuple<size_t, bool> match_delimiter(line_ptr_type begin,
|
|
|
|
const Delim& delim) {
|
|
|
|
line_ptr_type curr = begin;
|
|
|
|
|
|
|
|
trim_right_if_enabled(curr);
|
|
|
|
|
|
|
|
// just spacing
|
|
|
|
// TODO handle \r\n
|
2023-08-13 16:51:31 +02:00
|
|
|
if (*curr == '\n' || *curr == '\r') {
|
2023-08-14 01:12:15 +02:00
|
|
|
++line_number_;
|
2023-08-13 11:36:56 +02:00
|
|
|
return {0, false};
|
|
|
|
}
|
|
|
|
|
|
|
|
// not a delimiter
|
|
|
|
if (!match(curr, delim)) {
|
|
|
|
shift_if_escaped(curr);
|
|
|
|
return {1 + curr - begin, false};
|
|
|
|
}
|
|
|
|
|
|
|
|
curr += delimiter_size(delim);
|
|
|
|
trim_left_if_enabled(curr);
|
|
|
|
|
|
|
|
// delimiter
|
|
|
|
return {curr - begin, true};
|
|
|
|
}
|
|
|
|
|
|
|
|
void shift_if_escaped(line_ptr_type& curr) {
|
|
|
|
if constexpr (escape::enabled) {
|
|
|
|
if (escape::match(*curr)) {
|
2023-08-13 16:51:31 +02:00
|
|
|
// TODO handle differently
|
2023-08-13 11:36:56 +02:00
|
|
|
if (curr[1] == '\0') {
|
|
|
|
if constexpr (!multiline::enabled) {
|
|
|
|
// TODO handle
|
|
|
|
throw "unterminated escape";
|
|
|
|
// handle_error_unterminated_escape();
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
2023-08-14 01:12:15 +02:00
|
|
|
|
|
|
|
if (curr[1] == '\n') {
|
|
|
|
// TODO update
|
|
|
|
++line_number_;
|
|
|
|
if constexpr (multiline::size > 0) {
|
|
|
|
handle_line_increment();
|
|
|
|
if (multiline_limit_reached()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-08-13 11:36:56 +02:00
|
|
|
shift_and_jump_escape();
|
2023-08-12 21:15:44 +02:00
|
|
|
}
|
2023-08-13 11:36:56 +02:00
|
|
|
}
|
|
|
|
}
|
2020-12-26 00:46:42 +01:00
|
|
|
|
2023-08-13 16:51:31 +02:00
|
|
|
void shift_and_set_shifted_current() {
|
2023-08-13 11:36:56 +02:00
|
|
|
if constexpr (!is_const_line) {
|
|
|
|
if (escaped_ > 0) {
|
|
|
|
// shift by number of escapes
|
|
|
|
std::copy_n(shifted_curr_ + escaped_,
|
|
|
|
curr_ - shifted_curr_ - escaped_,
|
|
|
|
shifted_curr_);
|
|
|
|
shifted_curr_ = curr_ - escaped_;
|
|
|
|
return;
|
2023-08-12 21:15:44 +02:00
|
|
|
}
|
2023-08-13 11:36:56 +02:00
|
|
|
}
|
|
|
|
shifted_curr_ = curr_;
|
|
|
|
}
|
2020-12-26 00:46:42 +01:00
|
|
|
|
2023-08-13 11:36:56 +02:00
|
|
|
void shift_and_jump_escape() {
|
2023-08-13 16:51:31 +02:00
|
|
|
if constexpr (!is_const_line && escape::enabled) {
|
|
|
|
if (curr_[1] == '\r' && curr_[2] == '\n') {
|
|
|
|
shift_and_set_shifted_current();
|
|
|
|
++escaped_;
|
|
|
|
++curr_;
|
2023-08-13 19:44:52 +02:00
|
|
|
check_buff_end();
|
2023-08-13 16:51:31 +02:00
|
|
|
shift_and_set_shifted_current();
|
|
|
|
++curr_;
|
2023-08-13 19:44:52 +02:00
|
|
|
check_buff_end();
|
2023-08-13 16:51:31 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
shift_and_set_shifted_current();
|
2023-08-14 01:12:15 +02:00
|
|
|
|
2023-08-13 11:36:56 +02:00
|
|
|
if constexpr (!is_const_line) {
|
|
|
|
++escaped_;
|
|
|
|
}
|
|
|
|
++curr_;
|
|
|
|
}
|
|
|
|
|
|
|
|
void shift_push_and_start_next(size_t n) {
|
|
|
|
shift_and_push();
|
|
|
|
begin_ = curr_ + n;
|
|
|
|
}
|
|
|
|
|
|
|
|
void shift_and_push() {
|
2023-08-13 16:51:31 +02:00
|
|
|
shift_and_set_shifted_current();
|
2023-08-13 11:36:56 +02:00
|
|
|
split_data_.emplace_back(begin_, shifted_curr_);
|
|
|
|
}
|
2020-12-26 00:46:42 +01:00
|
|
|
|
2023-08-13 16:51:31 +02:00
|
|
|
// TODO check attribute
|
|
|
|
__attribute__((always_inline)) void check_buff_end() {
|
2023-08-14 01:12:15 +02:00
|
|
|
if (curr_ >= end_) {
|
2023-08-13 16:51:31 +02:00
|
|
|
auto old_buff = buff_;
|
2023-08-13 11:36:56 +02:00
|
|
|
|
2023-08-13 16:51:31 +02:00
|
|
|
if (last_read_) {
|
|
|
|
// TODO handle
|
|
|
|
throw "no new line at eof";
|
|
|
|
}
|
2021-02-07 21:12:13 +01:00
|
|
|
|
2023-08-13 16:51:31 +02:00
|
|
|
handle_buffer_end_reached();
|
|
|
|
end_ = buff_ + buff_filled_;
|
2023-08-12 21:15:44 +02:00
|
|
|
|
2023-08-13 16:51:31 +02:00
|
|
|
for (auto& [begin, end] : split_data_) {
|
|
|
|
begin = begin - old_buff + buff_;
|
|
|
|
end = end - old_buff + buff_;
|
|
|
|
}
|
2023-08-12 21:15:44 +02:00
|
|
|
|
2023-08-13 16:51:31 +02:00
|
|
|
begin_ = begin_ - old_buff + buff_;
|
|
|
|
curr_ = curr_ - old_buff + buff_;
|
|
|
|
shifted_curr_ = shifted_curr_ - old_buff + buff_;
|
|
|
|
}
|
|
|
|
}
|
2020-12-10 19:26:56 +01:00
|
|
|
|
2023-08-14 01:12:15 +02:00
|
|
|
void handle_error_empty_line() {
|
|
|
|
constexpr static auto error_msg = "line empty";
|
|
|
|
|
|
|
|
if constexpr (string_error) {
|
|
|
|
error_.clear();
|
|
|
|
error_.append(error_msg);
|
|
|
|
} else if constexpr (throw_on_error) {
|
|
|
|
throw ss::exception{error_msg};
|
|
|
|
} else {
|
|
|
|
error_ = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void handle_error_multiline_limit_reached() {
|
|
|
|
constexpr static auto error_msg = "multiline limit reached";
|
|
|
|
|
|
|
|
if constexpr (string_error) {
|
|
|
|
error_.clear();
|
|
|
|
error_.append(error_msg);
|
|
|
|
} else if constexpr (throw_on_error) {
|
|
|
|
throw ss::exception{error_msg};
|
|
|
|
} else {
|
|
|
|
error_ = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void go_to_next_line() {
|
|
|
|
while (*curr_ != '\n') {
|
|
|
|
++curr_;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool multiline_limit_reached() {
|
|
|
|
if constexpr (multiline::size > 0) {
|
|
|
|
if (new_lines_ > multiline::size) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO update name
|
|
|
|
void handle_line_increment() {
|
|
|
|
if constexpr (multiline::size > 0) {
|
|
|
|
new_lines_++;
|
|
|
|
if (new_lines_ > multiline::size) {
|
|
|
|
handle_error_multiline_limit_reached();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-08-13 16:51:31 +02:00
|
|
|
void parse_next_line() {
|
2023-08-14 01:12:15 +02:00
|
|
|
if constexpr (multiline::size > 0) {
|
|
|
|
new_lines_ = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO handle
|
|
|
|
if (*curr_ == '\n') {
|
|
|
|
++line_number_;
|
|
|
|
check_buff_end();
|
|
|
|
handle_error_empty_line();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (*curr_ == '\r' && *(curr_ + 1) == '\n') {
|
|
|
|
++line_number_;
|
|
|
|
++curr_;
|
|
|
|
check_buff_end();
|
|
|
|
handle_error_empty_line();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-08-13 16:51:31 +02:00
|
|
|
while (true) {
|
|
|
|
if constexpr (quote::enabled || escape::enabled) {
|
|
|
|
escaped_ = 0;
|
2023-08-12 21:15:44 +02:00
|
|
|
}
|
2023-08-13 11:36:56 +02:00
|
|
|
|
|
|
|
// quoted string
|
|
|
|
if constexpr (quote::enabled) {
|
|
|
|
if (quote::match(*curr_)) {
|
|
|
|
begin_ = shifted_curr_ = ++curr_;
|
|
|
|
check_buff_end();
|
|
|
|
|
|
|
|
while (true) {
|
|
|
|
// quote not closed
|
|
|
|
if (!quote::match(*curr_)) {
|
|
|
|
// end of line
|
|
|
|
if constexpr (!multiline::enabled) {
|
2023-08-14 01:12:15 +02:00
|
|
|
// TODO update to \r\n
|
2023-08-13 11:36:56 +02:00
|
|
|
if (*curr_ == '\n' || *curr_ == '\r') {
|
2023-08-14 01:12:15 +02:00
|
|
|
++line_number_;
|
2023-08-13 11:36:56 +02:00
|
|
|
throw "unterminated quote";
|
|
|
|
}
|
2023-08-14 01:12:15 +02:00
|
|
|
} else if constexpr (multiline::size > 0) {
|
|
|
|
// TODO update to \r\n
|
|
|
|
if (*curr_ == '\n') {
|
|
|
|
++line_number_;
|
|
|
|
handle_line_increment();
|
|
|
|
if (multiline_limit_reached()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2023-08-13 11:36:56 +02:00
|
|
|
}
|
|
|
|
|
2023-08-13 19:44:52 +02:00
|
|
|
if constexpr (escape::enabled) {
|
|
|
|
if (escape::match(*curr_)) {
|
|
|
|
// TODO update
|
|
|
|
if constexpr (!multiline::enabled) {
|
|
|
|
if (curr_[1] == '\n' ||
|
|
|
|
curr_[1] == '\r') {
|
|
|
|
// eol, unterminated escape
|
|
|
|
// eg: ... "hel\\n
|
2023-08-14 01:12:15 +02:00
|
|
|
++line_number_;
|
2023-08-13 19:44:52 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
throw "unterminated escape";
|
2023-08-14 01:12:15 +02:00
|
|
|
} else if constexpr (multiline::size >
|
|
|
|
0) {
|
|
|
|
if (curr_[1] == '\n' ||
|
|
|
|
(curr_[1] == '\r' &&
|
|
|
|
curr_[2] == '\n')) {
|
|
|
|
++line_number_;
|
|
|
|
handle_line_increment();
|
|
|
|
if (multiline_limit_reached()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2023-08-13 19:44:52 +02:00
|
|
|
}
|
|
|
|
// not eol
|
|
|
|
|
|
|
|
shift_and_jump_escape();
|
|
|
|
check_buff_end();
|
2023-08-14 01:12:15 +02:00
|
|
|
++curr_;
|
2023-08-13 19:44:52 +02:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-08-13 11:36:56 +02:00
|
|
|
++curr_;
|
|
|
|
|
|
|
|
check_buff_end();
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2023-08-13 16:51:31 +02:00
|
|
|
auto [width, is_delim] =
|
2023-08-13 11:36:56 +02:00
|
|
|
match_delimiter(curr_ + 1, delim_char_);
|
2023-08-14 01:12:15 +02:00
|
|
|
if (multiline_limit_reached()) {
|
|
|
|
return;
|
|
|
|
}
|
2023-08-13 11:36:56 +02:00
|
|
|
|
|
|
|
// delimiter
|
2023-08-13 16:51:31 +02:00
|
|
|
if (is_delim) {
|
2023-08-13 11:36:56 +02:00
|
|
|
shift_push_and_start_next(width + 1);
|
|
|
|
curr_ += width + 1;
|
|
|
|
check_buff_end();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// double quote
|
|
|
|
// eg: ...,"hel""lo",... -> hel"lo
|
|
|
|
if (quote::match(*(curr_ + 1))) {
|
|
|
|
shift_and_jump_escape();
|
|
|
|
++curr_;
|
|
|
|
check_buff_end();
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (width == 0) {
|
|
|
|
// eol
|
|
|
|
// eg: ...,"hello" \n -> hello
|
|
|
|
// eg no trim: ...,"hello"\n -> hello
|
|
|
|
shift_and_push();
|
|
|
|
++curr_;
|
|
|
|
// TODO handle differently
|
|
|
|
if (curr_[0] == '\r') {
|
|
|
|
++curr_;
|
|
|
|
}
|
|
|
|
check_buff_end();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// mismatched quote
|
|
|
|
// eg: ...,"hel"lo,... -> error
|
2023-08-14 01:12:15 +02:00
|
|
|
go_to_next_line();
|
2023-08-13 19:44:52 +02:00
|
|
|
|
|
|
|
handle_error_mismatched_quote();
|
|
|
|
return;
|
2023-08-13 11:36:56 +02:00
|
|
|
}
|
2023-08-14 01:12:15 +02:00
|
|
|
continue;
|
2023-08-13 11:36:56 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// not quoted
|
2023-08-13 16:51:31 +02:00
|
|
|
begin_ = shifted_curr_ = curr_;
|
2023-08-13 11:36:56 +02:00
|
|
|
while (true) {
|
|
|
|
|
2023-08-13 16:51:31 +02:00
|
|
|
auto [width, is_delim] =
|
|
|
|
match_delimiter(curr_, delim_char_);
|
2023-08-13 11:36:56 +02:00
|
|
|
|
2023-08-14 01:12:15 +02:00
|
|
|
if (multiline_limit_reached()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-08-13 16:51:31 +02:00
|
|
|
if (!is_delim) {
|
|
|
|
// not a delimiter
|
|
|
|
|
|
|
|
if (width == 0) {
|
|
|
|
// eol
|
|
|
|
shift_and_push();
|
|
|
|
// ++curr_;
|
|
|
|
// TODO handle differently
|
2023-08-14 01:12:15 +02:00
|
|
|
if (*curr_ == '\r') {
|
2023-08-13 16:51:31 +02:00
|
|
|
++curr_;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
} else {
|
|
|
|
curr_ += width;
|
|
|
|
check_buff_end();
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// found delimiter
|
|
|
|
shift_push_and_start_next(width);
|
|
|
|
curr_ += width;
|
2023-08-13 11:36:56 +02:00
|
|
|
check_buff_end();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2023-07-10 02:39:24 +02:00
|
|
|
}
|
2023-08-13 11:36:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// read next line each time in order to set eof_
|
2023-08-14 01:12:15 +02:00
|
|
|
void read_next() {
|
2023-08-13 11:36:56 +02:00
|
|
|
// TODO update division value
|
|
|
|
if (buff_processed_ > buff_filled_ / 2) {
|
|
|
|
if (!last_read_) {
|
|
|
|
shift_read_next();
|
|
|
|
|
|
|
|
if (buff_filled_ != buff_size_) {
|
|
|
|
last_read_ = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
curr_ = buff_;
|
|
|
|
end_ = buff_ + buff_filled_;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
split_data_.clear();
|
|
|
|
begin_ = curr_;
|
|
|
|
|
2023-08-14 01:12:15 +02:00
|
|
|
try {
|
|
|
|
// TODO check where to put this
|
|
|
|
// ++line_number_;
|
|
|
|
parse_next_line();
|
|
|
|
} catch (...) {
|
|
|
|
// TODO remove duplicate
|
|
|
|
++curr_;
|
|
|
|
buff_processed_ = curr_ - buff_;
|
|
|
|
|
|
|
|
if (last_read_ && curr_ >= end_) {
|
|
|
|
eof_ = true;
|
|
|
|
}
|
|
|
|
throw;
|
|
|
|
}
|
2023-08-05 12:05:17 +02:00
|
|
|
|
2023-08-12 21:15:44 +02:00
|
|
|
++curr_;
|
|
|
|
buff_processed_ = curr_ - buff_;
|
2020-12-26 00:46:42 +01:00
|
|
|
|
2023-08-12 21:15:44 +02:00
|
|
|
if (last_read_ && curr_ >= end_) {
|
2023-08-14 01:12:15 +02:00
|
|
|
eof_ = true;
|
2021-02-07 21:12:13 +01:00
|
|
|
}
|
2020-12-26 00:46:42 +01:00
|
|
|
}
|
2021-02-07 21:12:13 +01:00
|
|
|
|
2023-08-12 21:15:44 +02:00
|
|
|
std::string delim_{};
|
|
|
|
FILE* file_{nullptr};
|
2021-02-07 21:12:13 +01:00
|
|
|
|
2023-06-29 23:41:03 +02:00
|
|
|
converter<Options...> converter_;
|
2023-08-12 21:15:44 +02:00
|
|
|
char* buff_{nullptr};
|
|
|
|
size_t line_number_{0};
|
2021-02-07 21:12:13 +01:00
|
|
|
|
2023-08-12 21:15:44 +02:00
|
|
|
// TODO set initial buffer size
|
|
|
|
size_t buff_size_{1};
|
|
|
|
size_t buff_filled_{0};
|
|
|
|
size_t buff_processed_{0};
|
2021-02-07 21:12:13 +01:00
|
|
|
|
2023-08-12 21:15:44 +02:00
|
|
|
// TODO update
|
|
|
|
char delim_char_;
|
2021-02-07 21:12:13 +01:00
|
|
|
|
2023-08-12 21:15:44 +02:00
|
|
|
// TODO move to splitter
|
|
|
|
char* begin_{nullptr};
|
2023-08-13 11:36:56 +02:00
|
|
|
char* shifted_curr_{nullptr};
|
2023-08-12 21:15:44 +02:00
|
|
|
char* curr_{nullptr};
|
|
|
|
char* end_{nullptr};
|
|
|
|
|
|
|
|
bool last_read_{false};
|
2023-07-10 02:39:24 +02:00
|
|
|
|
2023-08-12 21:15:44 +02:00
|
|
|
split_data split_data_;
|
2023-08-13 11:36:56 +02:00
|
|
|
|
|
|
|
// TODO add to constructors
|
|
|
|
size_t escaped_{0};
|
|
|
|
bool unterminated_quote_{true};
|
|
|
|
bool unterminated_escape_{true};
|
2023-08-13 19:44:52 +02:00
|
|
|
error_type error_;
|
2023-08-14 01:12:15 +02:00
|
|
|
size_t new_lines_{0};
|
|
|
|
bool eof_{false};
|
2021-02-07 21:12:13 +01:00
|
|
|
};
|
2020-12-26 00:46:42 +01:00
|
|
|
|
|
|
|
////////////////
|
|
|
|
// members
|
|
|
|
////////////////
|
|
|
|
|
2021-02-07 21:12:13 +01:00
|
|
|
std::string file_name_;
|
2021-02-14 01:59:06 +01:00
|
|
|
error_type error_{};
|
2021-02-07 21:12:13 +01:00
|
|
|
reader reader_;
|
2022-02-27 19:40:23 +01:00
|
|
|
std::vector<std::string> header_;
|
2023-08-05 13:30:14 +02:00
|
|
|
std::string raw_header_;
|
2020-12-10 19:26:56 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
} /* ss */
|