mirror of
https://github.com/Microsoft/calculator.git
synced 2025-08-22 06:13:14 -07:00
Replace HRESULT -> ResultCode(int32_t)
This commit is contained in:
parent
382396d1ad
commit
15e7e8d0aa
3 changed files with 22 additions and 20 deletions
|
@ -13,7 +13,7 @@ using namespace std;
|
||||||
using namespace CalcEngine;
|
using namespace CalcEngine;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
void IFT(HRESULT hr)
|
void IFT(ResultCode hr)
|
||||||
{
|
{
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
{
|
{
|
||||||
|
|
|
@ -7,9 +7,9 @@ template <typename TType>
|
||||||
class CalculatorVector
|
class CalculatorVector
|
||||||
{
|
{
|
||||||
public:
|
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
|
try
|
||||||
{
|
{
|
||||||
*item = m_vector.at(index);
|
*item = m_vector.at(index);
|
||||||
|
@ -21,15 +21,15 @@ public:
|
||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT GetSize(_Out_ unsigned int *size)
|
ResultCode GetSize(_Out_ unsigned int *size)
|
||||||
{
|
{
|
||||||
*size = static_cast<unsigned>(m_vector.size());
|
*size = static_cast<unsigned>(m_vector.size());
|
||||||
return S_OK;
|
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
|
try
|
||||||
{
|
{
|
||||||
m_vector[index] = item;
|
m_vector[index] = item;
|
||||||
|
@ -41,9 +41,9 @@ public:
|
||||||
return hr;
|
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())
|
if (index < m_vector.size())
|
||||||
{
|
{
|
||||||
m_vector.erase(m_vector.begin() + index);
|
m_vector.erase(m_vector.begin() + index);
|
||||||
|
@ -55,9 +55,9 @@ public:
|
||||||
return hr;
|
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
|
try
|
||||||
{
|
{
|
||||||
auto iter = m_vector.begin() + index;
|
auto iter = m_vector.begin() + index;
|
||||||
|
@ -70,9 +70,9 @@ public:
|
||||||
return hr;
|
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())
|
if (index < m_vector.size())
|
||||||
{
|
{
|
||||||
auto startIter = m_vector.begin() + index;
|
auto startIter = m_vector.begin() + index;
|
||||||
|
@ -85,9 +85,9 @@ public:
|
||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT Append(_In_opt_ TType item)
|
ResultCode Append(_In_opt_ TType item)
|
||||||
{
|
{
|
||||||
HRESULT hr = S_OK;
|
ResultCode hr = S_OK;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
m_vector.push_back(item);
|
m_vector.push_back(item);
|
||||||
|
@ -99,21 +99,21 @@ public:
|
||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT RemoveAtEnd()
|
ResultCode RemoveAtEnd()
|
||||||
{
|
{
|
||||||
m_vector.erase(--(m_vector.end()));
|
m_vector.erase(--(m_vector.end()));
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT Clear()
|
ResultCode Clear()
|
||||||
{
|
{
|
||||||
m_vector.clear();
|
m_vector.clear();
|
||||||
return S_OK;
|
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;
|
unsigned int nTokens = 0;
|
||||||
std::pair <std::wstring, int> currentPair;
|
std::pair <std::wstring, int> currentPair;
|
||||||
hr = this->GetSize(&nTokens);
|
hr = this->GetSize(&nTokens);
|
||||||
|
@ -144,7 +144,7 @@ public:
|
||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT GetExpressionSuffix(_Out_ std::wstring* suffix)
|
ResultCode GetExpressionSuffix(_Out_ std::wstring* suffix)
|
||||||
{
|
{
|
||||||
*suffix = L" =";
|
*suffix = L" =";
|
||||||
return S_OK;
|
return S_OK;
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
// R - Reserved - not currently used for anything
|
// R - Reserved - not currently used for anything
|
||||||
//
|
//
|
||||||
// r - reserved portion of the facility code. Reserved for internal
|
// 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.
|
// values, but are instead message ids for display strings.
|
||||||
//
|
//
|
||||||
// Facility - is the facility code
|
// Facility - is the facility code
|
||||||
|
@ -34,6 +34,8 @@
|
||||||
// This format is based loosely on an OLE HRESULT and is compatible with the
|
// 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
|
// SUCCEEDED and FAILED macros as well as the HRESULT_CODE macro
|
||||||
|
|
||||||
|
typedef int32_t ResultCode;
|
||||||
|
|
||||||
// CALC_E_DIVIDEBYZERO
|
// CALC_E_DIVIDEBYZERO
|
||||||
//
|
//
|
||||||
// The current operation would require a divide by zero to complete
|
// The current operation would require a divide by zero to complete
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue