mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Add basic functionality for validating special case keywords
This commit is contained in:
@@ -33,9 +33,12 @@
|
||||
namespace Opm
|
||||
{
|
||||
|
||||
|
||||
|
||||
namespace KeywordValidation
|
||||
{
|
||||
|
||||
|
||||
std::string get_error_report(const std::vector<ValidationError>& errors, const bool critical)
|
||||
{
|
||||
const std::string keyword_format = " {keyword}: keyword not supported\n";
|
||||
@@ -75,13 +78,22 @@ namespace KeywordValidation
|
||||
}
|
||||
|
||||
void
|
||||
KeywordValidator::validateDeck(const Deck& deck, const ParseContext& parse_context, ErrorGuard& error_guard) const
|
||||
KeywordValidator::validateDeck(const Deck& deck,
|
||||
const ParseContext& parse_context,
|
||||
ErrorGuard& error_guard) const
|
||||
{
|
||||
// Make a vector with all problems encountered in the deck.
|
||||
std::vector<ValidationError> errors;
|
||||
for (const auto& keyword : deck)
|
||||
for (const auto& keyword : deck) {
|
||||
validateDeckKeyword(keyword, errors);
|
||||
|
||||
const auto& special_it = this->m_special_validation.find(keyword.name());
|
||||
if (special_it != this->m_special_validation.end()) {
|
||||
const auto& validator = special_it->second;
|
||||
validator(keyword, errors);
|
||||
}
|
||||
}
|
||||
|
||||
// First report non-critical problems as a warning.
|
||||
auto warning_report = get_error_report(errors, false);
|
||||
if (!warning_report.empty()) {
|
||||
|
||||
Reference in New Issue
Block a user