//**************************************************************************************************
//
// LAST ERROR SUPPORT (TYPES):
//
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// RuntimeForStatic base library | C+- (SysRoutine) | Author: Sergei Y.Kitáev
#pragma once
#include "include_restrictions.h"
namespace RuntimeForStatic {

//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
//
// "$LE" STATIC CLASS — LAST ERROR SUPPORT FOR USER/LIBRARY API (THREAD STATIC INFO):
//
//==================================================================================================
class $LE $thread_static
{
$STATIC_CLASS( $LE )
public:
   static bool IsInitialized() $thread_static;
   static void VerifyInitialized($O) $thread_static $requires_rt_n_thread_init;
public:
   static bool HasError();
   static bool Success();
   static bool IsWarning();
   static $ErrorType ErrorType();

   static bool IsWin32Error();
   static bool IsCOMError();
   static bool IsWin32OrCOMError();
   static bool IsCustomError();
   static bool IsUnknownError();

   static int IntCode();
   static DWORD DWordCode();

   DWORD Win32Error($O) $fatal_error_on_failure;
   HRESULT COMError($O) $fatal_error_on_failure;
   static DWORD Win32ErrorOrZero();
   static HRESULT COMErrorOrZero();
public:
   static $ErrorSign ErrorSign();

   static $DynText Message() $tenacious;
   static $DynText GetMessage(bool& messageGenerationProblem $out) $tenacious;
   static $DynText StrictMessage() $fatal_error_on_failure;
   static bool WasMessageProvided();
   static bool MessageGenerationProblem();

   static $ErrorInfo ErrorInfo() $tenacious;
   //static $ErrorInfo StrictErrorInfo() $fatal_error_on_failure;
public:
   static bool SetWin32Error( DWORD dwError ) $ret_false;

   static bool SetWin32Error($A, PCWSTR message ) $ret_false;
   static bool SetWin32ErrorFmt($A, PCWSTR messageFmt, ... ) $ret_false;
   static bool SetWin32ErrorFmtVA($A, PCWSTR messageFmt, va_list argList ) $ret_false;

   static bool SetWin32Error( PCWSTR headerMessage $optional, DWORD dwError ) $ret_false;
   static bool SetWin32ErrorFmt($A, DWORD dwError, PCWSTR headerMessageFmt, ... ) $ret_false;
   static bool SetWin32ErrorFmtVA($A, DWORD dwError, PCWSTR headerMessageFmt,
                                                     va_list argList ) $ret_false;

   static bool SetWin32FuncFailure($A, PCWSTR functionName ) $ret_false;
public:
   static bool SetCOMError( HRESULT status ) $ret_false;

   static bool SetCOMError($A, PCWSTR message ) $ret_false;
   static bool SetCOMErrorFmt($A, PCWSTR messageFmt, ... ) $ret_false;
   static bool SetCOMErrorFmtVA($A, PCWSTR messageFmt, va_list argList ) $ret_false;

   static bool SetCOMError( PCWSTR headerMessage $optional, HRESULT status ) $ret_false;
   static bool SetCOMErrorFmt($A, HRESULT status, PCWSTR headerMessageFmt, ... ) $ret_false;
   static bool SetCOMErrorFmtVA($A, HRESULT status, PCWSTR headerMessageFmt,
                                                    va_list argList ) $ret_false;
public:
   static bool SetErrorLastSystem() $ret_false;

   static bool SetErrorLastSystem( PCWSTR headerMessage $optional ) $ret_false;
   static bool SetErrorLastSystemFmt($A, PCWSTR headerMessageFmt, ... ) $ret_false;
   static bool SetErrorLastSystemFmtVA($A, PCWSTR headerMessageFmt, va_list argList ) $ret_false;
public:
   static bool SetError( PCWSTR message $optional ) $ret_false;
   static bool SetError( int code, PCWSTR message $optional ) $ret_false;
   static bool SetError( bool isWarning, int code, PCWSTR message $optional ) $ret_false;
   static bool SetError( bool isWarning, int code, int exCode, PCWSTR message $optional )
                         $ret_false;
   static bool SetError( bool isWarning, int code, DWORD exCode, PCWSTR message $optional )
                         $ret_false;
   static bool SetError( DWORD code, PCWSTR message $optional ) $ret_false;
   static bool SetError( bool isWarning, DWORD code, PCWSTR message $optional ) $ret_false;
   static bool SetError( bool isWarning, DWORD code, int exCode, PCWSTR message $optional )
                         $ret_false;
   static bool SetError( bool isWarning, DWORD code, DWORD exCode, PCWSTR message $optional )
                         $ret_false;
   static bool SetError($A, const $ErrorInfo& errorInfo ) $ret_false;

   static bool SetErrorFmt($A, PCWSTR messageFmt, ... ) $ret_false;
   static bool SetErrorFmt($A, int code, PCWSTR messageFmt, ... ) $ret_false;
   static bool SetErrorFmt($A, bool isWarning, int code, PCWSTR messageFmt, ... ) $ret_false;
   static bool SetErrorFmt($A, bool isWarning, int code, int exCode, PCWSTR messageFmt, ... )
                               $ret_false;
   static bool SetErrorFmt($A, bool isWarning, int code, DWORD exCode, PCWSTR messageFmt, ... )
                               $ret_false;
   static bool SetErrorFmt($A, DWORD code, PCWSTR messageFmt, ... ) $ret_false;
   static bool SetErrorFmt($A, bool isWarning, DWORD code, PCWSTR messageFmt, ... ) $ret_false;
   static bool SetErrorFmt($A, bool isWarning, DWORD code, int exCode, PCWSTR messageFmt, ... )
                               $ret_false;
   static bool SetErrorFmt($A, bool isWarning, DWORD code, DWORD exCode, PCWSTR messageFmt, ... )
                               $ret_false;

