Reaktoro  v2.11.0
A unified framework for modeling chemically reactive systems
Common

The module in Reaktoro in which methods and classes commonly used in other modules are implemented. More...

Classes

struct  Exception
 Provides a convenient way to initialized an exception with helpful error messages. More...
 

Macros

#define RaiseError(exception)    throw std::runtime_error(Reaktoro::internal::message(exception, __FILE__, __LINE__));
 Define a macro to raise a runtime exception from an Exception instance. More...
 
#define RuntimeError(errorstr, reasonstr)
 Define a macro to raise a runtime exception from a error string and a reason string. More...
 
#define Assert(condition, errorstr, reasonstr)
 Define a macro to raise a runtime exception from a error string and a reason string. More...
 
#define warningif(condition, ...)
 Define a macro to print a warning message if condition is true. More...
 
#define warningifnot(condition, ...)
 Define a macro to print a warning message if an expected condition is not true. More...
 
#define errorif(condition, ...)
 Define a macro to raise a runtime exception if condition is true. More...
 
#define errorifnot(condition, ...)
 Define a macro to raise a runtime exception if an expected condition is not true. More...
 

Detailed Description

The module in Reaktoro in which methods and classes commonly used in other modules are implemented.

Macro Definition Documentation

◆ RaiseError

#define RaiseError (   exception)     throw std::runtime_error(Reaktoro::internal::message(exception, __FILE__, __LINE__));

Define a macro to raise a runtime exception from an Exception instance.

See also
Exception

◆ RuntimeError

#define RuntimeError (   errorstr,
  reasonstr 
)
Value:
{ \
Reaktoro::Exception exception; \
exception.error << errorstr; \
exception.reason << reasonstr; \
RaiseError(exception); \
}

Define a macro to raise a runtime exception from a error string and a reason string.

See also
Exception

◆ Assert

#define Assert (   condition,
  errorstr,
  reasonstr 
)
Value:
{ \
if(!(condition)) { \
Reaktoro::Exception exception; \
exception.error << errorstr; \
exception.reason << reasonstr; \
RaiseError(exception); \
} \
}

Define a macro to raise a runtime exception from a error string and a reason string.

See also
Exception

◆ warningif

#define warningif (   condition,
  ... 
)
Value:
{ \
if((condition)) { \
std::cerr << "\033[1;33m***WARNING***\n" << Reaktoro::str(__VA_ARGS__) << "\n\033[0m"; \
} \
}
auto str(Args... items) -> std::string
Concatenate the arguments into a string without any separator string.
Definition: StringUtils.hpp:73

Define a macro to print a warning message if condition is true.

Warning
Note the use of ... and VA_ARGS in the implementation.
The use of #define macro(args...) function(args) causes error in
MSVC compilers if compiler option /Zc:preprocessor (available in Visual
Studio 2019 v16.5) is not specified!

◆ warningifnot

#define warningifnot (   condition,
  ... 
)
Value:
{ \
if(!(condition)) { \
std::cerr << "\033[1;33m***WARNING***\n" << Reaktoro::str(__VA_ARGS__) << "\n\033[0m"; \
} \
}

Define a macro to print a warning message if an expected condition is not true.

◆ errorif

#define errorif (   condition,
  ... 
)
Value:
{ \
if((condition)) { \
throw std::runtime_error(Reaktoro::str("\033[1;31m***ERROR***\n", Reaktoro::str(__VA_ARGS__), "\n\033[0m")); \
} \
}

Define a macro to raise a runtime exception if condition is true.

Warning
Note the use of ... and VA_ARGS in the implementation.
The use of #define macro(args...) function(args) causes error in
MSVC compilers if compiler option /Zc:preprocessor (available in Visual
Studio 2019 v16.5) is not specified!

◆ errorifnot

#define errorifnot (   condition,
  ... 
)
Value:
{ \
if(!(condition)) { \
throw std::runtime_error(Reaktoro::str("\033[1;31m***ERROR***\n", Reaktoro::str(__VA_ARGS__), "\n\033[0m")); \
} \
}

Define a macro to raise a runtime exception if an expected condition is not true.