Files
2024-10-02 23:33:21 +01:00

75 lines
2.2 KiB
C++

/* This file is a part of Calyp project
* Copyright (C) 2014-2021 by Joao Carreira (jfmcarreira@gmail.com)
* Luis Lucas (luisfrlucas@gmail.com)
*
* 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, Fifth Floor, Boston, MA 02110-1301 USA.
*/
/**
* \file CalypDefs.h
* \ingroup CalypLibGrp
* \brief Define basic types, new types and enumerations (private use only)
*/
#ifndef __CALYPDEFS_H__
#define __CALYPDEFS_H__
#include <algorithm>
#include <format>
#include <iterator>
#include <memory>
#include <string>
enum CLP_LOG_LEVEL
{
CLP_LOG_INFO = 1,
CLP_LOG_WARNINGS = 2,
CLP_LOG_RESULT = 3,
CLP_LOG_ERROR = 4,
};
static const double S_PI = 3.14159265358979323846;
static const double S_PI_2 = 1.57079632679489661923;
inline std::string clpLowercase( const std::string& in )
{
std::string out;
std::transform( in.begin(), in.end(), std::back_inserter( out ), tolower );
return out;
}
inline std::string clpUppercase( const std::string& in )
{
std::string out;
std::transform( in.begin(), in.end(), std::back_inserter( out ), toupper );
return out;
}
struct CalypFailure : public std::exception
{
CalypFailure( std::string error_msg ) throw() : m_error_msg{ std::move( error_msg ) } {}
CalypFailure( std::string class_name, std::string error_msg ) throw()
: m_error_msg{ std::format( "[%s] %s", class_name, error_msg ) }
{
}
~CalypFailure() throw() {}
auto what() const throw() -> const char* { return m_error_msg.c_str(); }
private:
std::string m_error_msg;
};
#endif // __CALYPDEFS_H__