opm-common
RawKeyword.hpp
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 <cstddef>
24 #include <memory>
25 #include <optional>
26 #include <string>
27 #include <vector>
28 
29 #include <opm/common/OpmLog/KeywordLocation.hpp>
30 
31 #include "RawEnums.hpp"
32 #include "RawConsts.hpp"
33 
34 namespace Opm {
35 
36  class RawRecord;
37  class RawKeyword {
38  public:
39  RawKeyword(const std::string& name, const std::string& filename, std::size_t lineNR, bool raw_string, Raw::KeywordSizeEnum sizeType);
40  RawKeyword(const std::string& name, const std::string& filename, std::size_t lineNR, bool raw_string, Raw::KeywordSizeEnum sizeType, const std::optional<std::size_t>& min_size, std::size_t size_arg);
41  bool terminateKeyword();
42  bool addRecord(RawRecord record);
43 
44  const std::string& getKeywordName() const;
45  Raw::KeywordSizeEnum getSizeType() const;
46 
47  // Special case method only for inspecting INCLUDE keywords;
48  // the general getRecords functionality should use the
49  // iterator interface.
50  const RawRecord& getFirstRecord( ) const;
51 
52  bool isFinished() const;
53  bool rawStringKeyword() const;
54  const KeywordLocation& location() const;
55  bool can_complete() const;
56 
57  using const_iterator = std::vector< RawRecord >::const_iterator;
58  using iterator = std::vector< RawRecord >::iterator;
59 
60  iterator begin();
61  iterator end();
62  const_iterator begin() const;
63  const_iterator end() const;
64  std::size_t size() const;
65  private:
66  std::string m_name;
67  KeywordLocation m_location;
68  bool raw_string_keyword;
69  Raw::KeywordSizeEnum m_sizeType;
70 
71  std::size_t m_min_size = 0;
72  std::size_t m_fixedSize = 0;
73  std::size_t m_numTables = 0;
74  std::size_t m_currentNumTables = 0;
75  bool m_isTempFinished = false;
76  bool m_isFinished = false;
77 
78  std::vector< RawRecord > m_records;
79  };
80 }
81 #endif /* RAWKEYWORD_HPP */
Definition: RawKeyword.hpp:37
Definition: KeywordLocation.hpp:27
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition: Exceptions.hpp:30
Class representing the lowest level of the Raw datatypes, a record.
Definition: RawRecord.hpp:36