opm-common
RawRecord.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 RECORD_HPP
21 #define RECORD_HPP
22 
23 #include <cstddef>
24 #include <deque>
25 #include <list>
26 #include <memory>
27 #include <string>
28 #include <string_view>
29 
30 namespace Opm {
31 class KeywordLocation;
32 
36 
37  class RawRecord {
38  public:
39  RawRecord( const std::string_view&, const KeywordLocation&, bool text);
40  explicit RawRecord( const std::string_view&, const KeywordLocation&);
41 
42  inline std::string_view pop_front();
43  inline std::string_view front() const;
44  void push_front( std::string_view token, std::size_t count );
45  inline std::size_t size() const;
46  std::size_t max_size() const;
47 
48  std::string getRecordString() const;
49  inline std::string_view getItem(std::size_t index) const;
50 
51  private:
52  std::string_view m_sanitizedRecordString;
53  std::deque< std::string_view > m_recordItems;
54  std::size_t m_max_size;
55  };
56 
57  /*
58  * These are frequently called, but fairly trivial in implementation, and
59  * inlining the calls gives a decent low-effort performance benefit.
60  */
61  std::string_view RawRecord::pop_front() {
62  auto result = m_recordItems.front();
63  this->m_recordItems.pop_front();
64  return result;
65  }
66 
67  std::string_view RawRecord::front() const {
68  return this->m_recordItems.front();
69  }
70 
71  std::size_t RawRecord::size() const {
72  return m_recordItems.size();
73  }
74 
75  std::string_view RawRecord::getItem(std::size_t index) const {
76  return this->m_recordItems.at( index );
77  }
78 }
79 
80 #endif /* RECORD_HPP */
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:37