21 static const char WILDCARD =
'%';
23 static const char*
const INCLUDE_DIRECTIVE =
"#include";
24 static const char*
const NAMESPACE_DIRECTIVE =
"namespace";
25 static const char*
const INCLUDE_EXTENSION =
".hh";
26 static const char*
const SOFTWARE_DIRECTORY =
"software";
36 public std::map<std::string, std::set<std::string> >
38 static const char JPP_PREFIX =
'J';
39 static const char DIRECTORY_SEPARATOR =
'/';
54 bool is_valid(
const key_type& key)
const
56 for (const_iterator p = this->begin(); p != this->end(); ++p) {
62 for (const_iterator q = this->begin(); q != p; ++q) {
79 JDirectory(
const std::string& dir =
"")
84 const string JPP_DIR = (dir !=
"" ? dir : getenv(
"JPP_DIR"));
85 const string TOP = JPP_DIR + DIRECTORY_SEPARATOR + SOFTWARE_DIRECTORY;
87 for (
const auto& top : ls(TOP)) {
89 if (top[0] == JPP_PREFIX && rm.count(top) == 0) {
91 const string SUB = TOP + DIRECTORY_SEPARATOR + top;
93 for (
const auto& file : ls(SUB)) {
95 if (file.find(INCLUDE_EXTENSION) != string::npos) {
97 const string file_name = SUB + DIRECTORY_SEPARATOR + file;
99 ifstream
in(file_name.c_str());
101 for (
string buffer;
getline(
in, buffer) && buffer.find(NAMESPACE_DIRECTIVE) == string::npos; ) {
103 if (buffer.find(INCLUDE_DIRECTIVE) != string::npos) {
105 istringstream
is(buffer);
107 string key, include_file;
109 is >> key >> include_file;
113 const size_t pos = include_file.find(DIRECTORY_SEPARATOR);
115 if (pos != string::npos) {
117 const string dir = include_file.substr(1, pos - 1);
120 (*this)[top].insert(dir);
141 JDirectory(
const JDirectory& input,
const key_type& key)
143 this->
copy(input, key);
153 const mapped_type&
get(
const key_type& key)
const
155 static const mapped_type buffer;
157 const_iterator p = this->find(key);
159 if (p != this->end())
172 path_type
getPath(
const key_type& key)
const
176 evaluate(key,
get(key));
188 bool is_valid(
const key_type& key)
const
192 return evaluate(key,
get(key));
201 inline void print(std::ostream& out)
const
205 for (const_iterator i = this->begin(); i != this->end(); ++i) {
207 out << i->first <<
" -> {";
209 for (
const auto& dir : i->second) {
210 out <<
" " << dir <<
",";
224 inline void print(std::ostream& out,
const JDirectory::key_type& key)
const
226 JDirectory(*
this, key).print(out);
236 void copy(
const JDirectory& input,
const key_type& key)
238 (*this)[key] = input.get(key);
240 for (
const auto& dir : input.get(key)) {
241 if (this->find(dir) == this->end()) {
255 bool evaluate(
const key_type& key,
const mapped_type& target)
const
257 if (!
path.is_valid(key)) {
261 for (mapped_type::const_iterator i = target.begin(); i != target.end(); ++i) {
265 if (!evaluate(key, this->
get(*i))) {
275 mutable path_type
path;
285 int main(
int argc,
char **argv)
297 JParser<> zap(
"Example program to test dependencies of include files");
306 catch(
const exception &error) {
307 FATAL(error.what() << endl);
318 if (pos != string::npos) {
319 outputFile.replace(pos, 1, (dir !=
"" ? dir.c_str() :
"Jpp"));
324 out <<
"\\documentclass[border=5mm]{standalone}" << endl;
326 out <<
"\\usepackage{tikz}" << endl;
327 out <<
"\\usetikzlibrary{graphs, graphdrawing}" << endl;
328 out <<
"\\usegdlibrary{layered}" << endl;
329 out <<
"\\begin{document}" << endl;
331 out <<
"\\tikz \\graph [layered layout]" << endl;
335 directory.print(out);
337 directory.print(out, dir);
341 out <<
"\\end{document}" << endl;
347 for (JDirectory::const_iterator i = directory.begin(); i != directory.end(); ++i) {
349 DEBUG(i->first <<
": " << flush);
351 if (!directory.is_valid(i->first)) {
353 const JDirectory::path_type
path = directory.getPath(i->first);
355 for (JDirectory::path_type::const_iterator dir = path.begin(); dir != path.end(); ++dir) {
363 for (JDirectory::const_iterator i = directory.begin(); i != directory.end(); ++i) {
364 ASSERT(directory.is_valid(i->first),
"check validity " << i->first);
Utility class to parse command line options.
int main(int argc, char *argv[])
bool is_double_quoted(const std::string &value)
Check quotation.
std::string getPath(const std::string &file_name)
Get path, i.e. part before last JEEP::PATHNAME_SEPARATOR if any.
#define ASSERT(A,...)
Assert macro.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
bool is_valid(const json &js)
Check validity of JSon data.
std::istream & getline(std::istream &in, JString &object)
Read string from input stream until end of line.
$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
General purpose messaging.
Utility class to parse command line options.
void copy(const Head &from, JHead &to)
Copy header from from to to.
then echo Creating output directory
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
#define DEBUG(A)
Message macros.