Exiv2
src
enforce.hpp
Go to the documentation of this file.
1
// ********************************************************* -*- C++ -*-
2
/*
3
* Copyright (C) 2004-2018 Exiv2 authors
4
* This program is part of the Exiv2 distribution.
5
*
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; either version 2
9
* of the License, or (at your option) any later version.
10
*
11
* This program 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 this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301 USA.
19
*/
28
#include <string>
29
30
#include "
error.hpp
"
31
42
template
<
typename
exception_t,
typename
T>
43
inline
void
enforce
(
bool
condition,
const
T& arg1)
44
{
45
if
(!condition) {
46
throw
exception_t(arg1);
47
}
48
}
49
54
inline
void
enforce
(
bool
condition,
Exiv2::ErrorCode
err_code)
55
{
56
if
(!condition) {
57
throw
Exiv2::Error
(err_code);
58
}
59
}
60
65
template
<
typename
T>
66
inline
void
enforce
(
bool
condition,
Exiv2::ErrorCode
err_code,
const
T& arg1)
67
{
68
if
(!condition) {
69
throw
Exiv2::Error
(err_code, arg1);
70
}
71
}
72
77
template
<
typename
T,
typename
U>
78
inline
void
enforce
(
bool
condition,
Exiv2::ErrorCode
err_code,
const
T& arg1,
const
U& arg2)
79
{
80
if
(!condition) {
81
throw
Exiv2::Error
(err_code, arg1, arg2);
82
}
83
}
84
89
template
<
typename
T,
typename
U,
typename
V>
90
inline
void
enforce
(
bool
condition,
Exiv2::ErrorCode
err_code,
const
T& arg1,
const
U& arg2,
const
V& arg3)
91
{
92
if
(!condition) {
93
throw
Exiv2::Error
(err_code, arg1, arg2, arg3);
94
}
95
}
enforce
void enforce(bool condition, const T &arg1)
Ensure that condition is true, otherwise throw an exception of the type exception_t.
Definition:
enforce.hpp:43
Exiv2::Error
BasicError< char > Error
Error class used for exceptions (std::string based)
Definition:
error.hpp:323
Exiv2::ErrorCode
ErrorCode
Complete list of all Exiv2 error codes.
Definition:
error.hpp:191
error.hpp
Error class for exceptions, log message class.
Generated on Tue May 25 2021 00:00:00 for Exiv2 by
1.8.20