Jpp  18.0.1-rc.1
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
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

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 }
Utility class to parse command line options.
Definition: JParser.hh:1514
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.
#define FATAL(A)
Definition: JMessage.hh:67
nlohmann::json json
int debug
debug level
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62