ML Reference
MeVis/Foundation/Sources/MLUtilities/mlRangeCasts.h File Reference

Configurable collection of safe casts for data value conversions. More...

#include "mlTypeDefs.h"
#include "mlErrorMacros.h"
#include "mlErrorOutput.h"
#include "mlSystemWarningsDisable.h"
#include <limits.h>
#include "mlSystemWarningsRestore.h"

Go to the source code of this file.

Classes

struct  _ml_numeric_limits< unsigned char >
struct  _ml_numeric_limits< signed char >
struct  _ml_numeric_limits< char >
struct  _ml_numeric_limits< unsigned short >
struct  _ml_numeric_limits< short >
struct  _ml_numeric_limits< unsigned int >
struct  _ml_numeric_limits< int >
struct  _ml_numeric_limits< unsigned long >
struct  _ml_numeric_limits< long >
struct  _ml_numeric_limits< unsigned long long >
struct  _ml_numeric_limits< long long >
struct  _MLIntegerRangeCheck< true, true, Target, Source >
struct  _MLIntegerRangeCheck< false, true, Target, Source >
struct  _MLIntegerRangeCheck< true, false, Target, Source >
struct  _MLIntegerRangeCheck< false, false, Target, Source >

Defines

#define _ML_COMPILE_RANGE_CASTS_WITH_CHECKS
 If this flag is enabled then range casts are compiled as pure casts to suppress precision warnings.
#define _ML_RANGE_ERROR_TYPE   ML_PRINT_FATAL_ERROR
 This definition determines which error type is used to report range errors; the default are fatal errors.

Functions

template<typename Target , typename Source >
Target mlrange_cast (Source arg)
 Generic version of checked ML casts.

Detailed Description

Configurable collection of safe casts for data value conversions.

Author:
Wolf Spindler
Date:
09/2010

Definition in file mlRangeCasts.h.


Define Documentation

#define _ML_COMPILE_RANGE_CASTS_WITH_CHECKS

If this flag is enabled then range casts are compiled as pure casts to suppress precision warnings.

If this flag is enabled then range casts are compiled as inline functions which casts the values and apply checks for valid ranges.

Definition at line 31 of file mlRangeCasts.h.

#define _ML_RANGE_ERROR_TYPE   ML_PRINT_FATAL_ERROR

This definition determines which error type is used to report range errors; the default are fatal errors.

Definition at line 34 of file mlRangeCasts.h.

Referenced by _MLIntegerRangeCheck< true, false, Target, Source >::checked_cast(), _MLIntegerRangeCheck< false, true, Target, Source >::checked_cast(), and _MLIntegerRangeCheck< true, true, Target, Source >::checked_cast().


Function Documentation

template<typename Target , typename Source >
Target mlrange_cast ( Source  arg) [inline]

Generic version of checked ML casts.

Do a cast to the given target type, with a range check if the value can be represented by the target type (otherwise a fatal error occurs). This is only defined for integer types.

Definition at line 208 of file mlRangeCasts.h.