/
Variables.h
executable file
·91 lines (74 loc) · 2.48 KB
/
Variables.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
#ifndef VARIABLES_H_
#define VARIABLES_H_
#include <atomic>
#include <map>
#include <unordered_map>
#include <mutex>
#include <thread>
#include <fstream>
#include <set>
#include <unordered_set>
#include <vector>
#include "NumFns.h"
#include "Path.h"
#include "StrFns.h"
struct VLayer
{
std::string scope;
std::unordered_set<std::string> constants, privates;
std::unordered_map<std::string, std::unordered_set<std::string> > inScopes;
std::unordered_map<std::string, std::string> scopeOf;
std::unordered_map<std::string, std::string> typeOf;
std::unordered_map<std::string, std::string> functions;
std::unordered_set<std::string> nFns, unscopedFns, noOutput;
std::map<std::string, Path> paths;
//std::map<std::string, int> funcDefLineNo;
std::map<std::string, bool> bools;
std::unordered_map<std::string, int> ints;
std::map<std::string, long long int> llints;
std::map<std::string, double> doubles;
std::map<std::string, char> chars;
std::map<std::string, std::string> strings;
std::map<std::string, std::vector<double> > doubVecs;
std::map<std::string, std::vector<std::string> > strVecs;
std::map<std::string, std::fstream> fstreams;
std::map<std::string, std::ifstream> ifstreams;
std::map<std::string, std::ofstream> ofstreams;
VLayer();
};
struct VPos
{
int layer;
std::string name, type;
VPos();
};
struct Variables
{
std::vector<VLayer> layers;
std::unordered_set<std::string> basic_types;
std::map<std::string, std::string> typeDefs;
std::unordered_set<std::string> nTypes;
std::map<std::string, Path> typeDefPath;
std::map<std::string, int> typeDefLineNo;
int precision;
bool fixedPrecision, scientificPrecision;
Variables();
std::string double_to_string(const double& d, const bool& round);
int add_layer(const std::string& scope);
bool find(const std::string& name, VPos& vpos);
bool find_fn(const std::string& name, VPos& vpos);
int get_bool_from_var(const VPos& vpos, bool& val);
int get_double_from_var(const VPos& vpos, double& val);
int get_str_from_var(const VPos& vpos,
std::string& str,
const bool& round,
const bool& indent);
int add_str_from_var(const VPos& vpos,
std::string& str,
const bool& round,
const bool& indent,
std::string& indentAmount);
int set_var_from_str(const VPos& vpos, const std::string& value);
int set_var_from_double(const VPos& vpos, const double& value);
};
#endif //VARIABLES_H_