libcruft-util/tools/json-validate.cpp
Danny Robson f6056153e3 rename root namespace from util to cruft
This places, at long last, the core library code into the same namespace
as the extended library code.
2018-08-05 14:42:02 +10:00

45 lines
957 B
C++

/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* Copyright:
* 2014-2016, Danny Robson <danny@nerdcruft.net>
*/
#include "json/flat.hpp"
#include "json/except.hpp"
#include "io.hpp"
#include <iostream>
#include <cstdlib>
enum {
ARG_CMD,
ARG_PATH,
NUM_ARGS
};
int
main (int argc, char ** argv) {
if (argc != NUM_ARGS) {
std::cerr << "Invalid arguments. "
<< argv[ARG_CMD] << " <path> "
<< std::endl;
return EXIT_FAILURE;
}
try {
const cruft::mapped_file data (argv[ARG_PATH]);
json::flat::parse (cruft::view{data}.cast<const char*> ());
} catch (const json::error &x) {
std::cerr << "error: " << x.what () << '\n';
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}