// RuntimeForStatic base library | C+- (SysRoutine) | Author: Sergei Y.Kitáev
#include "Precompiled.h"
#include "SharedIncludes.h"
#include "LE.internal.h"
namespace RuntimeForStatic {
//==================================================================================================

bool $LE::SetCOMError(HRESULT status) $ret_false
{
   return SetSystemError( nullptr, status, true );
}

//--------------------------------------------------------------------------------------------------

bool $LE::SetCOMError($A, PCWSTR message ) $ret_false
{
   return SetErrorEx( $ErrorSign::CreateCOM(), message );
}

bool $LE::SetCOMErrorFmt($A, PCWSTR messageFmt, ... ) $ret_false
{
   $$VERIFY_POINTER_ARG( messageFmt );
   va_list argList;
   SetCOMErrorFmtVA($ci, $VA_COMPLEMENT( messageFmt, argList ) );
   va_end( argList );
   return $RESET_LAST_SYS_ERROR( false );
}
bool $LE::SetCOMErrorFmtVA($A, PCWSTR messageFmt, va_list argList ) $ret_false
{
   return SetErrorExFmtVA($ci, $ErrorSign::CreateCOM(), messageFmt, argList );
}

//--------------------------------------------------------------------------------------------------

bool $LE::SetCOMError( PCWSTR headerMessage $optional, HRESULT status ) $ret_false
{
   return SetSystemError( headerMessage, status, true );
}
bool $LE::SetCOMErrorFmt($A, HRESULT status, PCWSTR headerMessageFmt, ... ) $ret_false
{
   $$VERIFY_POINTER_ARG( headerMessageFmt );
   va_list argList;
   SetCOMErrorFmtVA($ci, status, $VA_COMPLEMENT( headerMessageFmt, argList ) );
   va_end( argList );
   return $RESET_LAST_SYS_ERROR( false );
}
bool $LE::SetCOMErrorFmtVA($A, HRESULT status, PCWSTR headerMessageFmt,
                                               va_list argList ) $ret_false
{
   $$VERIFY_POINTER_ARG( headerMessageFmt );
   PWSTR pHeaderMessage = HelpersRT::FormatAllocVA($, headerMessageFmt, argList );
   $AUTO_FREE( pHeaderMessage );
   return pHeaderMessage ? SetCOMError( pHeaderMessage, status ) : SetFormatAllocFailure();
}

//==================================================================================================
} // RuntimeForStatic
