libosmscout 1.1.1
Loading...
Searching...
No Matches
StyleError.h
Go to the documentation of this file.
1#ifndef OSMSCOUT_STYLEERROR_H
2#define OSMSCOUT_STYLEERROR_H
3
4/*
5 This source is part of the libosmscout library
6 Copyright (C) 2023 Lukas Karas
7
8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Lesser General Public
10 License as published by the Free Software Foundation; either
11 version 2.1 of the License, or (at your option) any later version.
12
13 This library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Lesser General Public License for more details.
17
18 You should have received a copy of the GNU Lesser General Public
19 License along with this library; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21*/
22
24
25#include <string>
26
27namespace osmscout {
28
33 {
34 public:
38
39 public:
40 StyleError(StyleErrorType type, int line, int column, const std::string &text) :
41 type(type), line(line), column(column), text(text){}
42
43 StyleError(const StyleError&) = default;
44 StyleError(StyleError&&) = default;
45
46 StyleError& operator=(const StyleError&) = default;
48
49 ~StyleError() = default;
50
52 {
53 return type;
54 }
55
56 std::string GetTypeName() const
57 {
58 switch(type){
59 case Symbol:
60 return "Symbol";
61 case Error:
62 return "Error";
63 case Warning:
64 return "Warning";
65 case Exception:
66 return "Exception";
67 default:
68 assert(false);
69 return "???";
70 }
71 }
72
73 int GetLine() const
74 {
75 return line;
76 }
77
78 int GetColumn() const
79 {
80 return column;
81 }
82
83 const std::string &GetText() const
84 {
85 return text;
86 }
87
88 std::string GetShortDescription() const
89 {
90 return GetTypeName() + ": " + GetText();
91 }
92
93 std::string GetDescription() const
94 {
95 return std::to_string(GetLine()) + "," + std::to_string(GetColumn()) + " " + GetShortDescription();
96 }
97
98 private:
99 StyleErrorType type;
100 int line;
101 int column;
102 std::string text;
103 };
104
105}
106
107#endif //OSMSCOUT_STYLEERROR_H
#define OSMSCOUT_MAP_API
Definition MapImportExport.h:45
int GetColumn() const
Definition StyleError.h:78
std::string GetShortDescription() const
Definition StyleError.h:88
StyleErrorType
Definition StyleError.h:35
@ Error
Definition StyleError.h:36
@ Exception
Definition StyleError.h:36
@ Symbol
Definition StyleError.h:36
@ Warning
Definition StyleError.h:36
StyleError(const StyleError &)=default
StyleError(StyleError &&)=default
StyleErrorType GetType() const
Definition StyleError.h:51
int GetLine() const
Definition StyleError.h:73
StyleError(StyleErrorType type, int line, int column, const std::string &text)
Definition StyleError.h:40
StyleError & operator=(const StyleError &)=default
std::string GetDescription() const
Definition StyleError.h:93
std::string GetTypeName() const
Definition StyleError.h:56
StyleError & operator=(StyleError &&)=default
const std::string & GetText() const
Definition StyleError.h:83
Definition Area.h:39