Jpp 19.3.0-rc.1
the software that should make you happy
Loading...
Searching...
No Matches
JSon/JComparator.hh
Go to the documentation of this file.
1#ifndef __JSON__JCOMPARATOR__
2#define __JSON__JCOMPARATOR__
3
4#include <ostream>
5#include <iomanip>
6
7#include "JSon/JSon.hh"
8
9
10/**
11 * \author mdejong
12 */
13
14namespace JSON {}
15namespace JPP { using namespace JSON; }
16
17namespace JSON {
18
19 /**
20 * Auxiliary data structure to compare (part of) JSon data.
21 *
22 * The key can be used to specify which part of the JSon data to print.\n
23 * For example:
24 * <pre>
25 * "Error.Code"
26 * </pre>
27 * will compare the error codes some specific JSon data.
28 */
29 struct JComparator {
30
31 char SEPARATOR = '.';
32
33 /**
34 * Defaut constructor.
35 */
37 {}
38
39
40 /**
41 * Auxiliary method to compare (part of) JSon data.
42 *
43 * \param ja JSon data
44 * \param jb JSon data
45 * \param key key
46 */
47 inline json operator()(const json& ja, const json& jb, const std::string& key) const
48 {
49 using namespace std;
50
51 const size_t pos = key.find(SEPARATOR);
52
53 if (pos != string::npos) {
54 return (*this)(ja[key.substr(0,pos)], ja[key.substr(0,pos)], key.substr(pos + 1));
55 } else if (key != "") {
56 return json::diff(ja[key], jb[key]);
57 } else {
58 return json::diff(ja, jb);
59 }
60 }
61 };
62}
63
64#endif
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Auxiliary classes and methods for detector calibration.
Auxiliary data structure to compare (part of) JSon data.
json operator()(const json &ja, const json &jb, const std::string &key) const
Auxiliary method to compare (part of) JSon data.
JComparator()
Defaut constructor.