calculator/src/CalcManager/ExpressionCommandInterface.h
Scott Freeman 6366e0c535 Replacing CalculatorVector usage with std::vector (#756)
* Replacing CalculatorVector usage with std::vector

Assumptions made here are that memory allocations
are not recoverable.  If it can be proved that an index
will be in range, then the indexing operation is used.
If not (without manual checks) the std::vector::at function
is used to throw an exception in case of a programmer bug.

* Changes based on PR feedback

Using auto& in CalculatorCollector::UpdateHistoryExpression
so the token.first value is properly updated.

Using range for loop to GenerateExpressions.

Setting isEditable directly to the result of boolean expression.

Using token.second directly instead of creating a
separate tokenCommandIndex variable.

* Fixing issue with generating expressions strings.

A space should not be added before the first item.
2019-10-30 10:55:13 -07:00

58 lines
1.5 KiB
C++

// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#pragma once
#include <memory> // for std::shared_ptr
#include <vector>
#include "Command.h"
class ISerializeCommandVisitor;
class IExpressionCommand
{
public:
virtual CalculationManager::CommandType GetCommandType() const = 0;
virtual void Accept(_In_ ISerializeCommandVisitor& commandVisitor) = 0;
};
class IOperatorCommand : public IExpressionCommand
{
public:
virtual void SetCommand(int command) = 0;
};
class IUnaryCommand : public IOperatorCommand
{
public:
virtual const std::shared_ptr<std::vector<int>>& GetCommands() const = 0;
virtual void SetCommands(int command1, int command2) = 0;
};
class IBinaryCommand : public IOperatorCommand
{
public:
virtual void SetCommand(int command) override = 0;
virtual int GetCommand() const = 0;
};
class IOpndCommand : public IExpressionCommand
{
public:
virtual const std::shared_ptr<std::vector<int>>& GetCommands() const = 0;
virtual void AppendCommand(int command) = 0;
virtual void ToggleSign() = 0;
virtual void RemoveFromEnd() = 0;
virtual bool IsNegative() const = 0;
virtual bool IsSciFmt() const = 0;
virtual bool IsDecimalPresent() const = 0;
virtual const std::wstring& GetToken(wchar_t decimalSymbol) = 0;
virtual void SetCommands(std::shared_ptr<std::vector<int>> const& commands) = 0;
};
class IParenthesisCommand : public IExpressionCommand
{
public:
virtual int GetCommand() const = 0;
};