RDKit
Open-source cheminformatics and machine learning.
Loading...
Searching...
No Matches
Invariant.h File Reference
#include <RDGeneral/export.h>
#include <cassert>
#include <string>
#include <iostream>
#include <stdexcept>
#include "BoostStartInclude.h"
#include <RDGeneral/RDLog.h>
#include "BoostEndInclude.h"

Go to the source code of this file.

Classes

class  Invar::Invariant
 

Namespaces

namespace  Invar
 

Macros

#define INVARIANT_EXCEPTION_METHOD   1
 
#define ASSERT_INVARIANT(expr, mess)   assert(expr)
 
#define CHECK_INVARIANT(expr, mess)
 
#define PRECONDITION(expr, mess)
 
#define POSTCONDITION(expr, mess)
 
#define UNDER_CONSTRUCTION(fn)
 
#define RANGE_CHECK(lo, x, hi)
 
#define URANGE_CHECK(x, hi)
 
#define TEST_ASSERT(expr)
 
#define rdcast   static_cast
 
#define RDUNUSED_PARAM(x)   (void)x;
 

Functions

RDKIT_RDGENERAL_EXPORT std::ostream & Invar::operator<< (std::ostream &s, const Invariant &inv)
 

Macro Definition Documentation

◆ ASSERT_INVARIANT

#define ASSERT_INVARIANT (   expr,
  mess 
)    assert(expr)

Definition at line 93 of file Invariant.h.

◆ CHECK_INVARIANT

#define CHECK_INVARIANT (   expr,
  mess 
)
Value:
if (!(expr)) { \
Invar::Invariant inv("Invariant Violation", mess, #expr, __FILE__, \
__LINE__); \
BOOST_LOG(rdErrorLog) << "\n\n****\n" << inv << "****\n\n"; \
throw inv; \
}
RDKIT_RDGENERAL_EXPORT RDLogger rdErrorLog

Definition at line 101 of file Invariant.h.

◆ INVARIANT_EXCEPTION_METHOD

#define INVARIANT_EXCEPTION_METHOD   1

Definition at line 37 of file Invariant.h.

◆ POSTCONDITION

#define POSTCONDITION (   expr,
  mess 
)
Value:
if (!(expr)) { \
Invar::Invariant inv("Post-condition Violation", mess, #expr, __FILE__, \
__LINE__); \
BOOST_LOG(rdErrorLog) << "\n\n****\n" << inv << "****\n\n"; \
throw inv; \
}

Definition at line 117 of file Invariant.h.

◆ PRECONDITION

#define PRECONDITION (   expr,
  mess 
)
Value:
if (!(expr)) { \
Invar::Invariant inv("Pre-condition Violation", mess, #expr, __FILE__, \
__LINE__); \
BOOST_LOG(rdErrorLog) << "\n\n****\n" << inv << "****\n\n"; \
throw inv; \
}

Definition at line 109 of file Invariant.h.

◆ RANGE_CHECK

#define RANGE_CHECK (   lo,
  x,
  hi 
)
Value:
if ((lo) > (hi) || (x) < (lo) || (x) > (hi)) { \
std::stringstream errstr; \
errstr << lo << " <= " << x << " <= " << hi; \
Invar::Invariant inv("Range Error", #x, errstr.str().c_str(), __FILE__, \
__LINE__); \
BOOST_LOG(rdErrorLog) << "\n\n****\n" << inv << "****\n\n"; \
throw inv; \
}

Definition at line 132 of file Invariant.h.

◆ rdcast

#define rdcast   static_cast

Definition at line 191 of file Invariant.h.

◆ RDUNUSED_PARAM

#define RDUNUSED_PARAM (   x)    (void)x;

Definition at line 196 of file Invariant.h.

◆ TEST_ASSERT

#define TEST_ASSERT (   expr)
Value:
if (!(expr)) { \
Invar::Invariant inv("Test Assert", "Expression Failed: ", #expr, \
__FILE__, __LINE__); \
BOOST_LOG(rdErrorLog) << "\n\n****\n" << inv << "****\n\n"; \
throw inv; \
}

Definition at line 152 of file Invariant.h.

◆ UNDER_CONSTRUCTION

#define UNDER_CONSTRUCTION (   fn)
Value:
Invar::Invariant inv("Incomplete Code", \
"This routine is still under development", fn, \
__FILE__, __LINE__); \
BOOST_LOG(rdErrorLog) << "\n\n****\n" << inv << "****\n\n"; \
throw inv;

Definition at line 125 of file Invariant.h.

◆ URANGE_CHECK

#define URANGE_CHECK (   x,
  hi 
)
Value:
if (x >= (hi)) { \
std::stringstream errstr; \
errstr << x << " < " << hi; \
Invar::Invariant inv("Range Error", #x, errstr.str().c_str(), __FILE__, \
__LINE__); \
BOOST_LOG(rdErrorLog) << "\n\n****\n" << inv << "****\n\n"; \
throw inv; \
}

Definition at line 142 of file Invariant.h.