Files
opm-common/opm/parser/eclipse/Applications/KeywordDescriber.cpp

86 lines
2.9 KiB
C++
Raw Normal View History

2013-12-19 14:05:50 +01:00
/*
* File: KeywordDescriber.cpp
* Author: atleh
*
* Created on December 19, 2013, 1:19 PM
*/
#include <iostream>
#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>
#include <opm/parser/eclipse/Parser/ParserKeyword.hpp>
2013-12-19 14:05:50 +01:00
/*
*
*/
void printKeywordInformation(Opm::ParserKeywordConstPtr keyword)
{
std::string indent = " ";
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;
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;
std::pair<std::string, std::string> sizeDefinitionPair = keyword->getSizeDefinitionPair();
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-19 14:05:50 +01:00
int main(int argc, char** argv) {
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);
Opm::ParserPtr parser(new Opm::Parser());
std::list<std::string> keywords;
2013-12-20 13:02:33 +01:00
keywords = createListOfKeywordsToDescribe(argv, allKeywords, parser);
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
}