DeckRecord ParserRecord::parse(const ParseContext& parseContext , MessageContainer& msgContainer, RawRecord& rawRecord ) const { DeckRecord deckRecord( size() + 20 ); for (size_t i = 0; i < size(); i++) { auto parserItem = get(i); deckRecord.addItem( parserItem->scan( rawRecord ) ); } if (rawRecord.size() > 0) { std::string msg = "The RawRecord for keyword \"" + rawRecord.getKeywordName() + "\" in file\"" + rawRecord.getFileName() + "\" contained " + std::to_string(rawRecord.size()) + " too many items according to the spec. RawRecord was: " + rawRecord.getRecordString(); parseContext.handleError(ParseContext::PARSE_EXTRA_DATA , msgContainer, msg); } return deckRecord; }
DeckRecordConstPtr ParserRecord::parse(RawRecordPtr rawRecord) const { std::string recordBeforeParsing = rawRecord->getRecordString(); DeckRecordPtr deckRecord(new DeckRecord()); for (size_t i = 0; i < size(); i++) { ParserItemConstPtr parserItem = get(i); DeckItemPtr deckItem = parserItem->scan(rawRecord); deckRecord->addItem(deckItem); } const size_t recordSize = rawRecord->size(); if (recordSize > 0) throw std::invalid_argument("The RawRecord for keyword \"" + rawRecord->getKeywordName() + "\" in file\"" + rawRecord->getFileName() + "\" contained " + boost::lexical_cast<std::string>(recordSize) + " too many items according to the spec. RawRecord was: " + recordBeforeParsing); return deckRecord; }