My Project
Loading...
Searching...
No Matches
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 <deque>
24#include <memory>
25#include <string>
26#include <string_view>
27#include <list>
28
29namespace Opm {
30class KeywordLocation;
31
35
36 class RawRecord {
37 public:
38 RawRecord( const std::string_view&, const KeywordLocation&, bool text);
39 explicit RawRecord( const std::string_view&, const KeywordLocation&);
40
41 inline std::string_view pop_front();
42 inline std::string_view front() const;
43 void push_front( std::string_view token, std::size_t count );
44 inline size_t size() const;
45 std::size_t max_size() const;
46
47 std::string getRecordString() const;
48 inline std::string_view getItem(size_t index) const;
49
50 private:
51 std::string_view m_sanitizedRecordString;
52 std::deque< std::string_view > m_recordItems;
53 std::size_t m_max_size;
54 };
55
56 /*
57 * These are frequently called, but fairly trivial in implementation, and
58 * inlining the calls gives a decent low-effort performance benefit.
59 */
60 std::string_view RawRecord::pop_front() {
61 auto front = m_recordItems.front();
62 this->m_recordItems.pop_front();
63 return front;
64 }
65
66 std::string_view RawRecord::front() const {
67 return this->m_recordItems.front();
68 }
69
70 size_t RawRecord::size() const {
71 return m_recordItems.size();
72 }
73
74 std::string_view RawRecord::getItem(size_t index) const {
75 return this->m_recordItems.at( index );
76 }
77}
78
79#endif /* RECORD_HPP */
80
Definition KeywordLocation.hpp:27
Class representing the lowest level of the Raw datatypes, a record.
Definition RawRecord.hpp:36
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30