enforce.hpp
// ***************************************************************** -*- C++ -*-
/*
* Copyright (C) 2004-2021 Exiv2 authors
* This program is part of the Exiv2 distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301 USA.
*/
#include <string>
#include "error.hpp"
template <typename exception_t, typename T>
inline void enforce(bool condition, const T& arg1)
{
if (!condition) {
throw exception_t(arg1);
}
}
inline void enforce(bool condition, Exiv2::ErrorCode err_code)
{
if (!condition) {
throw Exiv2::Error(err_code);
}
}
template <typename T>
inline void enforce(bool condition, Exiv2::ErrorCode err_code, const T& arg1)
{
if (!condition) {
throw Exiv2::Error(err_code, arg1);
}
}
template <typename T, typename U>
inline void enforce(bool condition, Exiv2::ErrorCode err_code, const T& arg1, const U& arg2)
{
if (!condition) {
throw Exiv2::Error(err_code, arg1, arg2);
}
}
template <typename T, typename U, typename V>
inline void enforce(bool condition, Exiv2::ErrorCode err_code, const T& arg1, const U& arg2, const V& arg3)
{
if (!condition) {
throw Exiv2::Error(err_code, arg1, arg2, arg3);
}
}
error.hpp
Error class for exceptions, log message class.
Exiv2::ErrorCode
ErrorCode
Complete list of all Exiv2 error codes.
Definition: error.hpp:191
Exiv2::Error
BasicError< char > Error
Error class used for exceptions (std::string based)
Definition: error.hpp:324