My Project
Loading...
Searching...
No Matches
KeywordLocation.hpp
1/*
2 Copyright 2015 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 KEYWORD_LOCATION_HPP
21#define KEYWORD_LOCATION_HPP
22
23#include <string>
24
25namespace Opm {
26
28public:
29 /*
30 Observe that many error messages whcih should print out the name of the
31 problem keyword along with the location {} placeholders can be used. The
32 convention is:
33
34 {keyword} -> keyword
35 {file} -> filename
36 {line} -> lineno
37
38 This convention must be adhered to at the call site *creating the output
39 string*.
40 */
41
42 std::string keyword;
43 std::string filename = "<memory string>";
44 std::size_t lineno = 0;
45
46 KeywordLocation() = default;
47 KeywordLocation(std::string kw, std::string fname, std::size_t lno) :
48 keyword(std::move(kw)),
49 filename(std::move(fname)),
50 lineno(lno)
51 {}
52
53
54 std::string format(const std::string& msg_fmt) const;
55
56 static KeywordLocation serializationTestObject()
57 {
58 KeywordLocation result;
59 result.keyword = "KW";
60 result.filename = "test";
61 result.lineno = 1;
62
63 return result;
64 }
65
66 bool operator==(const KeywordLocation& data) const {
67 return keyword == data.keyword &&
68 filename == data.filename &&
69 lineno == data.lineno;
70 }
71
72 template<class Serializer>
73 void serializeOp(Serializer& serializer)
74 {
75 serializer(keyword);
76 serializer(filename);
77 serializer(lineno);
78 }
79};
80
81}
82
83#endif
Definition KeywordLocation.hpp:27
Class for (de-)serializing.
Definition Serializer.hpp:84
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30