| 141 | } |
| 142 | |
| 143 | static int parseAndSaveValueTree(const JSONCPP_STRING& input, |
| 144 | const JSONCPP_STRING& actual, |
| 145 | const JSONCPP_STRING& kind, |
| 146 | const Json::Features& features, |
| 147 | bool parseOnly, |
| 148 | Json::Value* root) |
| 149 | { |
| 150 | Json::Reader reader(features); |
| 151 | bool parsingSuccessful = reader.parse(input.data(), input.data() + input.size(), *root); |
| 152 | if (!parsingSuccessful) { |
| 153 | printf("Failed to parse %s file: \n%s\n", |
| 154 | kind.c_str(), |
| 155 | reader.getFormattedErrorMessages().c_str()); |
| 156 | return 1; |
| 157 | } |
| 158 | if (!parseOnly) { |
| 159 | FILE* factual = fopen(actual.c_str(), "wt"); |
| 160 | if (!factual) { |
| 161 | printf("Failed to create %s actual file.\n", kind.c_str()); |
| 162 | return 2; |
| 163 | } |
| 164 | printValueTree(factual, *root); |
| 165 | fclose(factual); |
| 166 | } |
| 167 | return 0; |
| 168 | } |
| 169 | // static JSONCPP_STRING useFastWriter(Json::Value const& root) { |
| 170 | // Json::FastWriter writer; |
| 171 | // writer.enableYAMLCompatibility(); |
no test coverage detected