guards.h File Reference

#include "definitions.h"

Include dependency graph for guards.h:

This graph shows which files directly or indirectly include this file:

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,
 ) 

Value:

guards::FL_continuable_error(__FILE__, __LINE__, c, f, i, \
      "Runtime Problem Information")

Definition at line 119 of file guards.h.

Referenced by blowfish_decryption(), blowfish_encryption(), thread_cabinet::cancel_all(), system_checkup::check_system_characteristics(), compare(), version_checker::complain_cannot_load(), version_checker::complain_wrong_version(), blowfish_crypto::decrypt(), blowfish_crypto::encrypt(), infoton::fast_unpack(), cromp_transaction::flatten(), RSA_crypto::generate_key(), timer_driver::handle_system_timer(), guards::implement_bounds_halt(), octopus::remove_tentacle(), array< contents >::retrain(), RSA_crypto::set_key(), thread_cabinet::stop_all(), and cromp_transaction::unflatten().

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

Definition at line 124 of file guards.h.

Referenced by hash_table< key_type, contents >::acquire(), ADD(), hash_table< key_type, contents >::add(), ADD2(), hash_table< key_type, contents >::apply(), array_tester(), copy_hash_table(), deep_array_tester(), hash_table< key_type, contents >::elements(), fake_pack(), FIND(), hash_table< key_type, contents >::find(), formal(), guards::implement_bounds_halt(), main(), bookmark_tree::process_category(), nodes::symbol_tree::prune(), query_canvas(), query_desktop(), query_manager(), hash_table< key_type, contents >::rehash(), hash_table< key_type, contents >::reset(), array< contents >::resize(), array< contents >::retrain(), run_test_01(), run_test_02(), run_test_03(), run_test_04(), run_test_05(), run_test_06(), run_test_08(), run_test_09(), run_test_10(), run_test_11(), run_test_12(), run_test_14(), run_test_15(), run_test_16(), run_test_18(), run_test_19(), run_test_21(), run_test_22(), run_test_23(), run_test_24(), run_test_25(), run_test_28(), run_test_29(), run_test_31(), run_test_32(), run_test_33(), run_test_34(), run_test_35(), run_test_36(), run_test_37(), run_test_39(), run_test_40(), run_test_41(), byte_format::shifted_string_to_bytes(), test_bogon_amorph(), test_byte_array_amorph(), test_byte_table(), test_stack_with_objects(), test_stack_with_pointers(), test_string_table(), test_tc_table(), hash_table< key_type, contents >::zap(), array< contents >::zap(), and hash_table< key_type, contents >::~hash_table().

#define non_continuable_error ( c,
f,
 ) 

Value:

guards::FL_non_continuable_error(__FILE__, __LINE__, c, f, i, \
      "A Non-Continuable Runtime Problem Has Occurred")
Provide some macros that will automatically add the file and line number.

These use the functions below to report different types of error situations and in some cases, exit the program.

Definition at line 116 of file guards.h.

Referenced by hamming::corrupter(), worker::draw(), static_memory_gremlin::ensure_space_exists(), write_build_config::execute(), hamming::get_defaults(), hamming::init_lower_subnet(), hamming::init_upper_subnet(), hamming::init_with_unknown_pattern(), main(), nub::nub(), tiny_shell::OnClose(), palette::palette(), nub::parent(), nechung_oracle::pick_random(), bookmark_tree::process_category(), nodes::symbol_tree::prune(), bookmark_tree::read_csv_file(), hamming::read_file(), hamming::save_sample(), write_build_config::write_output_file(), safe_callback::~safe_callback(), and static_memory_gremlin::~static_memory_gremlin().

#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 Wed Jul 23 04:33:56 2008 for HOOPLE Libraries by  doxygen 1.5.1