Jpp  15.0.5
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
include.cc
Go to the documentation of this file.
1 
2 #include <string>
3 #include <iostream>
4 #include <iomanip>
5 #include <fstream>
6 #include <cstdlib>
7 
8 #include "Jeep/JParser.hh"
9 #include "Jeep/JMessage.hh"
10 
11 namespace {
12 
13  /**
14  * Jpp top-level directory.
15  */
16  static const std::string JPP_DIR = getenv("JPP_DIR");
17 
18 
19  /**
20  * Look for specified target in given file name.
21  *
22  * \param file_name file name
23  * \param target target
24  * \param path path
25  */
26  inline void include(const std::string& file_name, const std::string& target, const std::string& path = "")
27  {
28  using namespace std;
29 
30  ifstream in(file_name.c_str());
31 
32  if (!in) {
33  //cerr << "Error opening: " << file_name << endl;
34  }
35 
36  for (string buffer; getline(in, buffer); ) {
37 
38  const string::size_type ipos = buffer.find("\"");
39 
40  if (buffer.find("#include") == 0 && ipos != string::npos) {
41 
42  const string source = buffer.substr(ipos + 1, buffer.length() - ipos - 2);
43 
44  if (source.find(target) != string::npos) {
45  cout << ((path.empty() ? file_name : path) + " -> " + source) << endl;
46  break;
47  }
48 
49  include(JPP_DIR + "/software/" + source, target, ((path.empty() ? file_name : path) + " -> " + source));
50  }
51  }
52 
53  in.close();
54  }
55 }
56 
57 
58 /**
59  * \file
60  * Auxiliary program to check for include file within Jpp repository.
61  * \author mdejong
62  */
63 int main(int argc, char **argv)
64 {
65  using namespace std;
66 
67  string source;
68  string target;
69  int debug;
70 
71  try {
72 
73  JParser<> zap("Auxiliary program to recursively check for include file in Jpp repository.");
74 
75  zap['f'] = make_field(source, "name of source file to be inspected");
76  zap['i'] = make_field(target, "name of include file to be searched");
77  zap['d'] = make_field(debug) = 1;
78 
79  if (zap.read(argc, argv) != 0)
80  return 1;
81  }
82  catch(const exception& error) {
83  FATAL(error.what() << endl);
84  }
85 
86  DEBUG("JPP_DIR" << ' ' << JPP_DIR << endl);
87 
88  include(source, target);
89 }
Utility class to parse command line options.
Definition: JParser.hh:1500
int main(int argc, char *argv[])
Definition: Main.cc:15
$WORKDIR driver txt done cat $WORKDIR driver txt<< EOFprocess ${DATAFILTER}$FILTER_HOST csh-c '(setenv ROOTSYS $ROOTSYS &&source $JPP_DIR/setenv.csh $JPP_DIR &&JDataFilter-H\$SERVER\$-M\$LOGGER\$-d $DEBUG-u ${DATAFILTER}-P $PORT</dev/null > &/dev/null)&';process ${DATAWRITER}$WRITER_HOST csh-c '(setenv ROOTSYS $ROOTSYS &&source $JPP_DIR/setenv.csh $JPP_DIR &&JDataWriter-H\$SERVER\$-M\$LOGGER\$-d $DEBUG-u ${DATAWRITER}</dev/null > &/dev/null)&';print enterevent ev_init{RC_CMD}event ev_reset{RC_CMD}event ev_init{RC_CMD}event ev_configure{RC_DFLTR%<$WORKDIR/ev_configure_datafilter.txt > RC_DOM<$WORKDIR/ev_configure_domsimulator.txt > RC_DWRT path
#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
int debug
debug level
Definition: JSirene.cc:63
General purpose messaging.
#define FATAL(A)
Definition: JMessage.hh:67
int read(const int argc, const char *const argv[])
Parse the program&#39;s command line options.
Definition: JParser.hh:1798
Utility class to parse command line options.
then usage $script< input_file >< detector_file > fi set_variable OUTPUT_DIR set_variable SELECTOR JDAQTimesliceL1 set_variable DEBUG case set_variable DEBUG
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:41