Jpp  pmt_effective_area_update_2
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JProcess.cc
Go to the documentation of this file.
1 
2 #include <string>
3 #include <iostream>
4 #include <iomanip>
5 #include <algorithm>
6 
7 #include "JSystem/JProcess.hh"
8 #include "Jeep/JParser.hh"
9 #include "Jeep/JMessage.hh"
10 
11 
12 /**
13  * \file
14  *
15  * Example for testing inter-process communication.
16  * \author mdejong
17  */
18 int main(int argc, char* argv[])
19 {
20  using namespace std;
21 
22  string command;
23  bool use_cin;
24  bool revert;
25 
26  try {
27 
28  JParser<> zap("Example for testing inter-process communication.");
29 
30  zap['c'] = make_field(command);
31  zap['C'] = make_field(use_cin);
32  zap['r'] = make_field(revert);
33 
34  zap(argc, argv);
35  }
36  catch(const exception &error) {
37  FATAL(error.what() << endl);
38  }
39 
40 
41 
42  using namespace JPP;
43 
44  try {
45 
46  JProcess process(command);
47 
48  if (!use_cin) {
49 
50  istream in(process.getInputStreamBuffer());
51 
52  for (string buffer; getline(in, buffer); ) {
53  cout << buffer << endl;
54  }
55 
56  } else {
57 
58  ostream out(process.getOutputStreamBuffer());
59  istream in (process.getInputStreamBuffer());
60 
61  for (string buffer; getline(cin, buffer) && buffer != ""; ) {
62 
63  out << buffer << endl;
64 
65  getline(in, buffer);
66 
67  if (revert) {
68  reverse(buffer.begin(), buffer.end());
69  }
70 
71  cout << buffer << endl;
72  }
73  }
74  }
75  catch(const JException& error) {
76  cerr << error.what() << endl;
77  }
78 }
Utility class to parse command line options.
Definition: JParser.hh:1500
int main(int argc, char *argv[])
Definition: Main.cc:15
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1961
std::istream & getline(std::istream &in, JString &object)
Read string from input stream until end of line.
Definition: JString.hh:478
General purpose messaging.
#define FATAL(A)
Definition: JMessage.hh:67
Utility class to parse command line options.
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 source JAcoustics sh $DETECTOR_ID CHECK_EXIT_CODE typeset A TRIPODS get_tripods $WORKDIR tripod txt TRIPODS for EMITTER in
Definition: JCanberra.sh:40