Jpp 19.3.0-rc.2
the software that should make you happy
Loading...
Searching...
No Matches
JSonDiff.cc File Reference

Auxiliary program to compare (part of) JSon files. More...

#include <iostream>
#include <iomanip>
#include <fstream>
#include "JSon/JSon.hh"
#include "JSon/JComparator.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Auxiliary program to compare (part of) JSon files.

Author
mdejong

Definition in file JSonDiff.cc.

Function Documentation

◆ main()

int main ( int argc,
char ** argv )

Definition at line 18 of file JSonDiff.cc.

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}
string outputFile
#define DEBUG(A)
Message macros.
Definition JMessage.hh:62
#define FATAL(A)
Definition JMessage.hh:67
int debug
debug level
Definition JSirene.cc:72
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition JParser.hh:2142
nlohmann::json json
Utility class to parse command line options.
Definition JParser.hh:1698
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Auxiliary data structure to compare (part of) JSon data.
Auxiliary class to load json data from file.
Definition JSon.hh:63