diff --git a/include/openspace/documentation/verifier.h b/include/openspace/documentation/verifier.h index 47f61427b2..7cde68a2aa 100644 --- a/include/openspace/documentation/verifier.h +++ b/include/openspace/documentation/verifier.h @@ -156,7 +156,17 @@ struct IntVerifier : public TemplateVerifier { * std::string. No implicit conversion is considered in this testing. */ struct StringVerifier : public TemplateVerifier { + StringVerifier(bool mustBeNotEmpty = false); + + TestResult operator()(const ghoul::Dictionary& dictionary, + const std::string& key) const override; + std::string type() const override; + + bool mustBeNotEmpty() const; + +private: + bool _mustBeNotEmpty = false; }; /** diff --git a/src/documentation/verifier.cpp b/src/documentation/verifier.cpp index 9de0012f2c..ab6377f91f 100644 --- a/src/documentation/verifier.cpp +++ b/src/documentation/verifier.cpp @@ -174,6 +174,33 @@ std::string IntVerifier::type() const { return "Integer"; } +StringVerifier::StringVerifier(bool mustBeNotEmpty) + : TemplateVerifier() + , _mustBeNotEmpty(mustBeNotEmpty) +{} + +TestResult StringVerifier::operator()(const ghoul::Dictionary& dictionary, + const std::string& key) const +{ + TestResult res = TemplateVerifier::operator()(dictionary, key); + if (!res.success) { + return res; + } + + std::string value = dictionary.value(key); + if (value.empty() && _mustBeNotEmpty) { + res.success = false; + res.offenses.push_back({ + key, TestResult::Offense::Reason::Verification, "value must not be empty" + }); + } + return res; +} + +bool StringVerifier::mustBeNotEmpty() const { + return _mustBeNotEmpty; +} + std::string StringVerifier::type() const { return "String"; } diff --git a/src/engine/logfactory.cpp b/src/engine/logfactory.cpp index e07c794afa..90633d26e6 100644 --- a/src/engine/logfactory.cpp +++ b/src/engine/logfactory.cpp @@ -103,7 +103,6 @@ std::unique_ptr createLog(const ghoul::Dictionary& dictiona bool dateStamp = p.dateStamping.value_or(true); bool categoryStamp = p.categoryStamping.value_or(true); bool logLevelStamp = p.logLevelStamping.value_or(true); - Parameters::LogLevel logLevel = p.logLevel.value_or(Parameters::LogLevel::AllLogging); ghoul::logging::LogLevel level = [](Parameters::LogLevel l) { switch (l) { case Parameters::LogLevel::AllLogging: