20 #ifndef OPM_KEYWORDVALIDATION_HEADER_INCLUDED
21 #define OPM_KEYWORDVALIDATION_HEADER_INCLUDED
23 #include <opm/common/OpmLog/KeywordLocation.hpp>
26 #include <initializer_list>
30 #include <unordered_map>
41 namespace KeywordValidation
46 std::optional<std::string> message;
53 std::function<bool(T)> validator;
54 std::optional<std::string> message;
58 using UnsupportedKeywords = std::map<std::string, UnsupportedKeywordProperties>;
62 using PartiallySupportedKeywordItems = std::map<size_t, PartiallySupportedKeywordProperties<T>>;
66 using PartiallySupportedKeywords = std::map<std::string, PartiallySupportedKeywordItems<T>>;
73 KeywordLocation location;
75 std::optional<size_t> item_number;
76 std::optional<std::string> item_value;
77 std::optional<std::string> user_message;
85 std::string get_error_report(
const std::vector<ValidationError>& errors,
const bool critical);
92 void validateBRINE(
const DeckKeyword& keyword, std::vector<ValidationError>& errors);
98 const PartiallySupportedKeywords<std::string>& string_items,
99 const PartiallySupportedKeywords<int>& int_items,
100 const PartiallySupportedKeywords<double>& double_items,
101 const std::unordered_map<std::string, std::function<
void(
const DeckKeyword& keyword, std::vector<ValidationError>& errors)>>& special_validation)
102 : m_keywords(keywords)
103 , m_string_items(string_items)
104 , m_int_items(int_items)
105 , m_double_items(double_items)
106 , m_special_validation(special_validation)
113 void validateDeck(
const Deck& deck,
114 const ParseContext& parse_context,
115 ErrorGuard& error_guard)
const;
119 void validateDeckKeyword(
const DeckKeyword& keyword, std::vector<ValidationError>& errors)
const;
122 template <
typename T>
123 void validateKeywordItem(
const DeckKeyword& keyword,
125 const bool multiple_records,
126 const size_t record_number,
127 const size_t item_number,
129 std::vector<ValidationError>& errors)
const;
132 template <
typename T>
133 void validateKeywordItems(
const DeckKeyword& keyword,
134 const PartiallySupportedKeywords<T>& partially_supported_options,
135 std::vector<ValidationError>& errors)
const;
137 const UnsupportedKeywords m_keywords;
138 const PartiallySupportedKeywords<std::string> m_string_items;
139 const PartiallySupportedKeywords<int> m_int_items;
140 const PartiallySupportedKeywords<double> m_double_items;
141 const std::unordered_map<std::string, std::function<void(
const DeckKeyword& keyword, std::vector<ValidationError>& errors)>> m_special_validation;
146 template <
typename T>
150 allow_values(
const std::initializer_list<T>& allowed_values)
152 for (
auto item : allowed_values) {
153 m_allowed_values.push_back(item);
157 bool operator()(
const T& value)
const
159 return std::find(m_allowed_values.begin(), m_allowed_values.end(), value) != m_allowed_values.end();
163 std::vector<T> m_allowed_values;
Definition: KeywordValidation.hpp:95
Definition: KeywordValidation.hpp:148
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition: BlackoilPhases.hpp:27
Definition: KeywordValidation.hpp:51
Definition: KeywordValidation.hpp:44
Definition: KeywordValidation.hpp:71