RawKeyword.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 RAWKEYWORD_HPP
21 #define RAWKEYWORD_HPP
22 
23 #include <string>
24 #include <utility>
25 #include <vector>
26 #include <memory>
27 
30 
31 namespace Opm {
32 
37 
38  class RawKeyword {
39  public:
40  RawKeyword(const std::string& name , Raw::KeywordSizeEnum sizeType , const std::string& filename, size_t lineNR);
41  RawKeyword(const std::string& name , const std::string& filename, size_t lineNR , size_t inputSize , bool isTableCollection = false);
42 
43  const std::string& getKeywordName() const;
44  void addRawRecordString(const std::string& partialRecordString);
45  size_t size() const;
47  RawRecordPtr getRecord(size_t index) const;
48 
49  static bool isKeywordPrefix(const std::string& line, std::string& keywordName);
50  static bool isTerminator(std::string line);
51 
52 
53  bool isPartialRecordStringEmpty() const;
54  bool isFinished() const;
55  bool unKnownSize() const;
56  void finalizeUnknownSize();
57 
58  const std::string& getFilename() const;
59  size_t getLineNR() const;
60 
61 
62  private:
63  Raw::KeywordSizeEnum m_sizeType;
64  bool m_isFinished;
65  size_t m_fixedSize;
66  size_t m_numTables;
67  size_t m_currentNumTables;
68  std::string m_name;
69  std::vector<RawRecordPtr> m_records;
70  std::string m_partialRecordString;
71 
72  size_t m_lineNR;
73  std::string m_filename;
74 
75  void commonInit(const std::string& name,const std::string& filename, size_t lineNR);
76  void setKeywordName(const std::string& keyword);
77  static bool isValidKeyword(const std::string& keywordCandidate);
78  };
79  typedef std::shared_ptr<RawKeyword> RawKeywordPtr;
80  typedef std::shared_ptr<const RawKeyword> RawKeywordConstPtr;
81 
82 }
83 #endif /* RAWKEYWORD_HPP */
84 
size_t size() const
std::shared_ptr< const RawKeyword > RawKeywordConstPtr
Definition: RawKeyword.hpp:80
bool isFinished() const
std::shared_ptr< RawKeyword > RawKeywordPtr
Definition: RawKeyword.hpp:79
Definition: Deck.hpp:29
const std::string & getKeywordName() const
KeywordSizeEnum
Definition: RawEnums.hpp:30
RawRecordPtr getRecord(size_t index) const
static bool isTerminator(std::string line)
Raw::KeywordSizeEnum getSizeType() const
bool isPartialRecordStringEmpty() const
bool unKnownSize() const
Definition: RawKeyword.hpp:38
const std::string & getFilename() const
size_t getLineNR() const
std::shared_ptr< RawRecord > RawRecordPtr
Definition: RawRecord.hpp:64
void finalizeUnknownSize()
RawKeyword(const std::string &name, Raw::KeywordSizeEnum sizeType, const std::string &filename, size_t lineNR)
void addRawRecordString(const std::string &partialRecordString)
static bool isKeywordPrefix(const std::string &line, std::string &keywordName)