Skip to content
Snippets Groups Projects

Extraargs

Merged Sebastian Neubert requested to merge sneubert/IOjuggler:extraargs into master
1 file
+ 30
10
Compare changes
  • Side-by-side
  • Inline
+ 30
10
@@ -32,6 +32,17 @@
@@ -32,6 +32,17 @@
namespace pt = boost::property_tree;
namespace pt = boost::property_tree;
/**
/**
 
* @fn print_ptree(const pt::ptree& configtree)
 
* @param configtree: reference to ptree that is printed
 
*/
 
inline void print_ptree(const pt::ptree& configtree){
 
for (const auto& it : configtree) {
 
std::cout << it.first << ": " << it.second.get_value<std::string>() << std::endl;
 
print_ptree(it.second);
 
}
 
}
 
 
/**
* @fn parse_options(int argc, char** argv, STRING&& available_options)
* @fn parse_options(int argc, char** argv, STRING&& available_options)
* @param argc, argv: Options to executable
* @param argc, argv: Options to executable
* @param available_options: Options that should be parseable from the executable. The maximally parseable options are currently "c:d:i:j:o:t:hw:r:m:n:".
* @param available_options: Options that should be parseable from the executable. The maximally parseable options are currently "c:d:i:j:o:t:hw:r:m:n:".
@@ -68,6 +79,7 @@ inline const pt::ptree parse_options(int argc, char** argv, STRING&& available_o
@@ -68,6 +79,7 @@ inline const pt::ptree parse_options(int argc, char** argv, STRING&& available_o
};
};
extern char* optarg;
extern char* optarg;
 
extern int optind;
int ca;
int ca;
while ((ca = getopt(argc, argv, options)) != -1){
while ((ca = getopt(argc, argv, options)) != -1){
switch (ca) {
switch (ca) {
@@ -112,6 +124,21 @@ inline const pt::ptree parse_options(int argc, char** argv, STRING&& available_o
@@ -112,6 +124,21 @@ inline const pt::ptree parse_options(int argc, char** argv, STRING&& available_o
}
}
}
}
 
 
// put list of arguments which can't be parsed into the property tree
 
//if (optind >= argc) {
 
// if we reqire additional paremters give an error message
 
//}
 
std::vector<std::string> extraarguments;
 
while (optind < argc) {
 
// use a little trick to create a list of values
 
pt::ptree ptr1;
 
ptr1.put("",std::string(argv[optind++]));
 
parsed_options.add_child("extraargs",ptr1);
 
}
 
 
 
//now check mandatory options
//now check mandatory options
if((opts.Contains("c") && !parsed_options.get_optional<std::string>("config"))
if((opts.Contains("c") && !parsed_options.get_optional<std::string>("config"))
|| (opts.Contains("i") && !parsed_options.get_optional<std::string>("infilename"))
|| (opts.Contains("i") && !parsed_options.get_optional<std::string>("infilename"))
@@ -139,6 +166,8 @@ inline const pt::ptree parse_options(int argc, char** argv, STRING&& available_o
@@ -139,6 +166,8 @@ inline const pt::ptree parse_options(int argc, char** argv, STRING&& available_o
gSystem->mkdir(parsed_options.get<std::string>("workdir").data());
gSystem->mkdir(parsed_options.get<std::string>("workdir").data());
}
}
 
print_ptree(parsed_options);
 
return parsed_options;//the ptree is moved implicitly!
return parsed_options;//the ptree is moved implicitly!
}
}
@@ -188,16 +217,7 @@ inline OBJTYPE* get_obj(TFile* infile, STR&& treename){
@@ -188,16 +217,7 @@ inline OBJTYPE* get_obj(TFile* infile, STR&& treename){
return obj;
return obj;
}
}
/**
* @fn print_ptree(const pt::ptree& configtree)
* @param configtree: reference to ptree that is printed
*/
inline void print_ptree(const pt::ptree& configtree){
for (const auto& it : configtree) {
std::cout << it.first << ": " << it.second.get_value<std::string>() << std::endl;
print_ptree(it.second);
}
}
/**
/**
* @fn get_ptree(STR&& config, bool print = false)
* @fn get_ptree(STR&& config, bool print = false)
* @param config: location of config file
* @param config: location of config file
Loading