forked from kenygia/MooseEdit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
GenStatsReader.h
115 lines (111 loc) · 2.89 KB
/
GenStatsReader.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#ifndef GENSTATSREADER_H
#define GENSTATSREADER_H
#include <istream>
#include <vector>
#include <map>
#include <algorithm>
class StatsContainer {
std::string containerType;
std::vector<std::string> containerArgs;
StatsContainer *usingContainer = 0;
std::string type;
std::map<std::string, std::string> dataMap;
std::vector<std::string> prefixList;
std::vector<std::string> suffixList;
std::string boostName;
std::string boostValue;
public:
StatsContainer() {
;
}
~StatsContainer() {
;
}
std::string getBoostName() const {
return boostName;
}
std::string getBoostValue() const {
return boostValue;
}
void setBoostName(std::string boostName) {
this->boostName = boostName;
}
void setBoostValue(std::string boostValue) {
this->boostValue = boostValue;
}
std::vector<std::string>& getPrefixList() {
return prefixList;
}
std::vector<std::string>& getSuffixList() {
return suffixList;
}
std::string& getContainerType() {
return this->containerType;
}
void setContainerType(const char *type) {
this->containerType = type;
}
void setUsing(StatsContainer *usingContainer) {
this->usingContainer = usingContainer;
}
StatsContainer *getUsing() const {
return this->usingContainer;
}
std::string getUsingName() {
if (this->usingContainer != 0) {
return this->usingContainer->getArg(0);
}
return "";
}
long getArgCount() {
return containerArgs.size();
}
std::string getArg(long n) const {
if (n < containerArgs.size()) {
return containerArgs[n];
}
else {
return "";
}
}
void addArg(const char *arg) {
containerArgs.push_back(arg);
}
std::string& getType() {
return this->type;
}
void setType(const char *type) {
this->type = type;
}
void addData(std::string key, std::string value) {
dataMap[key] = value;
}
std::string getData(std::string key) {
if (dataMap.find(key) != dataMap.end()) {
return dataMap[key];
} else {
if (usingContainer != 0) {
return usingContainer->getData(key);
}
}
return "";
}
std::map<std::string, std::string> getBaseDataMap() {
return dataMap;
}
};
class GenStatsReader
{
public:
GenStatsReader();
std::vector<StatsContainer *> loadFile(std::istream& stream);
static StatsContainer *getContainer(std::vector<StatsContainer *>& containers, std::string containerName);
static std::vector<StatsContainer *> getContainersByContainerType(std::vector<StatsContainer *> &containers, std::string type);
static std::vector<StatsContainer *> getSubclassContainers(std::vector<StatsContainer *> &containers, StatsContainer *superClass);
static void freeContainers(std::vector<StatsContainer *> &containers) {
for (int i=0; i<containers.size(); ++i) {
delete containers[i];
}
}
};
#endif // GENSTATSREADER_H