   static bool SetErrorFmtVA($A, PCWSTR messageFmt, va_list argList ) $ret_false;
   static bool SetErrorFmtVA($A, int code, PCWSTR messageFmt, va_list argList ) $ret_false;
   static bool SetErrorFmtVA($A, bool isWarning, int code, PCWSTR messageFmt, va_list argList )
                                 $ret_false;
   static bool SetErrorFmtVA($A, bool isWarning, int code, int exCode,
                                 PCWSTR messageFmt, va_list argList ) $ret_false;
   static bool SetErrorFmtVA($A, bool isWarning, int code, DWORD exCode,
                                 PCWSTR messageFmt, va_list argList ) $ret_false;
   static bool SetErrorFmtVA($A, DWORD code, PCWSTR messageFmt, va_list argList ) $ret_false;
   static bool SetErrorFmtVA($A, bool isWarning, DWORD code,
                                 PCWSTR messageFmt, va_list argList ) $ret_false;
   static bool SetErrorFmtVA($A, bool isWarning, DWORD code, int exCode,
                                 PCWSTR messageFmt, va_list argList ) $ret_false;
   static bool SetErrorFmtVA($A, bool isWarning, DWORD code, DWORD exCode,
                                 PCWSTR messageFmt, va_list argList ) $ret_false;
public:
   static bool SetCustomError( PCWSTR message $optional ) $ret_false;
   static bool SetCustomError( int code, PCWSTR message $optional ) $ret_false;
   static bool SetCustomError( bool isWarning, int code, PCWSTR message $optional ) $ret_false;
   static bool SetCustomError( bool isWarning, int code, int exCode, PCWSTR message $optional )
                               $ret_false;
   static bool SetCustomError( bool isWarning, int code, DWORD exCode, PCWSTR message $optional )
                               $ret_false;
   static bool SetCustomError( DWORD code, PCWSTR message $optional ) $ret_false;
   static bool SetCustomError( bool isWarning, DWORD code, PCWSTR message $optional )
                               $ret_false;
   static bool SetCustomError( bool isWarning, DWORD code, int exCode, PCWSTR message $optional )
                               $ret_false;
   static bool SetCustomError( bool isWarning, DWORD code, DWORD exCode, PCWSTR message $optional )
                               $ret_false;

   static bool SetCustomErrorFmt($A, PCWSTR messageFmt, ... ) $ret_false;
   static bool SetCustomErrorFmt($A, int code, PCWSTR messageFmt, ... ) $ret_false;
   static bool SetCustomErrorFmt($A, bool isWarning, int code, PCWSTR messageFmt, ... ) $ret_false;
   static bool SetCustomErrorFmt($A, bool isWarning, int code, int exCode,
                                     PCWSTR messageFmt, ... ) $ret_false;
   static bool SetCustomErrorFmt($A, bool isWarning, int code, DWORD exCode,
                                     PCWSTR messageFmt, ... ) $ret_false;
   static bool SetCustomErrorFmt($A, DWORD code, PCWSTR messageFmt, ... ) $ret_false;
   static bool SetCustomErrorFmt($A, bool isWarning, DWORD code,
                                     PCWSTR messageFmt, ... ) $ret_false;
   static bool SetCustomErrorFmt($A, bool isWarning, DWORD code, int exCode,
                                     PCWSTR messageFmt, ... ) $ret_false;
   static bool SetCustomErrorFmt($A, bool isWarning, DWORD code, DWORD exCode,
                                     PCWSTR messageFmt, ... ) $ret_false;

   static bool SetCustomErrorVA($A, PCWSTR messageFmt, va_list argList ) $ret_false;
   static bool SetCustomErrorVA($A, int code, PCWSTR messageFmt, va_list argList ) $ret_false;
   static bool SetCustomErrorVA($A, bool isWarning, int code, PCWSTR messageFmt, va_list argList )
                                    $ret_false;
   static bool SetCustomErrorVA($A, bool isWarning, int code, int exCode,
                                    PCWSTR messageFmt, va_list argList ) $ret_false;
   static bool SetCustomErrorVA($A, bool isWarning, int code, DWORD exCode,
                                    PCWSTR messageFmt, va_list argList ) $ret_false;
   static bool SetCustomErrorVA($A, DWORD code, PCWSTR messageFmt, va_list argList ) $ret_false;
   static bool SetCustomErrorVA($A, bool isWarning, DWORD code,
                                    PCWSTR messageFmt, va_list argList ) $ret_false;
   static bool SetCustomErrorVA($A, bool isWarning, DWORD code, int exCode,
                                    PCWSTR messageFmt, va_list argList ) $ret_false;
   static bool SetCustomErrorVA($A, bool isWarning, DWORD code, DWORD exCode,
                                    PCWSTR messageFmt, va_list argList ) $ret_false;
public:
   static bool SetErrorEx( const $ErrorSign& errorSign, PCWSTR message $optional ) $ret_false;
   static bool SetErrorExFmt($A, const $ErrorSign& errorSign, PCWSTR messageFmt, ... ) $ret_false;
   static bool SetErrorExFmtVA($A, const $ErrorSign& errorSign,
                                   PCWSTR messageFmt, va_list argList ) $ret_false;
public:
   static bool ResetError() $ret_true;
public:
   static void SetMessageGenerationProblem($A, PCWSTR staticText $persistent_ptr );
private:
#include "..\private\LE.private.h"
}; // $LE
//==================================================================================================

} // RuntimeForStatic
