-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathColorConf.cpp
More file actions
153 lines (145 loc) · 5.48 KB
/
Copy pathColorConf.cpp
File metadata and controls
153 lines (145 loc) · 5.48 KB
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
#include "ColorConf.h"
namespace MBDoc
{
LanguageConfig LanguageConfig::Parse(MBParsing::JSONObject const& ObjectToParse)
{
LanguageConfig ReturnValue;
ReturnValue.FillObject(ObjectToParse);return ReturnValue;
}
void LanguageConfig::FillObject(MBParsing::JSONObject const& ObjectToParse)
{
if(ObjectToParse.GetType() != MBParsing::JSONObjectType::Aggregate)
{
throw std::runtime_error("Error parsing LanguageConfig: Object is not of aggregate type");
}
if(ObjectToParse.HasAttribute("LSP"))
{
if(ObjectToParse["LSP"].GetType() != MBParsing::JSONObjectType::String)
{
throw std::runtime_error("Error parsing object of type LanguageConfig: member LSP isn't of type string");
}
LSP = ObjectToParse["LSP"].GetStringData();
}
if(!ObjectToParse.HasAttribute("Regexes"))
{
throw std::runtime_error("Error parsing object of type LanguageConfig: missing mandatory field Regexes");
}
{
auto& i_MapMember = Regexes;
for(auto const& i_Pair : ObjectToParse["Regexes"].GetMapData())
{
i_MapMember[i_Pair.first] = MBParsing::JSONObject::FromJSON<std::vector<std::string>>(i_Pair.second);
}
}
}
MBParsing::JSONObject LanguageConfig::GetJSON() const
{
MBParsing::JSONObject ReturnValue(MBParsing::JSONObjectType::Aggregate);
ReturnValue["LSP"] = MBParsing::JSONObject(LSP);
{
auto const& i_MapMember = Regexes;
MBParsing::JSONObject i_MapObject(MBParsing::JSONObjectType::Aggregate);
for(auto const& i_Pair : i_MapMember)
{
i_MapObject[i_Pair.first] = MBParsing::JSONObject::ToJSON(i_Pair.second);
}
ReturnValue["Regexes"] = std::move(i_MapObject);
}
return ReturnValue;
}
ColorInfo ColorInfo::Parse(MBParsing::JSONObject const& ObjectToParse)
{
ColorInfo ReturnValue;
ReturnValue.FillObject(ObjectToParse);return ReturnValue;
}
void ColorInfo::FillObject(MBParsing::JSONObject const& ObjectToParse)
{
if(ObjectToParse.GetType() != MBParsing::JSONObjectType::Aggregate)
{
throw std::runtime_error("Error parsing ColorInfo: Object is not of aggregate type");
}
if(!ObjectToParse.HasAttribute("DefaultColor"))
{
throw std::runtime_error("Error parsing object of type ColorInfo: missing mandatory field DefaultColor");
}
if(ObjectToParse["DefaultColor"].GetType() != MBParsing::JSONObjectType::String)
{
throw std::runtime_error("Error parsing object of type ColorInfo: member DefaultColor isn't of type string");
}
DefaultColor = ObjectToParse["DefaultColor"].GetStringData();
if(!ObjectToParse.HasAttribute("ColorMap"))
{
throw std::runtime_error("Error parsing object of type ColorInfo: missing mandatory field ColorMap");
}
{
auto& i_MapMember = ColorMap;
for(auto const& i_Pair : ObjectToParse["ColorMap"].GetMapData())
{
i_MapMember[i_Pair.first] = i_Pair.second.GetStringData();
}
}
}
MBParsing::JSONObject ColorInfo::GetJSON() const
{
MBParsing::JSONObject ReturnValue(MBParsing::JSONObjectType::Aggregate);
ReturnValue["DefaultColor"] = MBParsing::JSONObject(DefaultColor);
{
auto const& i_MapMember = ColorMap;
MBParsing::JSONObject i_MapObject(MBParsing::JSONObjectType::Aggregate);
for(auto const& i_Pair : i_MapMember)
{
i_MapObject[i_Pair.first] = i_Pair.second;
}
ReturnValue["ColorMap"] = std::move(i_MapObject);
}
return ReturnValue;
}
ColorConfiguration ColorConfiguration::Parse(MBParsing::JSONObject const& ObjectToParse)
{
ColorConfiguration ReturnValue;
ReturnValue.FillObject(ObjectToParse);return ReturnValue;
}
void ColorConfiguration::FillObject(MBParsing::JSONObject const& ObjectToParse)
{
if(ObjectToParse.GetType() != MBParsing::JSONObjectType::Aggregate)
{
throw std::runtime_error("Error parsing ColorConfiguration: Object is not of aggregate type");
}
if(!ObjectToParse.HasAttribute("Coloring"))
{
throw std::runtime_error("Error parsing object of type ColorConfiguration: missing mandatory field Coloring");
}
if(ObjectToParse["Coloring"].GetType() != MBParsing::JSONObjectType::Aggregate)
{
throw std::runtime_error("Error parsing object of type ColorConfiguration: member Coloring isn't of type aggregate");
}
Coloring = ColorInfo::Parse(ObjectToParse["Coloring"]);
if(!ObjectToParse.HasAttribute("LanguageColorings"))
{
throw std::runtime_error("Error parsing object of type ColorConfiguration: missing mandatory field LanguageColorings");
}
{
auto& i_MapMember = LanguageColorings;
for(auto const& i_Pair : ObjectToParse["LanguageColorings"].GetMapData())
{
i_MapMember[i_Pair.first] = LanguageConfig::Parse(i_Pair.second);
}
}
}
MBParsing::JSONObject ColorConfiguration::GetJSON() const
{
MBParsing::JSONObject ReturnValue(MBParsing::JSONObjectType::Aggregate);
ReturnValue["Coloring"] = Coloring.GetJSON();
{
auto const& i_MapMember = LanguageColorings;
MBParsing::JSONObject i_MapObject(MBParsing::JSONObjectType::Aggregate);
for(auto const& i_Pair : i_MapMember)
{
i_MapObject[i_Pair.first] = i_Pair.second.GetJSON();
}
ReturnValue["LanguageColorings"] = std::move(i_MapObject);
}
return ReturnValue;
}
const int i_TypeIndexEndColorConf_h[] = {1,2,3,};
}