My Project
Loading...
Searching...
No Matches
StarToken.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 STAR_TOKEN_HPP
21#define STAR_TOKEN_HPP
22
23#include <cstddef>
24#include <string>
25#include <string_view>
26
27namespace Opm {
28
29 bool isStarToken(const std::string_view& token,
30 std::string& countString,
31 std::string& valueString);
32
33 template <class T>
34 T readValueToken( std::string_view );
35
36class StarToken {
37public:
38 explicit StarToken(const std::string_view& token);
39
40 StarToken(const std::string_view& token, const std::string& countStr, const std::string& valueStr)
41 : m_countString(countStr)
42 , m_valueString(valueStr)
43 {
44 init_(token);
45 }
46
47 std::size_t count() const {
48 return m_count;
49 }
50
51 bool hasValue() const {
52 return !m_valueString.empty();
53 }
54
55 // returns the coubt as rendered in the deck. note that this might be different
56 // than just converting the return value of count() to a string because an empty
57 // count is interpreted as 1...
58 const std::string& countString() const {
59 return m_countString;
60 }
61
62 // returns the value as rendered in the deck. note that this might be different
63 // than just converting the return value of value() to a string because values
64 // might have different representations in the deck (e.g. strings can be
65 // specified with and without quotes and but spaces are only allowed using the
66 // first representation.)
67 const std::string& valueString() const {
68 return m_valueString;
69 }
70
71private:
72 // internal initialization method. the m_countString and m_valueString attributes
73 // must be set before calling this method.
74 void init_(const std::string_view& token);
75
76 std::size_t m_count;
77 std::string m_countString;
78 std::string m_valueString;
79};
80
81}
82
83#endif
Definition StarToken.hpp:36
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30