MCPcopy Create free account
hub / github.com/avast/retdec / readJsonString

Method readJsonString

src/config/config.cpp:170–205  ·  view source on GitHub ↗

* Reads string containing JSON representation of configuration. * If file can not be parsed, an instance of @c ParseException is thrown. * @param json JSON string. */

Source from the content-addressed store, hash-verified

168 * @param json JSON string.
169 */
170void Config::readJsonString(const std::string& json)
171{
172 rapidjson::Document root;
173 rapidjson::ParseResult ok = root.Parse(json);
174 if (!ok)
175 {
176 std::string errMsg = "Failed to parse configuration!";
177
178 errMsg = GetParseError_En(ok.Code());
179
180 auto loc = retdec::utils::getLineAndColumnFromPosition(json, ok.Offset());
181 throw ParseException(errMsg, loc.first, loc.second);
182 }
183
184 *this = Config();
185
186 auto params = root.FindMember(JSON_parameters);
187 if (params != root.MemberEnd())
188 {
189 parameters.deserialize(params->value);
190 }
191
192 serdes::deserialize(root, JSON_architecture, architecture);
193 serdes::deserialize(root, JSON_fileType, fileType);
194 serdes::deserialize(root, JSON_fileFormat, fileFormat);
195
196 serdes::deserializeContainer(root, JSON_tools, tools);
197 serdes::deserializeContainer(root, JSON_languages, languages);
198 serdes::deserializeContainer(root, JSON_functions, functions);
199 serdes::deserializeContainer(root, JSON_globals, globals);
200 serdes::deserializeContainer(root, JSON_registers, registers);
201 serdes::deserializeContainer(root, JSON_structures, structures);
202 serdes::deserializeContainer(root, JSON_vtables, vtables);
203 serdes::deserializeContainer(root, JSON_classes, classes);
204 serdes::deserializeContainer(root, JSON_patterns, patterns);
205}
206
207} // namespace config
208} // namespace retdec

Callers 3

fromStringMethod · 0.80
fromJsonStringMethod · 0.80
TEST_FFunction · 0.80

Calls 11

ParseExceptionClass · 0.85
deserializeContainerFunction · 0.85
CodeMethod · 0.80
OffsetMethod · 0.80
FindMemberMethod · 0.80
MemberEndMethod · 0.80
deserializeMethod · 0.80
ConfigClass · 0.50
deserializeFunction · 0.50
ParseMethod · 0.45

Tested by 1

TEST_FFunction · 0.64