OGS
IntegrationPointMetaData.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) OpenGeoSys Community (opengeosys.org)
2// SPDX-License-Identifier: BSD-3-Clause
3
4#include <concepts>
5#include <optional>
6#include <range/v3/range/concepts.hpp>
7#include <range/v3/range/traits.hpp>
8#if defined(__cpp_lib_containers_ranges) && \
9 __cpp_lib_containers_ranges >= 202202L
10#include <ranges>
11#else
12#include <range/v3/to_container.hpp>
13#endif
14#include <string>
15#include <string_view>
16#include <vector>
17
18#pragma once
19
20namespace MeshLib
21{
33
36{
37public:
39 explicit IntegrationPointMetaData(std::string_view const json_string);
40
41 explicit IntegrationPointMetaData(ranges::input_range auto&& range)
42 requires(std::convertible_to<ranges::range_reference_t<decltype(range)>,
44 :
45#if defined(__cpp_lib_containers_ranges) && \
46 __cpp_lib_containers_ranges >= 202202L
47 fields_(std::from_range, std::forward<decltype(range)>(range))
48#else
49 fields_(ranges::to<std::vector<IntegrationPointMetaDataSingleField>>(
50 std::forward<decltype(range)>(range)))
51#endif
52 {
54 }
55
56 std::string toJsonString() const;
57
58 constexpr bool empty() const { return fields_.empty(); }
59
61 std::string const& field_name) const;
62
63 auto operator<=>(IntegrationPointMetaData const&) const = default;
64
65private:
66 void checkFieldNamesAreUnique() const;
67
68private:
69 std::vector<IntegrationPointMetaDataSingleField> fields_;
70};
71
75 std::optional<IntegrationPointMetaData> const& ip_meta_data,
76 std::string const& field_name);
77} // 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