| 334 | } |
| 335 | |
| 336 | int main(int argc, char * argv[]) |
| 337 | { |
| 338 | if (argc < 2) { |
| 339 | std::cerr << "A filename to parse is required.\n"; |
| 340 | exit(1); |
| 341 | } |
| 342 | |
| 343 | std::ifstream ifs(argv[1]); |
| 344 | if (!ifs) { |
| 345 | std::cerr << "Unable to read file '" << argv[1] << "'.\n"; |
| 346 | exit(1); |
| 347 | } |
| 348 | |
| 349 | // Read in the entire file. |
| 350 | std::string const file_contents = file_slurp(ifs); |
| 351 | // Parse the contents. If there is an error, just stream it to cerr. |
| 352 | auto json = json::parse( |
| 353 | file_contents, [](std::string const & msg) { std::cerr << msg; }); |
| 354 | if (!json) { |
| 355 | std::cerr << "Parse failure.\n"; |
| 356 | exit(1); |
| 357 | } |
| 358 | |
| 359 | std::cout << "Parse successful; contents:\n" << *json << "\n"; |
| 360 | |
| 361 | return 0; |
| 362 | } |
| 363 | //] |
nothing calls this directly
no test coverage detected