Merge remote-tracking branch 'upstream/master' into norne-keywords

This commit is contained in:
Joakim Hove
2013-12-02 15:35:34 +01:00
2 changed files with 14 additions and 7 deletions

View File

@@ -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.");

View File

@@ -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);