rsvs3D  0.0.0
Codes for the c++ implementation of the 3D RSVS
warning.hpp File Reference

Provides the error and warning system used by the RSVS3D project. More...

#include <stdarg.h>
#include <fstream>
#include <iostream>
#include <stdexcept>

Go to the source code of this file.

Classes

class  rsvs3d::rsvs_exception
 Exception for signaling rsvs errors. More...
 

Namespaces

 rsvs3d
 Namespace for general purpose tools of the RSVS project.
 

Macros

#define RSVS3D_ERROR(M)   (rsvs3d::error(M, __PRETTY_FUNCTION__, __FILE__, __LINE__, true))
 Throw generic rsvs errors. More...
 
#define RSVS3D_ERROR_NOTHROW(M)   (rsvs3d::error(M, __PRETTY_FUNCTION__, __FILE__, __LINE__, false))
 Generic rsvs warning. More...
 
#define RSVS3D_ERROR_TYPE(M, T)   (rsvs3d::error<T>(M, __PRETTY_FUNCTION__, __FILE__, __LINE__, true))
 Throw a specific error type. More...
 
#define RSVS3D_ERROR_LOGIC(M)   (rsvs3d::error<std::logic_error>(M, __PRETTY_FUNCTION__, __FILE__, __LINE__, true))
 Throw a logic_error. More...
 
#define RSVS3D_ERROR_ARGUMENT(M)    (rsvs3d::error<std::invalid_argument>(M, __PRETTY_FUNCTION__, __FILE__, __LINE__, true))
 Throw a invalid_argument. More...
 
#define RSVS3D_ARGCHECK(E, M)
 
#define RSVS3D_ARGCHECK_WARN(E, M)
 
#define RSVS3D_ERROR_RANGE(M)   (rsvs3d::error<std::range_error>(M, __PRETTY_FUNCTION__, __FILE__, __LINE__, true))
 Throw a range_error. More...
 

Functions

template<class E = rsvs_exception>
void rsvs3d::error (const char *message="", const char *caller="", const char *file="", int line=0, bool throwError=true)
 Custom error function. More...
 
template<typename T >
int rsvs3d::sign (T val)
 Returns the sign of a type comparable to 0. More...
 
int rsvs3d::TimeStamp (const char *str, int start_s)
 
double rsvs3d::SignedLogScale (double in)
 Returns a signed logscale useful for plotting data. More...
 
double rsvs3d::Clock2ms (int clockCycles)
 
void ThrowWarning (const char *message)
 
template<class T >
void CheckFStream (const T &file, const char *callerID, const std::string &fileName)
 Checks a file stream. More...
 

Detailed Description

Provides the error and warning system used by the RSVS3D project.

Definition in file warning.hpp.

Macro Definition Documentation

◆ RSVS3D_ARGCHECK

#define RSVS3D_ARGCHECK (   E,
 
)
Value:
if (!(E)) \
{ \
RSVS3D_ERROR_ARGUMENT(M); \
}

Definition at line 152 of file warning.hpp.

◆ RSVS3D_ARGCHECK_WARN

#define RSVS3D_ARGCHECK_WARN (   E,
 
)
Value:
if (!(E)) \
{ \
RSVS3D_ERROR_NOTHROW(M); \
}

Definition at line 157 of file warning.hpp.

◆ RSVS3D_ERROR

#define RSVS3D_ERROR (   M)    (rsvs3d::error(M, __PRETTY_FUNCTION__, __FILE__, __LINE__, true))

Throw generic rsvs errors.

Parameters
MMessage of the error (const char*).
Exceptions
rsvs3d::rsvs_exception

Definition at line 113 of file warning.hpp.

◆ RSVS3D_ERROR_ARGUMENT

#define RSVS3D_ERROR_ARGUMENT (   M)     (rsvs3d::error<std::invalid_argument>(M, __PRETTY_FUNCTION__, __FILE__, __LINE__, true))

Throw a invalid_argument.

Parameters
MMessage of the error (const char*).
Exceptions
std::invalid_argument

Definition at line 148 of file warning.hpp.

◆ RSVS3D_ERROR_LOGIC

#define RSVS3D_ERROR_LOGIC (   M)    (rsvs3d::error<std::logic_error>(M, __PRETTY_FUNCTION__, __FILE__, __LINE__, true))

Throw a logic_error.

Parameters
MMessage of the error (const char*).
Exceptions
std::logic_error

Definition at line 139 of file warning.hpp.

◆ RSVS3D_ERROR_NOTHROW

#define RSVS3D_ERROR_NOTHROW (   M)    (rsvs3d::error(M, __PRETTY_FUNCTION__, __FILE__, __LINE__, false))

Generic rsvs warning.

Parameters
MMessage of the warning (const char*).

Definition at line 120 of file warning.hpp.

◆ RSVS3D_ERROR_RANGE

#define RSVS3D_ERROR_RANGE (   M)    (rsvs3d::error<std::range_error>(M, __PRETTY_FUNCTION__, __FILE__, __LINE__, true))

Throw a range_error.

Parameters
MMessage of the error (const char*).
Exceptions
std::range_error

Definition at line 173 of file warning.hpp.

◆ RSVS3D_ERROR_TYPE

#define RSVS3D_ERROR_TYPE (   M,
 
)    (rsvs3d::error<T>(M, __PRETTY_FUNCTION__, __FILE__, __LINE__, true))

Throw a specific error type.

Parameters
MMessage of the warning (const char*).
Template Parameters
TType of the exception to throw.
Exceptions
T

Definition at line 130 of file warning.hpp.

Function Documentation

◆ CheckFStream()

template<class T >
void CheckFStream ( const T &  file,
const char *  callerID,
const std::string &  fileName 
)

Checks a file stream.

Parameters
[in]fileinput or output file stream
[in]callerIDthe name of the caller function as given by pretty function
[in]fileNameThe name of the file opened in the stream.
Template Parameters
Teither ifstream or ofstream, needs to support method T::is_open()

Definition at line 187 of file warning.hpp.