-
Notifications
You must be signed in to change notification settings - Fork 0
/
Singleton.cpp
81 lines (69 loc) · 2.16 KB
/
Singleton.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
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
#include "Singleton.hpp"
#include <vector>
#include <string>
using namespace std;
static char functionDefChar;
static char functionBodyChar;
static string inputFileName;
static string outputFileName;
static string finalMainFunctionData;
static vector <functionClass> functionList;
void Singleton::setfunctionDefChar(char newfunctionDefChar) {
functionDefChar = newfunctionDefChar;
}
void Singleton::setfunctionBodyChar(char newfunctionBodyChar) {
functionBodyChar = newfunctionBodyChar;
}
void Singleton::setinputFileName (string newinputFileName) {
inputFileName = newinputFileName;
}
void Singleton::setoutputFileName (string newoutputFileName) {
outputFileName = newoutputFileName;
}
char Singleton::getfunctionDefChar () {
return functionDefChar;
}
char Singleton::getfunctionBodyChar () {
return functionBodyChar;
}
string Singleton::getinputFileName () {
return inputFileName;
}
string Singleton::getoutputFileName () {
return outputFileName;
}
void Singleton::addToFunctionList (string functionName, string functionData) {
functionClass newFunction;
newFunction.functionName = functionName;
newFunction.functionData = functionData;
int index;
for (index = 0; index < functionList.size(); index++) {
if (functionList [index].functionName == newFunction.functionName) {
cout << "Error: function redefinition.";
exit (EXIT_FAILURE);
}
}
functionList.push_back(newFunction);
}
int Singleton::getFunctionCount () {
return functionList.size();
}
functionClass Singleton::getFunctionAtIndex (int index) {
return functionList [index];
}
string Singleton::getFunctionDataByFunctionName (string functionName) {
int index;
for (index = 0; index < functionList.size(); index++) {
if (functionList [index].functionName == functionName) {
return functionList [index].functionData;
}
}
cout << "Invalid input";
exit (EXIT_FAILURE);
}
void Singleton::setFinalMainFunctionData (std::string data) {
finalMainFunctionData = data;
}
std::string Singleton::getFinalMainFunctionData () {
return finalMainFunctionData;
}