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
JSon.hh
Go to the documentation of this file.
1 #ifndef __JSON__JSON__
2 #define __JSON__JSON__
3 
4 #include <fstream>
5 #include <iomanip>
6 
7 #include "json/json.hpp"
8 
9 
10 /**
11  * \author mdejong
12  */
13 
14 namespace JSON {}
15 namespace JPP { using namespace JSON; }
16 
17 namespace JSON {
18 
19  using nlohmann::json;
20 
21 
22  /**
23  * Load json data from input file.
24  *
25  * \param file_name file name
26  * \param object json data
27  */
28  inline void load(const std::string& file_name, json& object)
29  {
30  using namespace std;
31 
32  ifstream in(file_name.c_str());
33 
34  in >> object;
35 
36  in.close();
37  }
38 
39 
40  /**
41  * Store json data to output file.
42  *
43  * \param file_name file name
44  * \param object json data
45  */
46  inline void store(const std::string& file_name, const json& object)
47  {
48  using namespace std;
49 
50  ofstream out(file_name.c_str());
51 
52  out << setw(2) << setprecision(8) << object;
53 
54  out.close();
55  }
56 
57 
58  /**
59  * Auxiliary class to load json data from file.
60  */
61  struct JSon :
62  public json
63  {
64  /**
65  * Constructor.
66  *
67  * \param file_name file name
68  */
69  JSon(const std::string& file_name)
70  {
71  load(file_name, *this);
72  }
73  };
74 }
75 
76 #endif
JSon(const std::string &file_name)
Constructor.
Definition: JSon.hh:69
void store(const std::string &file_name, const JDetector &detector)
Store detector to output file.
then awk string
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
nlohmann::json json
Auxiliary class to load json data from file.
Definition: JSon.hh:61
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2] eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY JAcoustics sh $DETECTOR_ID source JAcousticsToolkit sh CHECK_EXIT_CODE typeset A EMITTERS get_tripods $WORKDIR tripod txt EMITTERS get_transmitters $WORKDIR transmitter txt EMITTERS for EMITTER in
Definition: JCanberra.sh:46