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 <deque>
24#include <memory>
25#include <string>
26#include <list>
27
29
30namespace Opm {
31
35
36 class RawRecord {
37 public:
38 RawRecord( const string_view&, bool text);
39 explicit RawRecord( const string_view&);
40
41 inline string_view pop_front();
42 inline string_view front() const;
43 void push_front( string_view token );
44 void prepend( size_t count, string_view token );
45 inline size_t size() const;
46
48 inline string_view getItem(size_t index) const;
49
50 void dump() const;
51
52 private:
53 string_view m_sanitizedRecordString;
54 std::deque< string_view > m_recordItems;
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 */
62 auto front = m_recordItems.front();
63 this->m_recordItems.pop_front();
64 return front;
65 }
66
68 return this->m_recordItems.front();
69 }
70
71 size_t RawRecord::size() const {
72 return m_recordItems.size();
73 }
74
76 return this->m_recordItems.at( index );
77 }
78}
79
80#endif /* RECORD_HPP */
81
int index
Definition: cJSON.h:168
int count
Definition: cJSON.h:212
const char *const string
Definition: cJSON.h:170
Definition: RawRecord.hpp:36
string_view getItem(size_t index) const
Definition: RawRecord.hpp:75
RawRecord(const string_view &, bool text)
void prepend(size_t count, string_view token)
string_view front() const
Definition: RawRecord.hpp:67
size_t size() const
Definition: RawRecord.hpp:71
RawRecord(const string_view &)
void dump() const
std::string getRecordString() const
void push_front(string_view token)
string_view pop_front()
Definition: RawRecord.hpp:61
Definition: Stringview.hpp:48
Definition: A.hpp:4