Added documentation comments. Added a policy.
git-svn-id: svn://svn.code.sf.net/p/loki-lib/code/trunk@955 7ec92016-0320-0410-acc4-a06ded1c099a
This commit is contained in:
parent
0ecd4269ce
commit
fef3ad9a3b
1 changed files with 56 additions and 36 deletions
|
@ -45,18 +45,20 @@ namespace Loki
|
||||||
/// primitive (bool, int, etc...) a pointer, or an enum (such as an error
|
/// primitive (bool, int, etc...) a pointer, or an enum (such as an error
|
||||||
/// condition enum). It can work with other types that have cheap copy
|
/// condition enum). It can work with other types that have cheap copy
|
||||||
/// operations.
|
/// operations.
|
||||||
///
|
|
||||||
/// \par OnError Policy
|
|
||||||
/// - OnError is a policy class indicating how to handle the situation when a
|
/// - OnError is a policy class indicating how to handle the situation when a
|
||||||
/// caller does not check or copy the returned value. Loki provides some
|
/// caller does not check or copy the returned value. Loki provides some
|
||||||
/// policy classs and you may also write your own. For example, you can write
|
/// policy classs and you may also write your own. For example, you can write
|
||||||
/// a policy to throw an exception or create a message box when the function
|
/// a policy to create a message box when the function ignores the return value.
|
||||||
/// ignores the return value. If your write your own, you only need to provide
|
/// That would quickly tell you places where code ignores the function call.
|
||||||
/// a function named "run".
|
/// If your write your own, you only need a templated class or struct with a
|
||||||
|
/// public function named "run" that accepts a reference to a const value.
|
||||||
///
|
///
|
||||||
|
/// @par Provided Policy Classes
|
||||||
/// - IgnoreReturnValue Deliberately ignores when the caller ignores the return value.
|
/// - IgnoreReturnValue Deliberately ignores when the caller ignores the return value.
|
||||||
/// - TriggerAssert Asserts in debug builds if the caller ignores the return value.
|
/// - TriggerAssert Asserts in debug builds if the caller ignores the return value.
|
||||||
/// - FprintfStderr Prints out an error message if the caller ignores the return value.
|
/// - FprintfStderr Prints out an error message if the caller ignores the return value.
|
||||||
|
/// - ThrowTheValue Throws the ignored value as an exception.
|
||||||
|
/// - ThrowLogicError Throws a logic_error exception to indicate a programming error.
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
@ -69,6 +71,24 @@ struct IgnoreReturnValue
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
struct ThrowTheValue
|
||||||
|
{
|
||||||
|
static void run(const T & value )
|
||||||
|
{
|
||||||
|
throw value;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
struct ThrowLogicError
|
||||||
|
{
|
||||||
|
static void run( const T & )
|
||||||
|
{
|
||||||
|
throw ::std::logic_error( "CheckReturn: return value was not checked.\n" );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
struct TriggerAssert
|
struct TriggerAssert
|
||||||
{
|
{
|
||||||
|
@ -83,7 +103,7 @@ struct FprintfStderr
|
||||||
{
|
{
|
||||||
static void run(const T&)
|
static void run(const T&)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "CheckReturn: return value was not checked\n");
|
fprintf(stderr, "CheckReturn: return value was not checked.\n");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue