Jpp  18.2.0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
JPrintProperties.cc File Reference

General purpose program to edit or create properties file. More...

#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>
#include <vector>
#include <set>
#include <map>
#include "JLang/JEquationParameters.hh"
#include "JLang/JEquation.hh"
#include "Jeep/JProperties.hh"
#include "Jeep/JComment.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

General purpose program to edit or create properties file.

Author
mdejong

Definition in file JPrintProperties.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 23 of file JPrintProperties.cc.

24 {
25  using namespace std;
26  using namespace JPP;
27 
28  string inputFile;
29  JEquationParameters parameters("=", ";\n", "", "#");
30  set<string> key;
31  int debug;
32 
33  try {
34 
35  JProperties properties;
36 
37  properties["sep"] = parameters.getSeparator();
38  properties["eol"] = parameters.getEndOfLine();
39  properties["div"] = parameters.getDivision();
40  properties["skip"] = parameters.getSkipLine();
41  properties["left"] = parameters.getLeftBracket();
42  properties["right"] = parameters.getRightBracket();
43  properties["ws"] = parameters.getWhiteSpace();
44  properties["cc"] = parameters.getComment();
45 
46  JParser<> zap("General purpose program to edit or create properties file.");
47 
48  zap['f'] = make_field(inputFile);
49  zap['@'] = make_field(properties) = JPARSER::initialised();
50  zap['k'] = make_field(key, "key");
51  zap['d'] = make_field(debug, "debug level") = 2;
52 
53  zap(argc, argv);
54  }
55  catch(const exception &error) {
56  FATAL(error.what() << endl);
57  }
58 
59 
60  JComment comment;
61 
62  const JEquationFacet facet(parameters);
63 
64  // input
65 
66  ifstream in(inputFile.c_str());
67 
68  in >> comment;
69 
70  in.imbue(locale(in.getloc(), facet.clone()));
71 
72  for (JEquation equation; in >> equation; ) {
73 
74  DEBUG(equation << endl);
75 
76  for (const auto& i : key) {
77 
78  if (equation.getKey().find(i) == 0) {
79  cout << ' ' << equation.getValue();
80  }
81  }
82  }
83 
84  in.close();
85 }
Utility class to parse command line options.
Definition: JParser.hh:1514
Utility class to parse parameter values.
Definition: JProperties.hh:497
*fatal Wrong number of arguments esac JCookie sh typeset Z DETECTOR typeset Z SOURCE_RUN typeset Z TARGET_RUN set_variable PARAMETERS_FILE $WORKDIR parameters
Definition: diff-Tuna.sh:38
Simple data structure to support I/O of equations (see class JLANG::JEquation).
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Definition: JParser.hh:83
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1989
#define FATAL(A)
Definition: JMessage.hh:67
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
int debug
debug level
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62