-
Notifications
You must be signed in to change notification settings - Fork 0
/
mainHeader.hpp
132 lines (117 loc) · 4.01 KB
/
mainHeader.hpp
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#define spaceInStringStructure '`'
#include "iostream"
#include "fstream"
#include "string"
#include "Windows.h"
#include "unordered_map"
#include "sstream"
#include "vector"
#include "algorithm"
#include "direct.h"
#include "sys/stat.h"
#include <sys/types.h>
#include "chrono"
#include "time.h"
#include "thread"
#include "fstream"
#include "stack"
#include <dirent.h>
namespace Parser{
//token primitive Types [commands/params/operator/....]
enum TokenPrimaryType{
COMMAND,
PARAMETER,
OPERATOR,
VARIABLE,
HARDSTRING,
HARDNUMBER,
BLOCK,
FLAGLIST,
PARANT
};
enum VariableType{
STRING,
NUMBER
};
//expression regulation
extern std::unordered_map<std::string, TokenPrimaryType> _primary_tokens;
//parsed tokens
extern std::vector<std::pair<TokenPrimaryType, std::string> > _curTokens;
//standard commands EX : print
extern std::unordered_map<std::string, void*> _commandsTokens;
//standard operators
extern std::unordered_map<std::string, void*>_operators;
//variables <token, value>
extern std::vector<std::pair<std::string,std::pair<VariableType, std::string >> > _variables;
//hard type for casting <type, cast-name>
extern std::unordered_map<std::string, Parser::VariableType> _variablesNameDeclare;
//blocks aka functions
extern std::unordered_map<std::string, std::vector<std::pair<TokenPrimaryType, std::string> > > _blockList;
//settings/flags lists
extern std::unordered_map<std::string,std::vector<std::pair<TokenPrimaryType, std::string> >> _flags;
//parsing
void ExtractTokens(std::string&);
//token type
TokenPrimaryType GetTokenType(std::string&);
void Interpret(std::vector<std::pair<TokenPrimaryType, std::string> >);
void ShowTokens();
std::string GetVariableValue(std::string&);
bool IsHardNumber(std::string&);
}
//Command : curIndex in cur tokenArray||block
namespace Commands{
void PrintFunction(int&, std::vector<std::pair<Parser::TokenPrimaryType, std::string> >&);
void BrutCommandFunction(int&, std::vector<std::pair<Parser::TokenPrimaryType, std::string> >&);
void CreateDirFunction(int&, std::vector<std::pair<Parser::TokenPrimaryType, std::string> >&);
void AddFileEventListener(int&, std::vector<std::pair<Parser::TokenPrimaryType, std::string> >&);
void SetTimeOut(int&, std::vector<std::pair<Parser::TokenPrimaryType, std::string> >&);
void SetInterval(int&, std::vector<std::pair<Parser::TokenPrimaryType, std::string> >&);
void ReadAFile(int&, std::vector<std::pair<Parser::TokenPrimaryType, std::string> >&);
void GetSubDirs(int&, std::vector<std::pair<Parser::TokenPrimaryType, std::string> > &);
void FileMove(int&, std::vector<std::pair<Parser::TokenPrimaryType,std::string> >&);
}
namespace Operators{
void _declareVar(std::string& , std::string&);
void _assignValueToVar(std::string&, std::string&);
}
namespace FileManager{
std::string workingDir();
void ReadAllFromFile(std::string, std::string, std::string, std::string);
void GetSubDirectories(std::string, std::string, std::string, std::string);
void FileMove(std::string, std::string);
}
namespace EventManagement{
class FileEventTrigger{
private:
tm _lastTime;
bool isFirstFrame;
public:
struct tm *_time;
struct stat attrib;
std::string _bl;
std::string _fileName;
FileEventTrigger(std::string&, std::string&);
void StartTrigger();
void Trigger(std::string&);
bool _timeIsEchivalent(tm, tm);
};
void StartNewEventThread(FileEventTrigger);
class EventManager{
public:
void AddEventTrigger(FileEventTrigger);
void RemoveEventTrigger(int);
FileEventTrigger *GetEventTrigger(int);
private:
std::vector<FileEventTrigger> _triggers;
};
extern EventManager _manager;
}
namespace Utility{
class Timer{
public:
Timer();
void SetTimeout(int, std::string);
void SetInterval(int, std::string);
};
int StringToInt(std::string);
}