#include <winstl/error/error_desc.hpp>
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()));
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. |
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.
basic_error_desc | ( | error_type | error = GetLastError() , |
|
char_type const * | modulePath = NULL | |||
) | [explicit] |
basic_error_desc | ( | HRESULT | hr, | |
char_type const * | modulePath = NULL | |||
) |
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.
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 |
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.
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.
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.