mirror of
https://github.com/Microsoft/calculator.git
synced 2025-08-22 14:13:30 -07:00
Some more refactoring
This commit is contained in:
parent
2cfb2f2973
commit
874e049532
3 changed files with 44 additions and 36 deletions
|
@ -409,34 +409,36 @@ int CHistoryCollector::AddCommand(_In_ const std::shared_ptr<IExpressionCommand>
|
|||
//To Update the operands in the Expression according to the current Radix
|
||||
void CHistoryCollector::UpdateHistoryExpression(uint32_t radix, int32_t precision)
|
||||
{
|
||||
if (m_spTokens != nullptr)
|
||||
if (m_spTokens == nullptr)
|
||||
{
|
||||
unsigned int size;
|
||||
IFT(m_spTokens->GetSize(&size));
|
||||
return;
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; i < size; ++i)
|
||||
unsigned int size;
|
||||
IFT(m_spTokens->GetSize(&size));
|
||||
|
||||
for (unsigned int i = 0; i < size; ++i)
|
||||
{
|
||||
std::pair<std::wstring, int> token;
|
||||
IFT(m_spTokens->GetAt(i, &token));
|
||||
int commandPosition = token.second;
|
||||
if (commandPosition != -1)
|
||||
{
|
||||
std::pair<std::wstring, int> token;
|
||||
IFT(m_spTokens->GetAt(i, &token));
|
||||
int commandPosition = token.second;
|
||||
if (commandPosition != -1)
|
||||
std::shared_ptr<IExpressionCommand> expCommand;
|
||||
IFT(m_spCommands->GetAt(commandPosition, &expCommand));
|
||||
if (expCommand != nullptr && CalculationManager::CommandType::OperandCommand == expCommand->GetCommandType())
|
||||
{
|
||||
std::shared_ptr<IExpressionCommand> expCommand;
|
||||
IFT(m_spCommands->GetAt(commandPosition, &expCommand));
|
||||
if (expCommand != nullptr && CalculationManager::CommandType::OperandCommand == expCommand->GetCommandType())
|
||||
std::shared_ptr<COpndCommand> opndCommand = std::static_pointer_cast<COpndCommand>(expCommand);
|
||||
if (opndCommand != nullptr)
|
||||
{
|
||||
std::shared_ptr<COpndCommand> opndCommand = std::static_pointer_cast<COpndCommand>(expCommand);
|
||||
if (opndCommand != nullptr)
|
||||
{
|
||||
token.first = opndCommand->GetString(radix, precision, m_decimalSymbol);
|
||||
IFT(m_spTokens->SetAt(i, token));
|
||||
opndCommand->SetCommands(GetOperandCommandsFromString(token.first));
|
||||
}
|
||||
token.first = opndCommand->GetString(radix, precision, m_decimalSymbol);
|
||||
IFT(m_spTokens->SetAt(i, token));
|
||||
opndCommand->SetCommands(GetOperandCommandsFromString(token.first));
|
||||
}
|
||||
}
|
||||
}
|
||||
SetExpressionDisplay();
|
||||
}
|
||||
SetExpressionDisplay();
|
||||
}
|
||||
|
||||
void CHistoryCollector::SetDecimalSymbol(wchar_t decimalSymbol)
|
||||
|
|
|
@ -484,7 +484,8 @@ namespace CalculationManager
|
|||
{
|
||||
m_savedCommands.push_back(MEMORY_COMMAND_TO_UNSIGNED_CHAR(MemoryCommand::MemorizeNumber));
|
||||
|
||||
if (m_currentCalculatorEngine->FInErrorState()) {
|
||||
if (m_currentCalculatorEngine->FInErrorState())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -512,7 +513,8 @@ namespace CalculationManager
|
|||
{
|
||||
SaveMemoryCommand(MemoryCommand::MemorizedNumberLoad, indexOfMemory);
|
||||
|
||||
if (m_currentCalculatorEngine->FInErrorState()) {
|
||||
if (m_currentCalculatorEngine->FInErrorState())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -530,7 +532,8 @@ namespace CalculationManager
|
|||
{
|
||||
SaveMemoryCommand(MemoryCommand::MemorizedNumberAdd, indexOfMemory);
|
||||
|
||||
if (m_currentCalculatorEngine->FInErrorState()) {
|
||||
if (m_currentCalculatorEngine->FInErrorState())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -570,7 +573,8 @@ namespace CalculationManager
|
|||
{
|
||||
SaveMemoryCommand(MemoryCommand::MemorizedNumberSubtract, indexOfMemory);
|
||||
|
||||
if (m_currentCalculatorEngine->FInErrorState()) {
|
||||
if (m_currentCalculatorEngine->FInErrorState())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -614,7 +618,8 @@ namespace CalculationManager
|
|||
/// <param name="indexOfMemory">Index of the target memory</param>
|
||||
void CalculatorManager::MemorizedNumberSelect(_In_ unsigned int indexOfMemory)
|
||||
{
|
||||
if (m_currentCalculatorEngine->FInErrorState()) {
|
||||
if (m_currentCalculatorEngine->FInErrorState())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -629,7 +634,8 @@ namespace CalculationManager
|
|||
/// <param name="indexOfMemory">Index of the target memory</param>
|
||||
void CalculatorManager::MemorizedNumberChanged(_In_ unsigned int indexOfMemory)
|
||||
{
|
||||
if (m_currentCalculatorEngine->FInErrorState()) {
|
||||
if (m_currentCalculatorEngine->FInErrorState())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -338,7 +338,7 @@ void UnitConverter::DeSerialize(const wstring& serializedData)
|
|||
{
|
||||
Reset();
|
||||
|
||||
if (!serializedData.empty())
|
||||
if (serializedData.empty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue