basic_error_desc Class Template Reference
[Error Library]

#include <winstl/error/error_desc.hpp>

List of all members.


Detailed Description

template<typename C, typename T = system_traits<C>>
class winstl::basic_error_desc< C, T >

Utility class that loads the system string representation corresponding to a given error code.

Consider the following example:

  winstl::error_desc_a  ed1(ERROR_ACCESS_DENIED);
  winstl::error_desc_w  ed2(ERROR_ACCESS_DENIED);
  winstl::error_desc    ed3(ERROR_ACCESS_DENIED);

  assert(0 == ::strcmp("Access is denied", ed1.c_str()));
  assert(0 == ::wcscmp(L"Access is denied", ed2.c_str()));
  assert(0 == ::_tcscmp(_T("Access is denied"), ed3.c_str()));

By default, the strings are looked up from the Windows system DLLs. To use a specific message-string DLL, simply specify this as the second argument to the constructor, as in (assuming MyCustomDll.DLL maps ERROR_ACCESS_DENIED to "No Access!"):

  winstl::error_desc_a  ed1(ERROR_ACCESS_DENIED, "MyCustomDll.DLL");

  assert(0 == ::strcmp("No Access!", ed1.c_str()));

Note:
Naturally, String Access Shim functions c_str_ptr(_a/_w), c_str_data(_a/_w), c_str_len(_a/_w) are defined for the class template, so it may be manipulated generically. (This is very handy when used with the Pantheios logging library.)

Types

typedef C char_type
 The character type.
typedef T traits_type
 The traits_type.
typedef basic_error_desc< C, T > class_type
 The current parameterisation of the type.
typedef ws_dword_t error_type
 The error type.
typedef size_t size_type
 The size type.
typedef bool bool_type
 The boolean type.

Construction

 basic_error_desc (error_type error=GetLastError(), char_type const *modulePath=NULL)
 Loads the error string associated with the given code.
 basic_error_desc (HRESULT hr, char_type const *modulePath=NULL)
 Loads the error string associated with the given code.
template<typename S>
 basic_error_desc (error_type error, S const &modulePaths)
 Loads the error string associated with the given code from the first module in the given container of paths that contains a mapping.
 ~basic_error_desc () throw ()
 Releases any resources.
 basic_error_desc (class_type &rhs) throw ()
 This move constructor satisfies GCC, which misunderstands certain expressions containing non-mutating (const) references to instances of the type.

Public Member Functions

Attributes
char_type const * get_description () const
 The error description.
Accessors
char_type const * c_str () const
 The error description.
 operator char_type const * () const
 Implicit conversion operator that yields the error description.
size_type length () const throw ()
 The length of the error description.
size_type size () const throw ()
 The length of the error description.
bool_type empty () const throw ()
 Indicates whether the instance is empty.

Member Typedef Documentation

typedef C char_type

The character type.

typedef T traits_type

The traits_type.

The current parameterisation of the type.

typedef ws_dword_t error_type

The error type.

typedef size_t size_type

The size type.

typedef bool bool_type

The boolean type.


Constructor & Destructor Documentation

basic_error_desc ( error_type  error = GetLastError(),
char_type const *  modulePath = NULL 
) [explicit]

Loads the error string associated with the given code.

Parameters:
error The Win32 error whose string equivalent will be searched
modulePath The module in which the string will be searched
Note:
If the error string is not found in the given module, the standard system libraries will be searched

basic_error_desc ( HRESULT  hr,
char_type const *  modulePath = NULL 
)

Loads the error string associated with the given code.

Parameters:
hr The COM error whose string equivalent will be searched
modulePath The module in which the string will be searched
Note:
If the error string is not found in the given module, the standard system libraries will be searched

basic_error_desc ( error_type  error,
S const &  modulePaths 
) [inline]

Loads the error string associated with the given code from the first module in the given container of paths that contains a mapping.

Parameters:
error The Win32 error whose string equivalent will be searched
modulePaths A sequence container of paths, which will be searched incrementally for the error string
Note:
If the error string is not found in any of the given modules, the standard system libraries will be searched

References ss_typename_type_k, and stlsoft_ns_qual.

~basic_error_desc (  )  throw ()

Releases any resources.

basic_error_desc ( class_type rhs  )  throw ()

This move constructor satisfies GCC, which misunderstands certain expressions containing non-mutating (const) references to instances of the type.

Note:
Defined only for GCC compilation.


Member Function Documentation

char_type const* get_description (  )  const

The error description.

char_type const* c_str (  )  const

The error description.

operator char_type const * (  )  const

Implicit conversion operator that yields the error description.

Deprecated:
This will be removed in a future version.

size_type length (  )  const throw ()

The length of the error description.

size_type size (  )  const throw ()

The length of the error description.

bool_type empty (  )  const throw ()

Indicates whether the instance is empty.


The documentation for this class was generated from the following file:

Generated on Thu Jun 10 08:59:21 2010 for STLSoft by  doxygen 1.5.6