RawRecord.hpp
Go to the documentation of this file.
1 /*
2  Copyright 2013 Statoil ASA.
3 
4  This file is part of the Open Porous Media project (OPM).
5 
6  OPM is free software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  OPM is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with OPM. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef RECORD_HPP
21 #define RECORD_HPP
22 
23 #include <string>
24 #include <deque>
25 #include <memory>
26 
27 namespace Opm {
28 
32 
33  class RawRecord {
34  public:
35  RawRecord(const std::string& singleRecordString, const std::string& fileName = "", const std::string& keywordName = "");
36 
37  std::string pop_front();
38  void push_front(std::string token);
39  size_t size() const;
40 
41  const std::string& getRecordString() const;
42  const std::string& getItem(size_t index) const;
43  const std::string& getFileName() const;
44  const std::string& getKeywordName() const;
45 
46  static bool isTerminatedRecordString(const std::string& candidateRecordString);
47  virtual ~RawRecord();
48  void dump() const;
49 
50  private:
51  std::string m_sanitizedRecordString;
52  std::deque<std::string> m_recordItems;
53  const std::string m_fileName;
54  const std::string m_keywordName;
55 
56  void setRecordString(const std::string& singleRecordString);
57  void splitSingleRecordString();
58  void processSeparatorCharacter(std::string& currentToken, const char& currentChar, char& tokenStarter);
59  void processQuoteCharacters(std::string& currentToken, const char& currentChar, char& tokenStarter);
60  void processNonSpecialCharacters(std::string& currentToken, const char& currentChar);
61  bool charIsSeparator(char candidate);
62  static unsigned int findTerminatingSlash(const std::string& singleRecordString);
63  };
64  typedef std::shared_ptr<RawRecord> RawRecordPtr;
65  typedef std::shared_ptr<const RawRecord> RawRecordConstPtr;
66 
67 }
68 
69 #endif /* RECORD_HPP */
70 
Definition: Deck.hpp:29
const std::string & getRecordString() const
void dump() const
size_t size() const
RawRecord(const std::string &singleRecordString, const std::string &fileName="", const std::string &keywordName="")
std::shared_ptr< const RawRecord > RawRecordConstPtr
Definition: RawRecord.hpp:65
const std::string & getFileName() const
const std::string & getKeywordName() const
const std::string & getItem(size_t index) const
void push_front(std::string token)
Definition: RawRecord.hpp:33
virtual ~RawRecord()
static bool isTerminatedRecordString(const std::string &candidateRecordString)
std::shared_ptr< RawRecord > RawRecordPtr
Definition: RawRecord.hpp:64
std::string pop_front()