merge with master

This commit is contained in:
Rudy Huyn
2019-12-02 19:36:54 -08:00
parent 39885668ae
commit 73d6a32add
247 changed files with 27860 additions and 8218 deletions

View File

@@ -3,7 +3,6 @@
#include <string>
#include "Header Files/CCommand.h"
#include "CalculatorVector.h"
#include "ExpressionCommand.h"
using namespace std;
@@ -35,18 +34,18 @@ void CParentheses::Accept(_In_ ISerializeCommandVisitor& commandVisitor)
CUnaryCommand::CUnaryCommand(int command)
{
m_command = make_shared<CalculatorVector<int>>();
m_command->Append(command);
m_command = make_shared<vector<int>>();
m_command->push_back(command);
}
CUnaryCommand::CUnaryCommand(int command1, int command2)
{
m_command = make_shared<CalculatorVector<int>>();
m_command->Append(command1);
m_command->Append(command2);
m_command = make_shared<vector<int>>();
m_command->push_back(command1);
m_command->push_back(command2);
}
const shared_ptr<CalculatorVector<int>>& CUnaryCommand::GetCommands() const
const shared_ptr<vector<int>>& CUnaryCommand::GetCommands() const
{
return m_command;
}
@@ -58,15 +57,15 @@ CalculationManager::CommandType CUnaryCommand::GetCommandType() const
void CUnaryCommand::SetCommand(int command)
{
m_command->Clear();
m_command->Append(command);
m_command->clear();
m_command->push_back(command);
}
void CUnaryCommand::SetCommands(int command1, int command2)
{
m_command->Clear();
m_command->Append(command1);
m_command->Append(command2);
m_command->clear();
m_command->push_back(command1);
m_command->push_back(command2);
}
void CUnaryCommand::Accept(_In_ ISerializeCommandVisitor& commandVisitor)
@@ -99,7 +98,7 @@ void CBinaryCommand::Accept(_In_ ISerializeCommandVisitor& commandVisitor)
commandVisitor.Visit(*this);
}
COpndCommand::COpndCommand(shared_ptr<CalculatorVector<int>> const& commands, bool fNegative, bool fDecimal, bool fSciFmt)
COpndCommand::COpndCommand(shared_ptr<vector<int>> const& commands, bool fNegative, bool fDecimal, bool fSciFmt)
: m_commands(commands)
, m_fNegative(fNegative)
, m_fSciFmt(fSciFmt)
@@ -115,27 +114,25 @@ void COpndCommand::Initialize(Rational const& rat)
m_fInitialized = true;
}
const shared_ptr<CalculatorVector<int>>& COpndCommand::GetCommands() const
const shared_ptr<vector<int>>& COpndCommand::GetCommands() const
{
return m_commands;
}
void COpndCommand::SetCommands(shared_ptr<CalculatorVector<int>> const& commands)
void COpndCommand::SetCommands(shared_ptr<vector<int>> const& commands)
{
m_commands = commands;
}
void COpndCommand::AppendCommand(int command)
{
unsigned int nCommands;
m_commands->GetSize(&nCommands);
if (m_fSciFmt)
{
ClearAllAndAppendCommand(static_cast<CalculationManager::Command>(command));
}
else
{
m_commands->Append(command);
m_commands->push_back(command);
}
if (command == IDC_PNT)
@@ -146,14 +143,8 @@ void COpndCommand::AppendCommand(int command)
void COpndCommand::ToggleSign()
{
unsigned int commandCount;
m_commands->GetSize(&commandCount);
for (unsigned int i = 0; i < commandCount; i++)
for (int nOpCode : *m_commands)
{
int nOpCode;
m_commands->GetAt(i, &nOpCode);
if (nOpCode != IDC_0)
{
m_fNegative = !m_fNegative;
@@ -170,8 +161,7 @@ void COpndCommand::RemoveFromEnd()
}
else
{
unsigned int nCommands;
m_commands->GetSize(&nCommands);
const size_t nCommands = m_commands->size();
if (nCommands == 1)
{
@@ -179,13 +169,14 @@ void COpndCommand::RemoveFromEnd()
}
else
{
int nOpCode;
m_commands->GetAt(nCommands - 1, &nOpCode);
int nOpCode = m_commands->at(nCommands - 1);
if (nOpCode == IDC_PNT)
{
m_fDecimal = false;
}
m_commands->RemoveAt(nCommands - 1);
m_commands->pop_back();
}
}
}
@@ -212,8 +203,8 @@ CalculationManager::CommandType COpndCommand::GetCommandType() const
void COpndCommand::ClearAllAndAppendCommand(CalculationManager::Command command)
{
m_commands->Clear();
m_commands->Append(static_cast<int>(command));
m_commands->clear();
m_commands->push_back(static_cast<int>(command));
m_fSciFmt = false;
m_fNegative = false;
m_fDecimal = false;
@@ -223,31 +214,29 @@ const wstring& COpndCommand::GetToken(wchar_t decimalSymbol)
{
static const wchar_t chZero = L'0';
unsigned int nCommands;
m_commands->GetSize(&nCommands);
const size_t nCommands = m_commands->size();
m_token.clear();
int nOpCode;
for (unsigned int i = 0; i < nCommands; i++)
for (size_t i = 0; i < nCommands; i++)
{
m_commands->GetAt(i, &nOpCode);
int nOpCode = (*m_commands)[i];
if (nOpCode == IDC_PNT)
{
m_token.append(wstring{ decimalSymbol });
m_token += decimalSymbol;
}
else if (nOpCode == IDC_EXP)
{
m_token.append(&chExp);
int nextOpCode;
m_commands->GetAt(i + 1, &nextOpCode);
m_token += chExp;
int nextOpCode = m_commands->at(i + 1);
if (nextOpCode != IDC_SIGN)
{
m_token.append(&chPlus);
m_token += chPlus;
}
}
else if (nOpCode == IDC_SIGN)
{
m_token.append(&chNegate);
m_token += chNegate;
}
else
{
@@ -257,7 +246,7 @@ const wstring& COpndCommand::GetToken(wchar_t decimalSymbol)
}
// Remove zeros
for (unsigned int i = 0; i < m_token.size(); i++)
for (size_t i = 0; i < m_token.size(); i++)
{
if (m_token.at(i) != chZero)
{
@@ -272,29 +261,26 @@ const wstring& COpndCommand::GetToken(wchar_t decimalSymbol)
if (m_fNegative)
{
m_token.insert(0, &chNegate);
m_token.insert(0, 1, chNegate);
}
return m_token;
}
}
m_token.clear();
m_token.append(&chZero);
m_token = chZero;
return m_token;
}
wstring COpndCommand::GetString(uint32_t radix, int32_t precision)
{
wstring result{};
if (m_fInitialized)
{
result = m_value.ToString(radix, eNUMOBJ_FMT::FMT_FLOAT, precision);
return m_value.ToString(radix, eNUMOBJ_FMT::FMT_FLOAT, precision);
}
return result;
return wstring{};
}
void COpndCommand::Accept(_In_ ISerializeCommandVisitor& commandVisitor)