| 33 | }; |
| 34 | |
| 35 | void LoadConfig(std::wstring const & configPath, ToolConfig & config) |
| 36 | { |
| 37 | std::ifstream f(configPath, std::ios::in); |
| 38 | if (!f.good()) { |
| 39 | return; |
| 40 | } |
| 41 | |
| 42 | Json::CharReaderBuilder factory; |
| 43 | Json::Value root; |
| 44 | std::string errs; |
| 45 | if (!Json::parseFromStream(factory, f, &root, &errs)) { |
| 46 | std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter; |
| 47 | std::wstring werrs = converter.from_bytes(errs); |
| 48 | |
| 49 | std::wstringstream err; |
| 50 | err << L"Failed to load configuration file '" << configPath << "':\r\n" << werrs; |
| 51 | Fail(err.str().c_str()); |
| 52 | } |
| 53 | |
| 54 | auto createConsole = root["CreateConsole"]; |
| 55 | if (!createConsole.isNull()) { |
| 56 | if (createConsole.isBool()) { |
| 57 | config.CreateConsole = createConsole.asBool(); |
| 58 | } else { |
| 59 | Fail("Config option 'CreateConsole' should be a boolean."); |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | auto enableLogging = root["EnableLogging"]; |
| 64 | if (!enableLogging.isNull()) { |
| 65 | if (enableLogging.isBool()) { |
| 66 | config.EnableLogging = enableLogging.asBool(); |
| 67 | } else { |
| 68 | Fail("Config option 'EnableLogging' should be a boolean."); |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | auto logCompile = root["LogCompile"]; |
| 73 | if (!logCompile.isNull()) { |
| 74 | if (logCompile.isBool()) { |
| 75 | config.LogCompile = logCompile.asBool(); |
| 76 | } |
| 77 | else { |
| 78 | Fail("Config option 'LogCompile' should be a boolean."); |
| 79 | } |
| 80 | } |
| 81 | |
| 82 | auto enableExtensions = root["EnableExtensions"]; |
| 83 | if (!enableExtensions.isNull()) { |
| 84 | if (enableExtensions.isBool()) { |
| 85 | config.EnableExtensions = enableExtensions.asBool(); |
| 86 | } |
| 87 | else { |
| 88 | Fail("Config option 'EnableExtensions' should be a boolean."); |
| 89 | } |
| 90 | } |
| 91 | |
| 92 | auto dumpStrings = root["DumpNetworkStrings"]; |
no test coverage detected