feisty meow concerns codebase
2.140
|
Go to the source code of this file.
Namespaces | |
basis | |
The guards collection helps in testing preconditions and reporting errors. | |
Macros | |
#define | bounds_return(value, low, high, to_return) { if (!basis::in_range(value, low, high)) return to_return; } |
Verifies that "value" is between "low" and "high", inclusive. More... | |
#define | bounds_halt(value, low, high, to_return) |
Verifies that "value" is between "low" and "high", inclusive. More... | |
Functions | |
template<class contents > | |
bool | basis::in_range (const contents &value, const contents &low, const contents &high) |
Returns true if the value is within the range specified. More... | |
void | basis::format_error (const base_string &class_name, const base_string &func_name, const base_string &error_message, base_string &to_fill) |
writes a string "to_fill" in a nicely formatted manner using the class and function names. More... | |
void | basis::throw_error (const base_string &class_name, const base_string &func_name, const base_string &error_message) |
throws an error that incorporates the class name and function name. More... | |
void | basis::throw_error (const astring &class_name, const astring &func_name, const astring &error_message) |
synonym method using astrings for easier char * handling. More... | |
#define bounds_halt | ( | value, | |
low, | |||
high, | |||
to_return | |||
) |
Verifies that "value" is between "low" and "high", inclusive.
"Value" must be an object for which greater than and less than are defined. The static_class_name() method and func definition are used to tag the complaint that is emitted when problems are detected. Note that if CATCH_ERRORS is defined, then the program is halted if the value is out of bounds. Otherwise, the "to_return" value is returned.
#define bounds_return | ( | value, | |
low, | |||
high, | |||
to_return | |||
) | { if (!basis::in_range(value, low, high)) return to_return; } |
Verifies that "value" is between "low" and "high", inclusive.
When the number is not in bounds, the function that is currently executing returns the "to_return" default provided. "to_return" can be empty for functions that return void. Note: it is also considered a failure for high to be less than low.