2013-12-19 14:05:50 +01:00
|
|
|
/*
|
|
|
|
|
* File: KeywordDescriber.cpp
|
|
|
|
|
* Author: atleh
|
|
|
|
|
*
|
|
|
|
|
* Created on December 19, 2013, 1:19 PM
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <iostream>
|
2013-12-20 12:28:54 +01:00
|
|
|
#include <utility>
|
|
|
|
|
#include <opm/parser/eclipse/Parser/Parser.hpp>
|
2013-12-20 14:01:36 +01:00
|
|
|
#include <opm/parser/eclipse/Parser/ParserRecord.hpp>
|
|
|
|
|
#include <opm/parser/eclipse/Parser/ParserItem.hpp>
|
2013-12-20 12:28:54 +01:00
|
|
|
#include <opm/parser/eclipse/Parser/ParserKeyword.hpp>
|
2013-12-19 14:05:50 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
*
|
|
|
|
|
*/
|
2013-12-20 12:28:54 +01:00
|
|
|
void printKeywordInformation(Opm::ParserKeywordConstPtr keyword)
|
|
|
|
|
{
|
2013-12-20 12:33:16 +01:00
|
|
|
std::string indent = " ";
|
2013-12-20 12:28:54 +01:00
|
|
|
|
2013-12-20 12:33:16 +01:00
|
|
|
std::cout << keyword->getName() << std::endl;
|
2013-12-20 13:02:33 +01:00
|
|
|
std::cout << indent << "numItems: " << keyword->numItems() << std::endl;
|
|
|
|
|
std::cout << indent << "hasDimension: " << keyword->hasDimension() << std::endl;
|
|
|
|
|
std::cout << indent << "hasFixedSize: " << keyword->hasFixedSize() << std::endl;
|
2013-12-20 12:28:54 +01:00
|
|
|
if (keyword->hasFixedSize())
|
2013-12-20 13:02:33 +01:00
|
|
|
std::cout << indent << "getFixedSize: " << keyword->getFixedSize() << std::endl;
|
|
|
|
|
std::cout << indent << "isTableCollection: " << keyword->isTableCollection() << std::endl;
|
|
|
|
|
std::cout << indent << "getSizeType: " << keyword->getSizeType() << std::endl;
|
2013-12-20 12:28:54 +01:00
|
|
|
std::pair<std::string, std::string> sizeDefinitionPair = keyword->getSizeDefinitionPair();
|
2013-12-20 12:33:16 +01:00
|
|
|
std::cout << indent << "getSizeDefinitionPair: '" << sizeDefinitionPair.first << "', '" << sizeDefinitionPair.second << "'" << std::endl;
|
2013-12-20 13:02:33 +01:00
|
|
|
std::cout << indent << "isDataKeyword: " << keyword->isDataKeyword() << std::endl;
|
2013-12-20 14:01:36 +01:00
|
|
|
|
|
|
|
|
// Opm::ParserRecordPtr parserRecord = keyword->getRecord();
|
|
|
|
|
// std::vector<Opm::ParserItemConstPtr>::const_iterator iterator;
|
|
|
|
|
// for (iterator = parserRecord->begin(); iterator != parserRecord->end(); ++iterator) {
|
|
|
|
|
// std::cout << indent << iterator->name;
|
|
|
|
|
// }
|
2013-12-20 13:02:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool parseCommandLineForAllKeywordsOption(char** argv)
|
|
|
|
|
{
|
|
|
|
|
bool allKeywords = false;
|
|
|
|
|
std::string arg(argv[1]);
|
|
|
|
|
if (arg == "-a")
|
|
|
|
|
allKeywords = true;
|
|
|
|
|
|
|
|
|
|
return allKeywords;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::list<std::string> createListOfKeywordsToDescribe(char** argv, bool allKeywords, Opm::ParserPtr parser)
|
|
|
|
|
{
|
|
|
|
|
std::list<std::string> keywords;
|
|
|
|
|
if (allKeywords) {
|
|
|
|
|
parser->getKeywords(&keywords);
|
|
|
|
|
} else {
|
|
|
|
|
std::string keywordName = argv[1];
|
|
|
|
|
keywords.push_back(keywordName);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return keywords;
|
2013-12-20 12:28:54 +01:00
|
|
|
}
|
|
|
|
|
|
2013-12-19 14:05:50 +01:00
|
|
|
int main(int argc, char** argv) {
|
2013-12-20 12:28:54 +01:00
|
|
|
if (argc < 2) {
|
|
|
|
|
std::cout << "Usage: " << argv[0] << " <Keywordname>|-a (all keywords)" << std::endl;
|
|
|
|
|
exit(1);
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-20 13:02:33 +01:00
|
|
|
bool allKeywords = parseCommandLineForAllKeywordsOption(argv);
|
2013-12-20 12:28:54 +01:00
|
|
|
|
|
|
|
|
Opm::ParserPtr parser(new Opm::Parser());
|
|
|
|
|
|
|
|
|
|
std::list<std::string> keywords;
|
2013-12-20 13:02:33 +01:00
|
|
|
keywords = createListOfKeywordsToDescribe(argv, allKeywords, parser);
|
2013-12-20 12:28:54 +01:00
|
|
|
|
|
|
|
|
std::list<std::string>::const_iterator iterator;
|
|
|
|
|
for (iterator = keywords.begin(); iterator != keywords.end(); ++iterator) {
|
|
|
|
|
Opm::ParserKeywordConstPtr keyword = parser->getKeyword(*iterator);
|
|
|
|
|
printKeywordInformation(keyword);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
2013-12-19 14:05:50 +01:00
|
|
|
}
|