/* Copyright 2013 Statoil ASA. This file is part of the Open Porous Media project (OPM). OPM is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. OPM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OPM. If not, see . */ #include #include "RawParserKWs.hpp" namespace Opm { RawParserKWs::RawParserKWs() { initializeFixedKeywordLenghts(); } bool RawParserKWs::keywordExists(const std::string& keyword) const { return m_keywordRecordLengths.find(keyword) != m_keywordRecordLengths.end(); } unsigned int RawParserKWs::getFixedNumberOfRecords(const std::string& keyword) const { if (keywordExists(keyword)) { return m_keywordRecordLengths.find(keyword) -> second; } else throw std::invalid_argument("Given keyword is not found, offending keyword: " + keyword); } void RawParserKWs::add(std::pair keywordAndNumRecords) { m_keywordRecordLengths.insert(keywordAndNumRecords); } void RawParserKWs::initializeFixedKeywordLenghts() { add(std::pair("GRIDUNIT", 1)); add(std::pair("INCLUDE", 1)); add(std::pair("RADFIN4", 1)); add(std::pair("DIMENS", 1)); add(std::pair("START", 1)); add(std::pair("GRIDOPTS", 1)); add(std::pair("ENDSCALE", 1)); add(std::pair("EQLOPTS", 1)); add(std::pair("TABDIMS", 1)); add(std::pair("EQLDIMS", 1)); add(std::pair("REGDIMS", 1)); add(std::pair("FAULTDIM", 1)); add(std::pair("WELLDIMS", 1)); add(std::pair("VFPPDIMS", 1)); add(std::pair("RPTSCHED", 1)); add(std::pair("TITLE", 0)); add(std::pair("RUNSPEC", 0)); add(std::pair("METRIC", 0)); add(std::pair("SCHEDULE", 0)); add(std::pair("SKIPREST", 0)); add(std::pair("NOECHO", 0)); add(std::pair("END", 0)); add(std::pair("OIL", 0)); add(std::pair("GAS", 0)); add(std::pair("WATER", 0)); add(std::pair("DISGAS", 0)); add(std::pair("VAPOIL", 0)); } RawParserKWs::~RawParserKWs() { } }