Library of Assembled Shared Sources
Enforcers

Detailed Description

enforcers are release-time counterpart of assertions to ease condition verifying

Author
[Bramz]

Enforcers are a tool described by Alexandrescu [1] [1] ALEXANDRESCU A. & MARGINEAN P. (2003), Enforcements. June 2003, C++ Experts Forum, http://www.cuj.com/documents/s=8250/cujcexp2106alexandr/alexandr.htm

Data Structures

class  lass::num::lass::util::EnforceFailure
 Exception thrown by enforcers. More...
 
struct  lass::python::impl::PythonFetchRaiser
 Raiser type for enforcers that raises a Python exception. More...
 
class  lass::util::EnforceFailure
 Exception thrown by enforcers. More...
 

Macros

#define LASS_ENFORCE(expression)
 Enforces the expression to be "true", by using operator!
 
#define LASS_ENFORCE_POINTER(pointer)
 Enforces a pointer to be different than the NULL pointer.
 
#define LASS_ENFORCE_STREAM(stream)
 Enforces a stream to be in the good state.
 
#define LASS_ENFORCE_ZERO(expression)
 Enforces the result of the expression to be zero.
 
#define LASS_ENFORCE_CLIB(functionCall)
 Enforces the return code of a CLIB function call to be different than -1.
 
#define LASS_ENFORCE_CLIB_RC(errorCode)
 Enforces the return code of a CLIB function call to be zero.
 
#define LASS_WARN_CLIB_RC(errorCode)
 Enforces the return code of a CLIB function call to be zero.
 
#define LASS_ENFORCE_COM(comResult)
 Enforces the HRESULT of a COM call to be 0 or more.
 
#define LASS_ENFORCE_INDEX(index, size)
 Enforces an index to be in the half open range [0, iSize).
 
#define LASS_ENFORCE_DYNAMIC_CAST(t_DestPointer, v_pointer)
 Enforces a pointer to an object to be dynamic casted to related type.
 
#define LASS_ENFORCE_DYNAMIC_PY_CAST(t_DestPyObjectPtr, v_pyObjectPtr)
 Enforces a python shared pointer to be dynamic casted to a related python shared pointer.
 

Macro Definition Documentation

◆ LASS_ENFORCE

#define LASS_ENFORCE ( expression)
Value:
*LASS_UTIL_IMPL_MAKE_ENFORCER(\
(expression), \
int(0), \
"Expression '" LASS_STRINGIFY(expression) "' failed in '" LASS_HERE "'.")
Predicate for enforcers using operator!

Enforces the expression to be "true", by using operator!

taken from: ALEXANDRESCU A. & MARGINEAN P. (2003), Enforcements. June 2003, C++ Experts Forum, http://www.cuj.com.

http://www.cuj.com/documents/s=8250/cujcexp2106alexandr

Definition at line 85 of file basic_ops.h.

◆ LASS_ENFORCE_CLIB

#define LASS_ENFORCE_CLIB ( functionCall)
Value:
*LASS_UTIL_IMPL_MAKE_ENFORCER(\
(functionCall), \
int(-1), \
"'" LASS_STRINGIFY(functionCall) "' in '" LASS_HERE "'")
Throws a run time exception for raisng LASS_ENFORCE_CLIB.
value must be different than closure

Enforces the return code of a CLIB function call to be different than -1.

Some CLIB functions return -1 on failure. An error code indicating the failure can be found using errno. LASS_ENFORCE_CLIB will enforce that the return value of the function call is not -1. If it is -1, it will rais a runtime exception with the error code errno and its string message translated by strerror().

Definition at line 141 of file basic_ops.h.

◆ LASS_ENFORCE_CLIB_RC

#define LASS_ENFORCE_CLIB_RC ( errorCode)
Value:
*LASS_UTIL_IMPL_MAKE_ENFORCER(\
(errorCode), \
int(0), \
"'" LASS_STRINGIFY(errorCode) "' in '" LASS_HERE "'")
Throws a run time exception for raisng LASS_ENFORCE_CLIB_RC.
value must be equal to closure

Enforces the return code of a CLIB function call to be zero.

Some CLIB functions return zero on success and an error code on failure. This error code can be translated to a string message with strerror(). LASS_ENFORCE_CLIB_RC will enforce that the return code of the function call is zero. If it's not, it will raise a runtime exception with the translated error code.

Definition at line 174 of file basic_ops.h.

◆ LASS_WARN_CLIB_RC

#define LASS_WARN_CLIB_RC ( errorCode)
Value:
*LASS_UTIL_IMPL_MAKE_ENFORCER(\
(errorCode), \
int(0), \
"'" LASS_STRINGIFY(errorCode) "' in '" LASS_HERE "'")
Throws a run time exception for raisng LASS_ENFORCE_CLIB_RC.

Enforces the return code of a CLIB function call to be zero.

Some CLIB functions return zero on success and an error code on failure. This error code can be translated to a string message with strerror(). LASS_ENFORCE_CLIB_RC will enforce that the return code of the function call is zero. If it's not, it will raise a runtime exception with the translated error code.

Definition at line 191 of file basic_ops.h.

◆ LASS_ENFORCE_DYNAMIC_CAST

#define LASS_ENFORCE_DYNAMIC_CAST ( t_DestPointer,
v_pointer )
Value:
*LASS_UTIL_IMPL_MAKE_ENFORCER(\
(dynamic_cast<t_DestPointer>(v_pointer)),\
int(0), \
"Unable to cast to '" LASS_STRINGIFY(t_DestPointer) "': '" LASS_STRINGIFY(v_pointer)\
"' is a null pointer or is not of the correct type, '" LASS_HERE "'.")

Enforces a pointer to an object to be dynamic casted to related type.

Parameters
t_DestPointerthe type of the pointer to be casted to.
v_pointera pointer to be casted (note that we don't cast references, use LASS_ENFORCE_DYNAMIC_REF_CAST for that)

Definition at line 270 of file basic_ops.h.

◆ LASS_ENFORCE_DYNAMIC_PY_CAST

#define LASS_ENFORCE_DYNAMIC_PY_CAST ( t_DestPyObjectPtr,
v_pyObjectPtr )
Value:
*LASS_UTIL_IMPL_MAKE_ENFORCER(\
int(0), \
"Unable to cast to '" LASS_STRINGIFY(t_DestPyObjectPtr) "': '" LASS_STRINGIFY(v_pyObjectPtr)\
"' is a null pointer or is not of the correct type, '" LASS_HERE "'.")
Out dynamicPyCast(const In &in)
dynamic_cast for python pointers

Enforces a python shared pointer to be dynamic casted to a related python shared pointer.

Parameters
t_DestPyObjectPtrthe type of python shared pointer to be casted to. So if you want to cast to PyObjectPtr<Foo>::Type, t_DestPyObjectPtr should be PyObjectPtr<Foo>::Type.
v_pyObjectPtra python shared pointer to be casted.

Definition at line 290 of file basic_ops.h.