Jpp  18.2.1-ARCA-DF-PATCH
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JSonDiff.cc
Go to the documentation of this file.
1 #include <iostream>
2 #include <iomanip>
3 #include <fstream>
4 
5 #include "JSon/JSon.hh"
6 #include "JSon/JComparator.hh"
7 
8 #include "Jeep/JParser.hh"
9 #include "Jeep/JMessage.hh"
10 
11 
12 /**
13  * \file
14  *
15  * Auxiliary program to compare (part of) JSon files.
16  * \author mdejong
17  */
18 int main(int argc, char **argv)
19 {
20  using namespace std;
21  using namespace JPP;
22 
23  string ja;
24  string jb;
25  string outputFile;
26  string key;
27  int debug;
28 
29  try {
30 
31  JParser<> zap("Auxiliary program to compare (part of) JSon files.");
32 
33  zap['a'] = make_field(ja);
34  zap['b'] = make_field(jb);
35  zap['o'] = make_field(outputFile) = "";
36  zap['k'] = make_field(key) = "";
37  zap['d'] = make_field(debug) = 1;
38 
39  zap(argc, argv);
40  }
41  catch(const exception &error) {
42  FATAL(error.what() << endl);
43  }
44 
45  JSON::JComparator compare;
46 
47  json js = compare(JSon(ja), JSon(jb), key);
48 
49  DEBUG(setw(2) << js << endl);
50 
51  if (outputFile != "") {
52 
53  ofstream out(outputFile.c_str());
54 
55  out << js;
56 
57  out.close();
58  }
59 
60  return (js.empty() ? 0 : 1);
61 }
Utility class to parse command line options.
Definition: JParser.hh:1514
int main(int argc, char *argv[])
Definition: Main.cc:15
string outputFile
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1989
Auxiliary data structure to compare (part of) JSon data.
General purpose messaging.
#define FATAL(A)
Definition: JMessage.hh:67
Utility class to parse command line options.
nlohmann::json json
int debug
debug level
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62