Files
opm-common/opm/parser/eclipse/RawDeck/RawRecord.hpp
Atgeirr Flø Rasmussen 78e0870bad Use std::list instead of std::vector to fix push_front().
The push_front() method can cause reallocation of expanded_items,
thereby invalidating iterators already stored in m_recordItems.
Switching to std::list fixes this.
2016-03-14 14:54:29 +01:00

69 lines
2.2 KiB
C++

/*
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 <http://www.gnu.org/licenses/>.
*/
#ifndef RECORD_HPP
#define RECORD_HPP
#include <deque>
#include <memory>
#include <string>
#include <list>
#include <opm/parser/eclipse/Utility/Stringview.hpp>
namespace Opm {
/// Class representing the lowest level of the Raw datatypes, a record. A record is simply
/// a vector containing the record elements, represented as strings. Some logic is present
/// to handle special elements in a record string, particularly with quote characters.
class RawRecord {
public:
RawRecord(const std::string& singleRecordString, const std::string& fileName = "", const std::string& keywordName = "");
string_view pop_front();
void push_front(std::string token);
size_t size() const;
const std::string& getRecordString() const;
string_view getItem(size_t index) const;
const std::string& getFileName() const;
const std::string& getKeywordName() const;
static bool isTerminatedRecordString(const std::string& candidateRecordString);
void dump() const;
private:
std::string m_sanitizedRecordString;
std::deque< string_view > m_recordItems;
std::list< std::string > expanded_items;
const std::string m_fileName;
const std::string m_keywordName;
void setRecordString(const std::string& singleRecordString);
};
typedef std::shared_ptr<RawRecord> RawRecordPtr;
typedef std::shared_ptr<const RawRecord> RawRecordConstPtr;
}
#endif /* RECORD_HPP */