//**************************************************************************************************
//
// "NativeLib" LAST ERROR FUNCTIONALITY (TYPES):
//
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// NativeLib DLL (for DotNetHelpers) | C+- (SysRoutine) | Author: Sergei Y.Kitáev
#pragma once
namespace NativeLib {

//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
//
// "NLFailure" STATIC CLASS:
//
//==================================================================================================
class NLFailure
{
$STATIC_CLASS( NLFailure )
public:
   static bool HasError();
   static NLErrorCat Category();
   static bool IsGeneralError();
   static bool IsArgumentError();
   static bool IsOutOfMemoryError();
   static bool IsSystemError();
   static bool IsCOMError();
   static bool IsSpecialError();
public:
   static bool ResetError() $ret_true;
   static bool ResetError(bool threadInitVerification) $ret_true;
public:
   static bool SetError( NLErrorCat category $optional ) $ret_false;
   static bool SetError( NLErrorCat category $optional, INT code $optional ) $ret_false;
   static bool SetError( NLErrorCat category $optional, UINT uCode $optional ) $ret_false;
   static bool SetError( NLErrorCat category $optional,
                         INT code $optional, DWORD value $optional ) $ret_false;
   static bool SetError( NLErrorCat category $optional,
                         UINT uCode $optional, DWORD value $optional ) $ret_false;

   static bool SetError( PCWSTR message );
   static bool SetError( PCWSTR message $optional, INT code $optional ) $ret_false;
   static bool SetError( PCWSTR message $optional, UINT uCode $optional ) $ret_false;
   static bool SetError( PCWSTR message $optional, INT code $optional, DWORD value $optional )
                         $ret_false;
   static bool SetError( PCWSTR message $optional, UINT uCode $optional, DWORD value $optional )
                         $ret_false;

   static bool SetError( NLErrorCat category $optional, PCWSTR message $optional ) $ret_false;
   static bool SetError( NLErrorCat category $optional, PCWSTR message $optional,
                         INT code $optional ) $ret_false;
   static bool SetError( NLErrorCat category $optional, PCWSTR message $optional,
                         UINT uCode $optional ) $ret_false;
   static bool SetError( NLErrorCat category $optional, PCWSTR message $optional,
                         INT code $optional, DWORD value $optional ) $ret_false;
   static bool SetError( NLErrorCat category $optional, PCWSTR message $optional,
                         UINT uCode $optional, DWORD value $optional ) $ret_false;
public:
   static bool SetArgumentError() $ret_false;
   static bool SetArgumentError( PCWSTR message $optional ) $ret_false;

   static bool SetOutOfMemoryError() $ret_false;

   static bool SetSpecialError( PCWSTR message );
   static bool SetSpecialError( PCWSTR message $optional, INT code $optional ) $ret_false;
   static bool SetSpecialError( PCWSTR message $optional, UINT uCode $optional ) $ret_false;
   static bool SetSpecialError( PCWSTR message $optional, INT code $optional,
                                DWORD value $optional ) $ret_false;
   static bool SetSpecialError( PCWSTR message $optional, UINT uCode $optional,
                                DWORD value $optional ) $ret_false;
public:
   static bool SetSystemError( DWORD dwError ) $ret_false;
   static bool SetSystemError($A, PCWSTR message ) $ret_false;
   static bool SetSystemError( PCWSTR headerMessage $optional, DWORD dwError ) $ret_false;
   static bool SetWin32FuncFailure($A, PCWSTR functionName ) $ret_false;
   static bool SetFromLastSystemError() $ret_false;
   static bool SetFromLastSystemError( PCWSTR headerMessage $optional ) $ret_false;

   static bool SetCOMError( HRESULT hResult ) $ret_false;
   static bool SetCOMError($A, PCWSTR message ) $ret_false;
   static bool SetCOMError( PCWSTR headerMessage $optional, HRESULT hResult ) $ret_false;

   static bool SetFromLastRTError() $ret_false;
   static bool SetFromLastRTError( PCWSTR headerMessage $optional ) $ret_false;
public:
   static bool SetFromErrorInfo($A, const $ErrorInfo& errorInfo ) $ret_false;
public:
   static bool SetFormatAllocFailure() $ret_false;
public:
   static const NLError& Error();
   static void SetMessageRetransQuery();
   static NLErrorCat CategoryFromErrorType($ErrorType errorType);
public:
#include "NLFailure.Fmt.h"
#include "NLFailure.FmtVA.h"
private:
   static bool SetSystemErrorEx( PCWSTR headerMessage $optional,
                                 DWORD dwError, bool isCOMError ) $ret_false;
   static NLError* FreeErrorData() $not_null;
   static NLError* DataPtr() $not_null $fatal_error_on_failure;
   static NLError* GetDataPtr();
}; // NLFailure
//==================================================================================================

} // NativeLib
