Jpp
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
software
JGizmo
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 framework.
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 framework."
);
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
}
JPARSER::JParser
Utility class to parse command line options.
Definition:
JParser.hh:1493
in
esac print_variable DETECTOR INPUT_FILE OUTPUT_FILE CDF for TYPE in
Definition:
JSirene.sh:45
path
do cat driver txt<< EOFevent ev_configure{RC_EVT%< ev_configure.txt > RC_DWRT path
Definition:
software/JDataWriter/JDataWriter.sh:143
make_field
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition:
JParser.hh:1954
JLANG::getline
std::istream & getline(std::istream &in, JString &object)
Read string from input stream until end of line.
Definition:
JString.hh:478
debug
int debug
debug level
Definition:
JSirene.cc:61
JMessage.hh
General purpose messaging.
FATAL
#define FATAL(A)
Definition:
JMessage.hh:67
JPARSER::JParser::read
int read(const int argc, const char *const argv[])
Parse the program's command line options.
Definition:
JParser.hh:1791
JParser.hh
Utility class to parse command line options.
DEBUG
#define DEBUG(A)
Message macros.
Definition:
JMessage.hh:62
main
int main(int argc, char *argv[])
Definition:
Main.cpp:15
Generated by
1.8.5