Initial
This commit is contained in:
115
com/hold/result.hpp
Normal file
115
com/hold/result.hpp
Normal file
@@ -0,0 +1,115 @@
|
||||
#ifndef _COM_RESULT_HPP_
|
||||
#define _COM_RESULT_HPP_
|
||||
#define COMMON_ENABLE_COM
|
||||
#ifndef _COMMON_WINDOWS_HPP_
|
||||
#include <common/windows.hpp>
|
||||
#endif
|
||||
#ifndef _COM_OLE2_HPP_
|
||||
#include <com/ole2.hpp>
|
||||
#endif
|
||||
|
||||
class ComResult
|
||||
{
|
||||
public:
|
||||
friend class ComObj;
|
||||
enum RCode{Success=S_OK,NoError=NOERROR,Error=S_FALSE,InvalidArg=E_INVALIDARG,OutOfMemory=E_OUTOFMEMORY,
|
||||
UnExpected=E_UNEXPECTED,ClassNotRegistered=REGDB_E_CLASSNOTREG,NoAggregation=CLASS_E_NOAGGREGATION,
|
||||
NoInterface=E_NOINTERFACE,Fail=E_FAIL,ArrayIsLocked=DISP_E_ARRAYISLOCKED,BadVarType=DISP_E_BADVARTYPE,
|
||||
BadIndex=DISP_E_BADINDEX};
|
||||
enum Facility{Windows=8,Storage=3,RPC=1,SSPI=9,Win32=7,Control=10,Null=0,Internet=12,Itf=4,Dispatch=2,Cert=11};
|
||||
ComResult(void);
|
||||
ComResult(const ComResult &comResult);
|
||||
ComResult(HRESULT hResult);
|
||||
virtual ~ComResult();
|
||||
ComResult &operator=(const ComResult &comResult);
|
||||
ComResult &operator=(HRESULT hResult);
|
||||
bool isFailure(void)const;
|
||||
RCode resultCode(void)const;
|
||||
BOOL success(void)const;
|
||||
HRESULT result(void)const;
|
||||
void result(HRESULT hResult);
|
||||
Facility facility(void)const;
|
||||
WORD error(void)const;
|
||||
private:
|
||||
HRESULT mhResult;
|
||||
};
|
||||
|
||||
inline
|
||||
ComResult::ComResult(void)
|
||||
: mhResult(Error)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
ComResult::ComResult(HRESULT hResult)
|
||||
: mhResult(hResult)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
ComResult::ComResult(const ComResult &comResult)
|
||||
{
|
||||
*this=comResult;
|
||||
}
|
||||
|
||||
inline
|
||||
ComResult::~ComResult()
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
ComResult &ComResult::operator=(const ComResult &comResult)
|
||||
{
|
||||
result(comResult.result());
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
ComResult &ComResult::operator=(HRESULT hResult)
|
||||
{
|
||||
result(hResult);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
ComResult::RCode ComResult::resultCode(void)const
|
||||
{
|
||||
return RCode(mhResult);
|
||||
}
|
||||
|
||||
inline
|
||||
HRESULT ComResult::result(void)const
|
||||
{
|
||||
return mhResult;
|
||||
}
|
||||
|
||||
inline
|
||||
void ComResult::result(HRESULT hResult)
|
||||
{
|
||||
mhResult=hResult;
|
||||
}
|
||||
|
||||
inline
|
||||
BOOL ComResult::success(void)const
|
||||
{
|
||||
return Success==RCode(mhResult&0x80000000);
|
||||
}
|
||||
|
||||
inline
|
||||
bool ComResult::isFailure(void)const
|
||||
{
|
||||
return !success();
|
||||
}
|
||||
|
||||
inline
|
||||
ComResult::Facility ComResult::facility(void)const
|
||||
{
|
||||
return Facility((mhResult>>16)&0xFFF);
|
||||
}
|
||||
|
||||
inline
|
||||
WORD ComResult::error(void)const
|
||||
{
|
||||
return mhResult&0xFFFF;
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user