guards.h File Reference

#include "definitions.h"

Include dependency graph for guards.h:

Go to the source code of this file.

Namespaces

namespace  guards

Defines

#define bounds_return(value, low, high, to_return)   { if (((value) < (low)) || ((value) > (high))) return to_return; }
 Verifies that "value" is between "low" and "high", inclusive.
#define CAUSE_BREAKPOINT
 This macro wraps the notion of stopping in the debugger.
#define REQUIRE(check)   if (!check) CAUSE_BREAKPOINT;
 Tests the value "check" to ensure that it's not zero.
#define BH_ERROR_ADDITION   ((istring(" in ") + __argv[0]).s())
 an extra piece of information used, if available, in bounds_halt below.
#define bounds_halt(value, low, high, to_return)
 Verifies that "value" is between "low" and "high", inclusive.
#define non_continuable_error(c, f, i)
 Provide some macros that will automatically add the file and line number.
#define continuable_error(c, f, i)
#define console_error(c, f, i)   guards::FL_console_error(__FILE__, __LINE__, c, f, i)
#define deadly_error(c, f, i)   guards::FL_deadly_error(__FILE__, __LINE__, c, f, i)
#define out_of_memory_now(c, f)   guards::FL_out_of_memory_now(__FILE__, __LINE__, c, f)

Functions

template<class contents>
bool guards::in_range (const contents &value, const contents &low, const contents &high)
 Returns true if the value is within the range specified.
void guards::write_to_console (const char *message)
 Prints out a message to the standard error file stream.
void guards::alert_message (const char *info, const char *title="Alert Message")
 shows the message in "info", with an optional "title" on the message.
void guards::alert_message (const istring &info)
void guards::alert_message (const istring &info, const istring &title)
void guards::FL_deadly_error (const char *file, int line, const char *classname, const char *function_name, const char *info)
 Prints out an error message and then exits the program.
void guards::FL_deadly_error (const istring &file, int line, const istring &classname, const istring &function_name, const istring &info)
 A version that takes strings instead of char pointers.
void guards::FL_continuable_error (const char *file, int line, const char *classname, const char *function_name, const char *info, const char *title)
 Describes an error like deadly_error, but does not exit the program.
void guards::FL_continuable_error (const istring &file, int line, const istring &classname, const istring &function_name, const istring &info, const istring &title)
 A version using istring instead of char pointers.
void guards::FL_non_continuable_error (const char *file, int line, const char *classname, const char *function_name, const char *info, const char *title)
 Shows the same information as continuable_error, but causes an exit.
void guards::FL_non_continuable_error (const istring &file, int line, const istring &classname, const istring &function_name, const istring &info, const istring &title)
 A version using istring instead of char pointers.
void guards::FL_out_of_memory_now (const char *file, int line, const char *classname, const char *function_name)
 Causes the program to exit due to a memory allocation failure.
void guards::FL_console_error (const char *file, int line, const char *error_class, const char *error_function, const char *info)
 Prints out an error message to the standard error file stream.
void guards::make_error_message (const char *file, int line, const char *error_class, const char *error_function, const char *info, char *guards_message_space)
 Used to build our particular type of error message.
void guards::implement_bounds_halt (const char *the_class_name, const char *func, const char *value, const char *low, const char *high, const char *error_addition)
 Provides the real implementation of bounds_halt to save code space.


Define Documentation

#define BH_ERROR_ADDITION   ((istring(" in ") + __argv[0]).s())

an extra piece of information used, if available, in bounds_halt below.

Definition at line 88 of file guards.h.

#define bounds_halt ( value,
low,
high,
to_return   ) 

Value:

{ \
    if (((value) < (low)) || ((value) > (high))) { \
      guards::implement_bounds_halt(static_class_name(), func, #value, #low, \
          #high, BH_ERROR_ADDITION); \
      return 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.

Definition at line 100 of file guards.h.

Referenced by deep_array< contents >::acquire(), deep_array< contents >::get(), array< contents >::get(), matrix< contents >::insert_column(), mat_morph< contents >::insert_column(), matrix< contents >::insert_row(), mat_morph< contents >::insert_row(), deep_array< contents >::overwrite(), array< contents >::overwrite(), deep_array< contents >::put(), array< contents >::put(), deep_array< contents >::restore(), deep_array< contents >::store(), istring::substring(), deep_array< contents >::use(), array< contents >::use(), matrix< contents >::zap_column(), mat_morph< contents >::zap_column(), matrix< contents >::zap_row(), and mat_morph< contents >::zap_row().

#define bounds_return ( value,
low,
high,
to_return   )     { if (((value) < (low)) || ((value) > (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.

Definition at line 42 of file guards.h.

Referenced by geometric::angle< contents >::arccosine(), geometric::angle< contents >::arcsine(), averager< contents >::average(), amorph< contents >::borrow(), nodes::tree::branch(), bit_vector::clear(), istring::compare(), menu_base::enable_item(), menu_base::enable_submenu(), sequence< contents >::find(), system_values::get(), runtime_history::get(), command_line::get(), amorph< contents >::get(), version::get_component(), menu_base::get_item(), nodes::node::get_link(), buffer::get_packet(), menu_base::get_submenu(), amorph< contents >::insert(), istring::insert(), bit_vector::light(), symbol_table< contents >::name(), amorph< contents >::next_valid(), symbol_table< contents >::operator[](), bit_vector::operator[](), bit_vector::overwrite(), istring::oy_icompare(), buffer::packet_length(), nodes::tree::prune_index(), amorph< contents >::put(), buffer::release(), picture::remove(), symbol_table< contents >::retrieve(), bit_vector::set(), bit_vector::set_bit(), buffer::store_packet(), deep_array< contents >::subarray(), array< contents >::subarray(), bit_vector::subvector(), command_line::zap(), amorph< contents >::zap(), istring::zap(), array< contents >::zap(), menu_base::zap_item(), and menu_base::zap_submenu().

#define CAUSE_BREAKPOINT

This macro wraps the notion of stopping in the debugger.

Definition at line 47 of file guards.h.

Referenced by array< contents >::array(), and guards::FL_deadly_error().

#define console_error ( c,
f,
 )     guards::FL_console_error(__FILE__, __LINE__, c, f, i)

Definition at line 122 of file guards.h.

#define continuable_error ( c,
f,
 ) 

#define deadly_error ( c,
f,
 )     guards::FL_deadly_error(__FILE__, __LINE__, c, f, i)

#define non_continuable_error ( c,
f,
 ) 

#define out_of_memory_now ( c,
 )     guards::FL_out_of_memory_now(__FILE__, __LINE__, c, f)

Definition at line 126 of file guards.h.

#define REQUIRE ( check   )     if (!check) CAUSE_BREAKPOINT;

Tests the value "check" to ensure that it's not zero.

This can be used instead of an ASSERT macro to check conditions in builds with ERRORS_ARE_FATAL turned on. This macro is orthogonal to the build being built with debugging or release features.

Definition at line 67 of file guards.h.


Generated on Mon Jul 26 04:22:49 2010 for HOOPLE Libraries by  doxygen 1.5.6