last_error_scope Class Reference
[Error Library]

#include <winstl/error/last_error_scope.hpp>

List of all members.


Detailed Description

A scoping class that scopes the thread's last error.

  DWORD   err = ::GetLastError();
  { winstl::last_error_scope  scope; // Scope the error while we change it

    // Some code that changes (or may change) the last error
    . . .

    ::SetLastError(ERROR_ACCESS_DENIED); // ... we just do this for pedagogical purposes

  } // End of scope - error value replaced to former value

  assert(::GetLastError() == err);

Public Types

Types
typedef last_error_scope class_type

Public Member Functions

Operations
 last_error_scope () throw ()
 Takes a copy of the current thread error, which will be reset on destruction of this instance.
 last_error_scope (ws_dword_t dwErr) throw ()
 Takes a copy of the current thread error, which will be reset on destruction of this instance.
 ~last_error_scope () throw ()
 Resets the thread error value current at the epoque of construction of this instance.
Operations
 operator ws_dword_t () const
 Returns the value of the recorded thread error, which will be reset on destruction of this instance.

Constructor & Destructor Documentation

last_error_scope (  )  throw () [inline]

Takes a copy of the current thread error, which will be reset on destruction of this instance.

last_error_scope ( ws_dword_t  dwErr  )  throw () [inline, explicit]

Takes a copy of the current thread error, which will be reset on destruction of this instance.

The current thread error is set to the given value.

Parameters:
dwErr The value to which the current thread error is set

~last_error_scope (  )  throw () [inline]

Resets the thread error value current at the epoque of construction of this instance.


Member Function Documentation

operator ws_dword_t (  )  const [inline]

Returns the value of the recorded thread error, which will be reset on destruction of this instance.


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