Aleph-w
7.10.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
aleph-exceptions.H
Go to the documentation of this file.
1
2
/*
3
Aleph_w
4
5
Data structures & Algorithms
6
version 2.0.0b
7
https://github.com/lrleon/Aleph-w
8
9
This file is part of Aleph-w library
10
11
Copyright (c) 2002-2026 Leandro Rabindranath Leon
12
13
Permission is hereby granted, free of charge, to any person obtaining a copy
14
of this software and associated documentation files (the "Software"), to deal
15
in the Software without restriction, including without limitation the rights
16
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17
copies of the Software, and to permit persons to whom the Software is
18
furnished to do so, subject to the following conditions:
19
20
The above copyright notice and this permission notice shall be included in all
21
copies or substantial portions of the Software.
22
23
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29
SOFTWARE.
30
*/
31
32
88
# ifndef ALEPH_EXCEPTIONS_H
89
# define ALEPH_EXCEPTIONS_H
90
91
# include <exception>
92
# include <sstream>
93
94
# include <
ahUtils.H
>
95
96
// The classes are deprecated, and so are their uses here: they warn only
97
// where the programs use them. The public macros are defined outside of
98
// the regions without the warning, which, for GCC, cover what they spell
99
# if defined(_MSC_VER) && !defined(__clang__)
100
# pragma warning(push)
101
# pragma warning(disable : 4996)
102
# else
103
# pragma GCC diagnostic push
104
# pragma GCC diagnostic ignored "-Wdeprecated-declarations"
105
# endif
106
107
# define ALEPH_EXCEPTIONS_DEPRECATED \
108
[[deprecated("aleph-exceptions.H goes in 8.0.0; use the macros of ah-errors.H instead")]]
109
119
struct
ALEPH_EXCEPTIONS_DEPRECATED
AlephException
:
public
std::runtime_error
120
{
122
const
size_t
line_number = 0;
123
125
const
std::string file_name =
"No defined"
;
126
127
const
std::string type =
"No defined"
;
128
const
std::string msg =
"No defined"
;
129
130
protected
:
131
132
std::string category_msg =
"No defined"
;
133
134
private
:
135
136
static
std::string
make_what
(
const
std::string & category_msg,
137
size_t
line_number,
138
const
std::string & file_name,
139
const
std::string & type,
140
const
std::string & msg)
141
{
142
std::ostringstream s;
143
s << category_msg <<
"|"
<< file_name <<
"|"
<< line_number
144
<<
"|"
<< type <<
"|"
<< msg;
145
return
s.str();
146
}
147
148
public
:
149
150
AlephException
() :
std
::runtime_error(msg) {}
151
152
AlephException
(
const
std::string & category_msg,
153
const
size_t
line_number,
154
const
std::string & file_name,
155
const
std::string & type,
156
const
std::string & msg)
157
: runtime_error(make_what(category_msg, line_number, file_name, type, msg)),
158
line_number(line_number), file_name(file_name), type(type) {}
159
};
160
161
# if defined(_MSC_VER) && !defined(__clang__)
162
# pragma warning(pop)
163
# else
164
# pragma GCC diagnostic pop
165
# endif
166
178
# define DEFINE_ALEPH_EXCEPTION(name, category_msg) \
179
struct name : public AlephException \
180
{ \
181
name(const size_t line_number, \
182
const std::string & file_name, \
183
const std::string & type, \
184
const std::string & msg) \
185
: AlephException(#category_msg, line_number, file_name, type, msg) {} \
186
\
187
private: \
188
/* GCC does not warn of a deprecated base class: of this, it does */
\
189
using aleph_deprecated_base_ = AlephException; \
190
};
191
201
# define ALEPHTHROW(type, msg) throw type(__LINE__, __FILE__, #type, msg)
202
203
# if defined(_MSC_VER) && !defined(__clang__)
204
# pragma warning(push)
205
# pragma warning(disable : 4996)
206
# else
207
# pragma GCC diagnostic push
208
# pragma GCC diagnostic ignored "-Wdeprecated-declarations"
209
# endif
210
211
// The exceptions of Aleph, deprecated as AlephException
212
# define ALEPH_DEFINE_DEPRECATED_EXCEPTION(name, category_msg) \
213
struct ALEPH_EXCEPTIONS_DEPRECATED name : public AlephException \
214
{ \
215
name(const size_t line_number, \
216
const std::string & file_name, \
217
const std::string & type, \
218
const std::string & msg) \
219
: AlephException(#category_msg, line_number, file_name, type, msg) {} \
220
};
221
222
ALEPH_DEFINE_DEPRECATED_EXCEPTION
(
MinMaxReversed
,
223
"minimum value is greater than maximum value"
);
224
ALEPH_DEFINE_DEPRECATED_EXCEPTION
(
InvalidCsvHeader
,
"Invalid csv header"
);
225
ALEPH_DEFINE_DEPRECATED_EXCEPTION
(
InvalidCsvRow
,
"Invalid csv row"
);
226
ALEPH_DEFINE_DEPRECATED_EXCEPTION
(
InvalidValue
,
"Invalid value"
);
227
ALEPH_DEFINE_DEPRECATED_EXCEPTION
(
OutOfMemory
,
"No memory"
);
228
ALEPH_DEFINE_DEPRECATED_EXCEPTION
(
OutOfRange
,
"Value is out of allowed range"
);
229
ALEPH_DEFINE_DEPRECATED_EXCEPTION
(
ValueNotFound
,
"Value not found"
);
230
ALEPH_DEFINE_DEPRECATED_EXCEPTION
(
CommandLineError
,
"error parsing command line"
);
231
ALEPH_DEFINE_DEPRECATED_EXCEPTION
(
InvariantError
,
"A bug has been detected. "
232
"Please send a bug report to leandro.r.leon@gmail.com"
);
233
ALEPH_DEFINE_DEPRECATED_EXCEPTION
(
SizeMismatch
,
"Sequences have different sizes"
);
234
ALEPH_DEFINE_DEPRECATED_EXCEPTION
(
InvalidConversion
,
"failure in numeric conversion"
);
235
ALEPH_DEFINE_DEPRECATED_EXCEPTION
(
NameNotFound
,
"name not found"
);
236
ALEPH_DEFINE_DEPRECATED_EXCEPTION
(
InvalidSize
,
"invalid size"
);
237
ALEPH_DEFINE_DEPRECATED_EXCEPTION
(
InvalidRange
,
"invalid range"
);
238
ALEPH_DEFINE_DEPRECATED_EXCEPTION
(
InvalidUnit
,
"invalid unit"
);
239
ALEPH_DEFINE_DEPRECATED_EXCEPTION
(
DuplicatedOperation
,
"duplicated operation"
);
240
ALEPH_DEFINE_DEPRECATED_EXCEPTION
(
DuplicatedName
,
"Duplicated name"
);
241
ALEPH_DEFINE_DEPRECATED_EXCEPTION
(
InvalidRead
,
"Error while reading input stream"
);
242
ALEPH_DEFINE_DEPRECATED_EXCEPTION
(
FileNotFound
,
"file not found"
);
243
244
# undef ALEPH_DEFINE_DEPRECATED_EXCEPTION
245
# undef ALEPH_EXCEPTIONS_DEPRECATED
246
247
# if defined(_MSC_VER) && !defined(__clang__)
248
# pragma warning(pop)
249
# else
250
# pragma GCC diagnostic pop
251
# endif
252
253
# endif
ahUtils.H
General utility functions and helpers.
ALEPH_EXCEPTIONS_DEPRECATED
#define ALEPH_EXCEPTIONS_DEPRECATED
Definition
aleph-exceptions.H:107
ALEPH_DEFINE_DEPRECATED_EXCEPTION
#define ALEPH_DEFINE_DEPRECATED_EXCEPTION(name, category_msg)
Definition
aleph-exceptions.H:212
std
STL namespace.
AlephException
Aleph exception class.
Definition
aleph-exceptions.H:120
AlephException::make_what
static std::string make_what(const std::string &category_msg, size_t line_number, const std::string &file_name, const std::string &type, const std::string &msg)
Definition
aleph-exceptions.H:136
AlephException::AlephException
AlephException()
Definition
aleph-exceptions.H:150
AlephException::AlephException
AlephException(const std::string &category_msg, const size_t line_number, const std::string &file_name, const std::string &type, const std::string &msg)
Definition
aleph-exceptions.H:152
CommandLineError
Definition
aleph-exceptions.H:230
DuplicatedName
Definition
aleph-exceptions.H:240
DuplicatedOperation
Definition
aleph-exceptions.H:239
FileNotFound
Definition
aleph-exceptions.H:242
InvalidConversion
Definition
aleph-exceptions.H:234
InvalidCsvHeader
Definition
aleph-exceptions.H:224
InvalidCsvRow
Definition
aleph-exceptions.H:225
InvalidRange
Definition
aleph-exceptions.H:237
InvalidRead
Definition
aleph-exceptions.H:241
InvalidSize
Definition
aleph-exceptions.H:236
InvalidUnit
Definition
aleph-exceptions.H:238
InvalidValue
Definition
aleph-exceptions.H:226
InvariantError
Definition
aleph-exceptions.H:232
MinMaxReversed
Definition
aleph-exceptions.H:223
NameNotFound
Definition
aleph-exceptions.H:235
OutOfMemory
Definition
aleph-exceptions.H:227
OutOfRange
Definition
aleph-exceptions.H:228
SizeMismatch
Definition
aleph-exceptions.H:233
ValueNotFound
Definition
aleph-exceptions.H:229
aleph-exceptions.H
Generated by
1.9.8