#include <exception.h>
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", age, 18, 0, "obtaining driver license"); if (i < 0 || i > 100) throw IndexOutOfRangeException("percentage of items sold", i, 0, 100, "checking input consistency");
Public Member Functions | |
| ValOutOfRange (const std::string &var_desc, C val, C inf, C sup, const std::string &context) 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 | |
| C | m_val |
| C | m_inf |
| C | m_sup |
| wibble::exception::ValOutOfRange< C >::ValOutOfRange | ( | const std::string & | var_desc, | |
| C | val, | |||
| C | inf, | |||
| C | sup, | |||
| const std::string & | context | |||
| ) | throw () [inline] |
Construct the exception; minBound and maxBound are the bounds of the valid index range (inclusive).
| virtual C wibble::exception::ValOutOfRange< C >::val | ( | ) | const throw () [inline, virtual] |
Get the value that caused the index to go out-of-bounds.
References wibble::exception::ValOutOfRange< C >::m_val.
| virtual C wibble::exception::ValOutOfRange< C >::inf | ( | ) | const throw () [inline, virtual] |
Get the minimum allowed value for this index.
References wibble::exception::ValOutOfRange< C >::m_inf.
| virtual C wibble::exception::ValOutOfRange< C >::sup | ( | ) | const throw () [inline, virtual] |
Get the maximum allowed value for this index.
References wibble::exception::ValOutOfRange< C >::m_sup.
| virtual const char* wibble::exception::ValOutOfRange< C >::type | ( | ) | const throw () [inline, virtual] |
| virtual std::string wibble::exception::ValOutOfRange< C >::desc | ( | ) | const throw () [virtual] |
Get a string describing what happened that threw the exception.
Reimplemented from wibble::exception::OutOfRange.
C wibble::exception::ValOutOfRange< C >::m_val [protected] |
Referenced by wibble::exception::ValOutOfRange< C >::val().
C wibble::exception::ValOutOfRange< C >::m_inf [protected] |
Referenced by wibble::exception::ValOutOfRange< C >::inf().
C wibble::exception::ValOutOfRange< C >::m_sup [protected] |
Referenced by wibble::exception::ValOutOfRange< C >::sup().
1.5.6