diff --git a/opm/parser/eclipse/Parser/ParserKeyword.cpp b/opm/parser/eclipse/Parser/ParserKeyword.cpp index a9f42ec1a..4a51ac65e 100644 --- a/opm/parser/eclipse/Parser/ParserKeyword.cpp +++ b/opm/parser/eclipse/Parser/ParserKeyword.cpp @@ -147,14 +147,22 @@ namespace Opm { } - bool ParserKeyword::wildCardName(const std::string& name) { + bool ParserKeyword::validNameStart(const std::string& name) { if (name.length() > ParserConst::maxKeywordLength) return false; if (!isupper(name[0])) return false; - for (unsigned int i = 1; i < name.length(); i++) { + return true; + } + + + bool ParserKeyword::wildCardName(const std::string& name) { + if (!validNameStart(name)) + return false; + + for (size_t i = 1; i < name.length(); i++) { char c = name[i]; if (!(isupper(c) || isdigit(c))) { if ((i == (name.length() - 1)) && (c == '*')) @@ -168,13 +176,10 @@ namespace Opm { bool ParserKeyword::validName(const std::string& name) { - if (name.length() > ParserConst::maxKeywordLength) + if (!validNameStart(name)) return false; - if (!isupper(name[0])) - return false; - - for (unsigned int i = 1; i < name.length(); i++) { + for (size_t i = 1; i < name.length(); i++) { char c = name[i]; if (!(isupper(c) || isdigit(c))) return wildCardName(name); @@ -182,6 +187,7 @@ namespace Opm { return true; } + void ParserKeyword::addItem(ParserItemConstPtr item) { if (m_isDataKeyword) throw std::invalid_argument("Keyword:" + getName() + " is already configured as data keyword - can not add more items."); diff --git a/opm/parser/eclipse/Parser/ParserKeyword.hpp b/opm/parser/eclipse/Parser/ParserKeyword.hpp index ddcccdae9..2033a07a7 100644 --- a/opm/parser/eclipse/Parser/ParserKeyword.hpp +++ b/opm/parser/eclipse/Parser/ParserKeyword.hpp @@ -73,6 +73,7 @@ namespace Opm { bool m_isTableCollection; ParserKeywordActionEnum m_action; + static bool validNameStart(const std::string& name); void initData( const Json::JsonObject& jsonConfig ); void initSize( const Json::JsonObject& jsonConfig ); void initSizeKeyword( const std::string& sizeKeyword, const std::string& sizeItem);