forked from microsoft/calculator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCalculatorHistory.h
45 lines (40 loc) · 1.46 KB
/
CalculatorHistory.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#pragma once
#include "ExpressionCommandInterface.h"
#include "Header Files/IHistoryDisplay.h"
namespace CalculationManager
{
struct HISTORYITEMVECTOR
{
std::shared_ptr<std::vector<std::pair<std::wstring, int>>> spTokens;
std::shared_ptr<std::vector<std::shared_ptr<IExpressionCommand>>> spCommands;
std::wstring expression;
std::wstring result;
};
struct HISTORYITEM
{
HISTORYITEMVECTOR historyItemVector;
};
class CalculatorHistory : public IHistoryDisplay
{
public:
CalculatorHistory(const size_t maxSize);
unsigned int AddToHistory(
_In_ std::shared_ptr<std::vector<std::pair<std::wstring, int>>> const& spTokens,
_In_ std::shared_ptr<std::vector<std::shared_ptr<IExpressionCommand>>> const& spCommands,
std::wstring_view result);
std::vector<std::shared_ptr<HISTORYITEM>> const& GetHistory();
std::shared_ptr<HISTORYITEM> const& GetHistoryItem(unsigned int uIdx);
void ClearHistory();
unsigned int AddItem(_In_ std::shared_ptr<HISTORYITEM> const& spHistoryItem);
bool RemoveItem(unsigned int uIdx);
size_t MaxHistorySize() const
{
return m_maxHistorySize;
}
private:
std::vector<std::shared_ptr<HISTORYITEM>> m_historyItems;
const size_t m_maxHistorySize;
};
}