Merge pull request #737 from jokva/raw-keyword-record-std-list

RawKeyword iterator support and correct RawRecord management
This commit is contained in:
Joakim Hove
2016-03-30 13:27:53 +02:00
3 changed files with 21 additions and 4 deletions

View File

@@ -363,8 +363,7 @@ bool Parser::parseState(std::shared_ptr<ParserState> parserState) const {
break;
}
else if (parserState->rawKeyword->getKeywordName() == Opm::RawConsts::paths) {
for (size_t i = 0; i < parserState->rawKeyword->size(); i++) {
auto& record = parserState->rawKeyword->getRecord(i);
for( const auto& record : *parserState->rawKeyword ) {
std::string pathName = readValueToken<std::string>(record.getItem(0));
std::string pathValue = readValueToken<std::string>(record.getItem(1));
parserState->pathMap->insert(std::pair<std::string, std::string>(pathName, pathValue));

View File

@@ -107,7 +107,13 @@ namespace Opm {
RawRecord& RawKeyword::getRecord(size_t index) {
return this->m_records.at( index );
if( index >= this->m_records.size() )
throw std::out_of_range(
"Error: looking up record " + std::to_string( index )
+ ", but RawKeyword has only "
+ std::to_string( this->m_records.size() ) + " records." );
return *std::next( this->m_records.begin(), index );
}
bool RawKeyword::isKeywordPrefix(const std::string& line, std::string& keywordName) {
@@ -158,6 +164,13 @@ namespace Opm {
return m_lineNR;
}
RawKeyword::const_iterator RawKeyword::begin() const {
return this->m_records.begin();
}
RawKeyword::const_iterator RawKeyword::end() const {
return this->m_records.end();
}
Raw::KeywordSizeEnum RawKeyword::getSizeType() const {
return m_sizeType;

View File

@@ -23,6 +23,7 @@
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <opm/parser/eclipse/RawDeck/RawEnums.hpp>
@@ -56,6 +57,10 @@ namespace Opm {
const std::string& getFilename() const;
size_t getLineNR() const;
using const_iterator = std::list< RawRecord >::const_iterator;
const_iterator begin() const;
const_iterator end() const;
private:
Raw::KeywordSizeEnum m_sizeType;
@@ -64,7 +69,7 @@ namespace Opm {
size_t m_numTables;
size_t m_currentNumTables;
std::string m_name;
std::vector< RawRecord > m_records;
std::list< RawRecord > m_records;
std::string m_partialRecordString;
size_t m_lineNR;