Xiangiqgame
AI engine for Xiangqi
Loading...
Searching...
No Matches
my_schemas.cpp
Go to the documentation of this file.
1
3
4#include <cstdlib>
5#include <iomanip>
6#include <iostream>
7#include <nlohmann/json-schema.hpp>
9#include <string>
12
13using nlohmann::json;
14using nlohmann::json_schema::json_validator;
15using namespace jsonio;
16
18 "ICGA_2004_bpo.json");
20 "ICGA_2004_raw.json");
22 "bpo_schema.json");
24 "raw_points_schema.json");
25
26int main() {
27
28 auto points_spec_ICGA_2004 =
30 auto points_spec_schema =
32
33 auto raw_points_ICGA_2004 =
35 auto raw_points_schema = import_json(raw_points_schema_path);
36
37 json_validator spec_validator;
38
39 try {
40 spec_validator.set_root_schema(raw_points_schema);
41 } catch (const std::exception &e) {
42 std::cerr << "Points Spec schema validation failed: " << e.what()
43 << std::endl;
44 return EXIT_FAILURE;
45 }
46
47 try {
48
49 auto spec_validation_result = spec_validator.validate(raw_points_ICGA_2004);
50 std::cout << "ICGA 2004 points spec validation succeeded" << std::endl;
51 } catch (const std::exception &e) {
52 std::cerr << "ICGA 2004 points spec validation failed: " << e.what()
53 << std::endl;
54 }
55
56 json_validator raw_points_validator;
57
58 return EXIT_SUCCESS;
59}
Definition of JsonUtility CRTP interface.
Declaration and implementation of templated portions of jsonio::NlohmannJsonUtility.
nlohmann::json import_json(std::string file_path)
static const std::string raw_points_schema_path
Definition: my_schemas.cpp:23
static const std::string points_spec_ICGA_2004_path
Definition: my_schemas.cpp:17
static const std::string raw_points_ICGA_2004_path
Definition: my_schemas.cpp:19
int main()
Definition: my_schemas.cpp:26
static const std::string points_spec_schema_path
Definition: my_schemas.cpp:21
Importing / exporting objects from / to json files.
const string get_data_file_abs_path(const std::string data_file)