Added Parser::dropKeyword()

This commit is contained in:
Joakim Hove 2013-10-09 08:22:43 +02:00
parent a8543c29aa
commit b63244228d
4 changed files with 19 additions and 0 deletions

View File

@ -72,6 +72,13 @@ namespace Opm {
return m_parserKeywords.find(keyword) != m_parserKeywords.end();
}
bool Parser::dropKeyword(const std::string& keyword) {
if (m_parserKeywords.erase( keyword ) == 1)
return true;
else
return false;
}
ParserKeywordConstPtr Parser::getKeyword(const std::string& keyword) const {
if (hasKeyword(keyword)) {
return m_parserKeywords.at(keyword);

View File

@ -47,6 +47,7 @@ namespace Opm {
/// Method to add ParserKeyword instances, these holding type and size information about the keywords and their data.
void addKeyword(ParserKeywordConstPtr parserKeyword);
bool hasKeyword(const std::string& keyword) const;
bool dropKeyword(const std::string& keyword);
ParserKeywordConstPtr getKeyword(const std::string& keyword) const;
void loadKeywords(const Json::JsonObject& jsonKeywords);

View File

@ -216,6 +216,14 @@ BOOST_AUTO_TEST_CASE(loadConfigFromDirectory_default) {
}
BOOST_AUTO_TEST_CASE(DropKeyword) {
ParserPtr parser(new Parser());
BOOST_CHECK_EQUAL(false , parser->dropKeyword("DoesNotHaveThis"));
BOOST_CHECK_EQUAL(true , parser->dropKeyword("BPR"));
BOOST_CHECK_EQUAL(false , parser->dropKeyword("BPR"));
}
/***************** Simple Int parsing ********************************/
ParserKeywordPtr setupParserKeywordInt(std::string name, int numberOfItems) {

View File

@ -0,0 +1,3 @@
{"name" : "MAPUNITS" , "size" : 1 , "items" : [
{"name" : "UNIT" , "value_type" : "STRING" , "default" : "METRES"}]}