OGS
IntegrationPointMetaData.h
Go to the documentation of this file.
1
9
10#include <concepts>
11#include <optional>
12#include <range/v3/range/concepts.hpp>
13#include <range/v3/range/traits.hpp>
14#if defined(__cpp_lib_containers_ranges) && \
15 __cpp_lib_containers_ranges >= 202202L
16#include <ranges>
17#else
18#include <range/v3/to_container.hpp>
19#endif
20#include <string>
21#include <string_view>
22#include <vector>
23
24#pragma once
25
26namespace MeshLib
27{
39
42{
43public:
45 explicit IntegrationPointMetaData(std::string_view const json_string);
46
47 explicit IntegrationPointMetaData(ranges::input_range auto&& range)
48 requires(std::convertible_to<ranges::range_reference_t<decltype(range)>,
50 :
51#if defined(__cpp_lib_containers_ranges) && \
52 __cpp_lib_containers_ranges >= 202202L
53 fields_(std::from_range, std::forward<decltype(range)>(range))
54#else
55 fields_(ranges::to<std::vector<IntegrationPointMetaDataSingleField>>(
56 std::forward<decltype(range)>(range)))
57#endif
58 {
60 }
61
62 std::string toJsonString() const;
63
64 constexpr bool empty() const { return fields_.empty(); }
65
67 std::string const& field_name) const;
68
69 auto operator<=>(IntegrationPointMetaData const&) const = default;
70
71private:
72 void checkFieldNamesAreUnique() const;
73
74private:
75 std::vector<IntegrationPointMetaDataSingleField> fields_;
76};
77
81 std::optional<IntegrationPointMetaData> const& ip_meta_data,
82 std::string const& field_name);
83} // namespace MeshLib
IntegrationPointMetaData(std::string_view const json_string)
Constructs integration point meta data from a JSON encoded string.
std::string toJsonString() const
Converts integration point meta data to a JSON string.
auto operator<=>(IntegrationPointMetaData const &) const =default
IntegrationPointMetaDataSingleField const & operator[](std::string const &field_name) const
std::vector< IntegrationPointMetaDataSingleField > fields_
IntegrationPointMetaData(ranges::input_range auto &&range)
IntegrationPointMetaDataSingleField getIntegrationPointMetaDataSingleField(std::optional< IntegrationPointMetaData > const &ip_meta_data, std::string const &field_name)
auto operator<=>(IntegrationPointMetaDataSingleField const &) const =default