Replace HRESULT -> ResultCode(int32_t)

This commit is contained in:
Michał Janiszewski 2019-03-09 00:05:36 +01:00
commit 15e7e8d0aa
3 changed files with 22 additions and 20 deletions

View file

@ -13,7 +13,7 @@ using namespace std;
using namespace CalcEngine;
namespace {
void IFT(HRESULT hr)
void IFT(ResultCode hr)
{
if (FAILED(hr))
{

View file

@ -7,9 +7,9 @@ template <typename TType>
class CalculatorVector
{
public:
HRESULT GetAt(_In_opt_ unsigned int index, _Out_ TType *item)
ResultCode GetAt(_In_opt_ unsigned int index, _Out_ TType *item)
{
HRESULT hr = S_OK;
ResultCode hr = S_OK;
try
{
*item = m_vector.at(index);
@ -21,15 +21,15 @@ public:
return hr;
}
HRESULT GetSize(_Out_ unsigned int *size)
ResultCode GetSize(_Out_ unsigned int *size)
{
*size = static_cast<unsigned>(m_vector.size());
return S_OK;
}
HRESULT SetAt(_In_ unsigned int index, _In_opt_ TType item)
ResultCode SetAt(_In_ unsigned int index, _In_opt_ TType item)
{
HRESULT hr = S_OK;
ResultCode hr = S_OK;
try
{
m_vector[index] = item;
@ -41,9 +41,9 @@ public:
return hr;
}
HRESULT RemoveAt(_In_ unsigned int index)
ResultCode RemoveAt(_In_ unsigned int index)
{
HRESULT hr = S_OK;
ResultCode hr = S_OK;
if (index < m_vector.size())
{
m_vector.erase(m_vector.begin() + index);
@ -55,9 +55,9 @@ public:
return hr;
}
HRESULT InsertAt(_In_ unsigned int index, _In_ TType item)
ResultCode InsertAt(_In_ unsigned int index, _In_ TType item)
{
HRESULT hr = S_OK;
ResultCode hr = S_OK;
try
{
auto iter = m_vector.begin() + index;
@ -70,9 +70,9 @@ public:
return hr;
}
HRESULT Truncate(_In_ unsigned int index)
ResultCode Truncate(_In_ unsigned int index)
{
HRESULT hr = S_OK;
ResultCode hr = S_OK;
if (index < m_vector.size())
{
auto startIter = m_vector.begin() + index;
@ -85,9 +85,9 @@ public:
return hr;
}
HRESULT Append(_In_opt_ TType item)
ResultCode Append(_In_opt_ TType item)
{
HRESULT hr = S_OK;
ResultCode hr = S_OK;
try
{
m_vector.push_back(item);
@ -99,21 +99,21 @@ public:
return hr;
}
HRESULT RemoveAtEnd()
ResultCode RemoveAtEnd()
{
m_vector.erase(--(m_vector.end()));
return S_OK;
}
HRESULT Clear()
ResultCode Clear()
{
m_vector.clear();
return S_OK;
}
HRESULT GetString(_Out_ std::wstring* expression)
ResultCode GetString(_Out_ std::wstring* expression)
{
HRESULT hr = S_OK;
ResultCode hr = S_OK;
unsigned int nTokens = 0;
std::pair <std::wstring, int> currentPair;
hr = this->GetSize(&nTokens);
@ -144,7 +144,7 @@ public:
return hr;
}
HRESULT GetExpressionSuffix(_Out_ std::wstring* suffix)
ResultCode GetExpressionSuffix(_Out_ std::wstring* suffix)
{
*suffix = L" =";
return S_OK;

View file

@ -24,7 +24,7 @@
// R - Reserved - not currently used for anything
//
// r - reserved portion of the facility code. Reserved for internal
// use. Used to indicate HRESULT values that are not status
// use. Used to indicate int32_t values that are not status
// values, but are instead message ids for display strings.
//
// Facility - is the facility code
@ -34,6 +34,8 @@
// This format is based loosely on an OLE HRESULT and is compatible with the
// SUCCEEDED and FAILED macros as well as the HRESULT_CODE macro
typedef int32_t ResultCode;
// CALC_E_DIVIDEBYZERO
//
// The current operation would require a divide by zero to complete