-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsupportedFunctionsForTestDatabase.cpp
44 lines (36 loc) · 1.18 KB
/
supportedFunctionsForTestDatabase.cpp
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
//
// supportedFunctionsForTestDatabase.cpp
// DataBaseCourseProject
//
// Created by Sergei Ziuzev on 3/17/22.
// Copyright © 2019 Sergei Ziuzev. All rights reserved.
//
#include "headers/supportedFunctionsForTestDatabase.hpp"
static std::shared_ptr<Node> extr(std::istringstream &is) {
return ParseCondition(is);
}
std::string DoPrint(const Database& database) {
std::stringstream ss;
database.Print(ss);
std::string resalt;
resalt = ss.str();
return resalt;
}
std::vector<std::string> DoFind(const Database& database, std::istringstream& is) {
auto condition = ParseCondition(is);
auto predicate = [condition](const Date& date, const std::string& event) {
return condition->Evaluate(date, event);
};
const auto entries = database.FindIf(predicate);
return entries;
}
std::string DoLast(const Database& database, const Date& data) {
return database.Last(data);
}
int DoDelete(Database& database, std::istringstream& is) {
auto condition = extr(is);
auto predicate = [condition](const Date& date, const std::string& event) {
return condition->Evaluate(date, event);
};
return database.RemoveIf(predicate);
}