ValOutOfRangeException< C > Class Template Reference

This exception is to be thrown when an index checking fails, providing informations on the acceptable index range and on the offending value. More...

#include <Exception.h>

Inheritance diagram for ValOutOfRangeException< C >:

OutOfRangeException ConsistencyCheckException ContextException Exception List of all members.

Public Member Functions

 ValOutOfRangeException (const std::string &context, const std::string &var_desc, C val, C inf, C sup) throw ()
 Construct the exception; minBound and maxBound are the bounds of the valid index range (inclusive).
virtual const char * type () const throw ()
 Get a string tag identifying the exception type.
virtual std::string desc () const throw ()
 Get a string describing what happened that threw the exception.
Methods used to get informations about the index and its bounds
virtual C val () const throw ()
 Get the value that caused the index to go out-of-bounds.
virtual C inf () const throw ()
 Get the minimum allowed value for this index.
virtual C sup () const throw ()
 Get the maximum allowed value for this index.

Protected Attributes

_val
_inf
_sup

Detailed Description

template<class C>
class ValOutOfRangeException< C >

This exception is to be thrown when an index checking fails, providing informations on the acceptable index range and on the offending value.

The context should be a description of the index, possibly preceeded by a description of in what context did the index checking happen.

Example:

  if (age < 18)
     throw IndexOutOfRangeException(age, 18, 0,
                                "obtaining driver license, age");

  if (i < 0 || i > 100)
    throw IndexOutOfRangeException(i, 0, 100, "percentage of items sold");


Constructor & Destructor Documentation

template<class C>
ValOutOfRangeException< C >::ValOutOfRangeException const std::string &  context,
const std::string &  var_desc,
val,
inf,
sup
throw () [inline]
 

Construct the exception; minBound and maxBound are the bounds of the valid index range (inclusive).


Member Function Documentation

template<class C>
virtual std::string ValOutOfRangeException< C >::desc  )  const throw () [inline, virtual]
 

Get a string describing what happened that threw the exception.

Reimplemented from OutOfRangeException.

template<class C>
virtual C ValOutOfRangeException< C >::inf  )  const throw () [inline, virtual]
 

Get the minimum allowed value for this index.

template<class C>
virtual C ValOutOfRangeException< C >::sup  )  const throw () [inline, virtual]
 

Get the maximum allowed value for this index.

template<class C>
virtual const char* ValOutOfRangeException< C >::type  )  const throw () [inline, virtual]
 

Get a string tag identifying the exception type.

Reimplemented from OutOfRangeException.

template<class C>
virtual C ValOutOfRangeException< C >::val  )  const throw () [inline, virtual]
 

Get the value that caused the index to go out-of-bounds.


Member Data Documentation

template<class C>
C ValOutOfRangeException< C >::_inf [protected]
 

template<class C>
C ValOutOfRangeException< C >::_sup [protected]
 

template<class C>
C ValOutOfRangeException< C >::_val [protected]
 


The documentation for this class was generated from the following file:
Generated on Wed Nov 30 18:18:30 2005 for libbuffy by  doxygen 1.4.5