24 constexpr
fill(Args &&... args) :
base_type{std::forward<Args>(args)...} {}
28 static constexpr
auto missing = std::nullopt;
69 template <
class Fields>
82 template <
class Field,
class Enable =
void>
86 template <
class Field>
88 Field, std::enable_if_t<is_optional_v<typename Field::value_type>>>
92 template <
class Field>
119 template <std::
size_t Min, std::
size_t Max>
struct range {
120 static constexpr
auto min = Min, max = Max;
132 template <
class R0,
class... R,
class Rn>
146 std::enable_if_t<std::is_floating_point_v<T>, void>> {
154 template <
class Value,
class Error>
158 template <
class Value,
class Error>
169 template <
class ValueType,
class TagType>
178 template <
class Value,
class Error>
182 template <
class Value,
class Error>
184 :
base_type{std::get<0>(f), std::get<1>(f)},
tag(std::get<2>(f)) {}
196 std::enable_if_t<std::is_floating_point_v<T>, void>> {
203 template <
class Value,
class ErrorLower,
class ErrorUpper>
205 ErrorUpper error_upper_)
208 template <
class Value,
class ErrorLower,
class ErrorUpper>
221 return error_lower * error_lower + error_upper * error_upper;
240 template <
class Field>
struct get_t;
244 template <
class T> constexpr
auto const &
operator()(T
const &t)
const {
251 template <
class T> constexpr
auto const &
operator()(T
const &t)
const {
258 template <
class T> constexpr
auto const &
operator()(T
const &t)
const {
265 template <
class T> constexpr
auto const &
operator()(T
const &t)
const {
272 template <
class T> constexpr
auto const &
operator()(T
const &t)
const {
278 template <
class T,
class Subfield,
class... S>
struct type_of {
283 template <
class T,
class Subfield>
struct type_of<T, Subfield> {
290 template <
class T,
class... Subfield>
296 return {f * vae.value, f * vae.error};
306 template <
class V,
class T>
309 return {f * vae.value, f * vae.error, vae.
tag};
313 template <
class V,
class T>
322 return {f * vae.value, f * vae.error_lower, f * vae.error_upper};
344 template <
class TagType>
348 template <
class TagType>
439 template <
class Range,
class T>
454 template <
class Ranges,
class T>
458 static_assert(std::tuple_size_v<Ranges> == 3);
462 if (b >= std::tuple_element_t<1, Ranges>::max)
465 auto value_sc = read_field<std::tuple_element_t<0, Ranges>>(out.value, s);
466 auto error_sc = read_field<std::tuple_element_t<1, Ranges>>(out.error, s);
477 template <
class Ranges,
class ValueType,
class TagType>
483 static_assert(std::tuple_size_v<Ranges> == 3);
487 if (b >= std::tuple_element_t<2, Ranges>::max)
490 auto value_sc = read_field<std::tuple_element_t<0, Ranges>>(out.value, s);
491 auto error_sc = read_field<std::tuple_element_t<1, Ranges>>(out.error, s);
492 auto tag_sc = read_field<std::tuple_element_t<2, Ranges>>(out.
tag, s);
503 template <
class Ranges,
class T>
507 static_assert(std::tuple_size_v<Ranges> == 3);
511 if (b >= std::tuple_element_t<2, Ranges>::max)
514 auto value_sc = read_field<std::tuple_element_t<0, Ranges>>(out.value, s);
515 auto error_lower_sc =
516 read_field<std::tuple_element_t<1, Ranges>>(out.error_lower, s);
517 auto error_upper_sc =
518 read_field<std::tuple_element_t<2, Ranges>>(out.error_upper, s);
520 if (value_sc ==
empty || error_lower_sc ==
empty || error_upper_sc ==
empty)
522 else if (value_sc ==
failed || error_lower_sc ==
failed ||
541 template <
class Field,
class... Subfield>
constexpr auto const & operator()(T const &t) const
Definition: fields.hpp:244
value_and_errors(fill< Value, ErrorLower, ErrorUpper > &&f)
Build the class from a field constant expression.
Definition: fields.hpp:209
Field for an error.
Definition: fields.hpp:110
value_type error_upper
Upper error.
Definition: fields.hpp:218
Define a range with minimum and maximum indices.
Definition: fields.hpp:119
Type defining an accessor to a value/error field.
Definition: fields.hpp:240
value_type error_squared() const
Calculate the squared error from the lower and upper errors.
Definition: fields.hpp:220
the conversion succeeded
Definition: fields.hpp:358
remove_optional_t< typename Field::value_type > type
Definition: fields.hpp:537
Field for a lower error.
Definition: fields.hpp:112
value_type error() const
Calculate the error from the lower and upper errors.
Definition: fields.hpp:224
T find_first_not_of(T... args)
T type
Definition: fields.hpp:96
value_type value
Value.
Definition: fields.hpp:214
typename type_of< T, Subfield... >::type type_of_t
Determine a returned type.
Definition: fields.hpp:291
constexpr fill(Args &&... args)
Definition: fields.hpp:24
constexpr auto const & operator()(T const &t) const
Definition: fields.hpp:258
static constexpr auto missing
Static object that defines a missing field within an object.
Definition: fields.hpp:28
value_and_errors(Value value_, ErrorLower error_lower_, ErrorUpper error_upper_)
Build the class with forwarded arguments.
Definition: fields.hpp:204
Contain the information whether a field is optional or not.
Definition: fields.hpp:83
Determine a returned type.
Definition: fields.hpp:278
value_and_error_with_tag(Value value_, Error error_, TagType tag_)
Build the class with forwarded arguments.
Definition: fields.hpp:179
TagType tag
Internal tag.
Definition: fields.hpp:187
constexpr auto const & operator()(T const &t) const
Definition: fields.hpp:272
the conversion failed
Definition: fields.hpp:360
T value_type
Definition: fields.hpp:198
Access the subtype of a set of fields.
Definition: fields.hpp:530
typename remove_optional< T >::type remove_optional_t
If the input type is an optional, get the underying type.
Definition: fields.hpp:105
constexpr auto const & operator()(T const &t) const
Definition: fields.hpp:251
Small structure to define fields without explicitely knowing its type.
Definition: fields.hpp:21
typename underlying_types< Fields >::type underlying_types_t
Define a std::tuple with the types of the fields provided.
Definition: fields.hpp:70
value_type error
Error.
Definition: fields.hpp:165
Define a std::tuple with the types of the fields provided.
Definition: fields.hpp:61
typename type_of< Subfield, S... >::type type
Definition: fields.hpp:279
conversion_status string_to_type(std::string &out, std::string const &s)
Convert a range of characters to string.
Definition: fields.hpp:427
typename field_member_type< Field, Subfield... >::type field_member_type_t
Access the subtype of a set of fields.
Definition: fields.hpp:543
typename overall_range< R >::type overall_range_t
Overall range of a variable (that can be a composite)
Definition: fields.hpp:138
Main namespace of the Reactions package.
Definition: all.hpp:22
T type
Definition: fields.hpp:100
Field for an lower error.
Definition: fields.hpp:114
value_and_error_with_tag(fill< Value, Error, TagType > &&f)
Build the class from a field constant expression.
Definition: fields.hpp:183
value_and_errors< T > operator*(T f, value_and_errors< T > const &vae)
Multiplication of the value and errors by a constant.
Definition: fields.hpp:327
Check if a type represents an optional.
Definition: fields.hpp:73
value_type error_lower
Lower error.
Definition: fields.hpp:216
Simple structure composed by a value and its error.
Definition: fields.hpp:141
constexpr auto const & operator()(T const &t) const
Definition: fields.hpp:265
value_and_error(fill< Value, Error > &&f)
Build the class from a field constant expression.
Definition: fields.hpp:159
T find_last_not_of(T... args)
value_type value
Value.
Definition: fields.hpp:163
constexpr auto is_optional_v
Alias to check if a type represents an optional.
Definition: fields.hpp:79
the object is missing
Definition: fields.hpp:359
conversion_status read_field(value_and_errors< T > &out, std::string const &s)
Read a field composed by value and errors in a line from a file.
Definition: fields.hpp:504
value_and_error(Value value_, Error error_)
Build the class with forwarded arguments.
Definition: fields.hpp:155
Represent a value, its error and a identifier tag.
Definition: fields.hpp:170
Field for a value.
Definition: fields.hpp:108
conversion_status
Status code of a conversion to an arithmetic or std::optional type.
Definition: fields.hpp:357
Simple structure composed by a value and the lower and upper errors.
Definition: fields.hpp:191
value_and_error_with_tag()
Empty constructor.
Definition: fields.hpp:175
If the input type is an optional, get the underying type.
Definition: fields.hpp:96
Field for a tag.
Definition: fields.hpp:116
constexpr auto const & access_value(std::optional< T > const &opt)
Definition: fields.hpp:235
type_of_t< remove_optional_t< typename Field::value_type >, Subfield... > type
Definition: fields.hpp:532
static constexpr get_t< Field > get
Accessor to a value/error field.
Definition: fields.hpp:332
value_and_error()
Empty constructor.
Definition: fields.hpp:151
T value_type
Definition: fields.hpp:148
constexpr auto is_optional_field_v
Contain the information whether a field is optional or not.
Definition: fields.hpp:93
Get the overall range for a range with/without subranges.
Definition: fields.hpp:127
Utilities to handle database objects and their elements.
Definition: fields.hpp:58
std::string to_string(std::string const &v)
Convert the given object to a string.
Definition: fields.hpp:551