//**************************************************************************************************
//
// INTERNAL RUNTIME HELPERS (TYPES):
//
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// RuntimeForStatic base library | C+- (SysRoutine) | Author: Sergei Y.Kitáev
#pragma once
namespace RuntimeForStatic {

//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
//
// "HelpersRT" STATIC CLASS:
//
//==================================================================================================
class HelpersRT
{
$STATIC_CLASS( HelpersRT )
public:
// GENERAL (MISC.):
   static bool TLSAlloc($A,DWORD volatile* pIndex $out) $last_system_error;

   static PWSTR GetSystemMessage($M,DWORD dwError) $null_on_failure $last_system_error $needs_free;
   static PWSTR GetLastSystemMessage($M) $null_on_failure $last_system_error $needs_free;

   static PWSTR GetExeName($M) $null_on_failure $needs_free;
   static PWSTR GetExePath($M) $null_on_failure $needs_free;
   static PWSTR GetExeBaseName($M) $null_on_failure $needs_free;
public:
// STRING MANIPULATION:
   static PWSTR IntToStr($M,int value) $null_on_failure $needs_free;

   static PWSTR DuplicateSZ($AM,PCWSTR source) $null_on_failure $needs_free;
   static PWSTR DuplicateStr($AM,PCWSTR source,int length) $null_on_failure $needs_free;
   static PWSTR ToUnicodeSZ($AM,PCSTR ansiStr) $null_on_failure $needs_free;
   static PWSTR FormatAlloc($AM,PCWSTR messageFmt, ... ) $null_on_failure $needs_free;
   static PWSTR FormatAllocVA($AM,PCWSTR messageFmt,va_list argList) $null_on_failure $needs_free;

   static PWSTR DuplicateSZ($A,$M, PCWSTR source ) $null_on_failure $needs_free;
   static PWSTR DuplicateStr($A,$M, PCWSTR source, int length ) $null_on_failure $needs_free;
   static PWSTR ToUnicodeSZ($A,$M, PCSTR ansiStr ) $null_on_failure $needs_free;
   static PWSTR FormatAlloc($A,$M, PCWSTR messageFmt, ... ) $null_on_failure $needs_free;
   static PWSTR FormatAllocVA($A,$M, PCWSTR messageFmt, va_list argList )
                                     $null_on_failure $needs_free;
public:
// MEMORY ALLOCATION:
   static PVOID Allocate($AM, SIZE_T size $not_zero ) $null_on_failure $needs_free;
   static PVOID Allocate($AM, SIZE_T size $not_zero, int count ) $null_on_failure $needs_free;
   static PVOID CleanAlloc($AM, SIZE_T size $not_zero ) $null_on_failure $needs_free;
   static PVOID CleanAlloc($AM, SIZE_T size $not_zero, int count ) $null_on_failure $needs_free;
   static PVOID ReAllocate($AM, PVOID memoryBlock, SIZE_T size $not_zero )
                                $null_on_failure $needs_free;
   static PVOID ReAllocate($AM, PVOID memoryBlock, SIZE_T size $not_zero, int count $not_zero )
                                $null_on_failure $needs_free;

   static PVOID Allocate($A,$M, SIZE_T size $not_zero ) $null_on_failure $needs_free;
   static PVOID Allocate($A,$M, SIZE_T size $not_zero, int count ) $null_on_failure $needs_free;
   static PVOID CleanAlloc($A,$M, SIZE_T size $not_zero ) $null_on_failure $needs_free;
   static PVOID CleanAlloc($A,$M, SIZE_T size $not_zero, int count ) $null_on_failure $needs_free;
   static PVOID ReAllocate($A,$M, PVOID memoryBlock, SIZE_T size $not_zero )
                                  $null_on_failure $needs_free;
   static PVOID ReAllocate($A,$M, PVOID memoryBlock, SIZE_T size $not_zero, int count $not_zero )
                                  $null_on_failure $needs_free;
public:
// TRACE:
   static $Status Trace();
   static $Status Trace($A,PCWSTR message);
   static $Status TraceFmt($A,PCWSTR messageFmt, ... );
   static $Status TraceVA($A,PCWSTR messageFmt,va_list argList);

   static $Status TraceInformation();
   static $Status TraceInformation($A,PCWSTR message);
   static $Status TraceInformationFmt($A,PCWSTR messageFmt, ... );
   static $Status TraceInformationVA($A,PCWSTR messageFmt,va_list argList);

   static $Status TraceWarning();
   static $Status TraceWarning($A,PCWSTR message);
   static $Status TraceWarningFmt($A,PCWSTR messageFmt, ... );
   static $Status TraceWarningVA($A,PCWSTR messageFmt,va_list argList);

   static $Status TraceError();
   static $Status TraceError($A,PCWSTR message);
   static $Status TraceErrorFmt($A,PCWSTR messageFmt, ... );
   static $Status TraceErrorVA($A,PCWSTR messageFmt,va_list argList);

   static $Status TraceOperation($A,PCWSTR message);
   static $Status TraceOperationFmt($A,PCWSTR messageFmt, ... );
   static $Status TraceOperationVA($A,PCWSTR messageFmt,va_list argList);

   static $Status TraceInFunction($A,PCWSTR funcNameOrSignature);
   static $Status TraceOutOfFunction($A,PCWSTR funcNameOrSignature);

   static $Status TraceEx($A,$TraceMessageType messageType);
   static $Status TraceEx($A,$TraceMessageType messageType,PCWSTR message);
   static $Status TraceExFmt($A,$TraceMessageType messageType,PCWSTR messageFmt, ... );
   static $Status TraceExVA($A,$TraceMessageType messageType,PCWSTR messageFmt,va_list argList);

   static PCWSTR TraceErrorToMessage($Status status) $not_null $static_pointer;

   static const $Status
      TraceError_FormatMessage= 1,
      TraceError_ExeName      = 2;
private:
   static const $TraceMessageType
      _OperationTraceMessageType_    = $TraceMessageType_Neutral,
      _InOutFunctionTraceMessageType_= $TraceMessageType_Neutral;
}; // HelpersRT
//==================================================================================================

} // RuntimeForStatic
