19 using std::istringstream;
20 using std::make_shared;
24 typedef std::shared_ptr<ParameterSet>
PSPtr;
50 ostream& operator<<(ostream& out, const std::vector<T>& vec) {
53 for (
auto val : vec ) {
54 if ( ! first ) cout <<
", ";
55 out << delim<T>() <<
val << delim<T>();
67 const string myname =
"fcldump:print_block: ";
75 cout << prefix <<
key <<
": ";
77 if ( dbg ) cout << myname << prefix <<
"Key to sequence: " << key <<
endl;
100 int submaxlev = nlevrem;
101 if ( submaxlev > 0 ) {
104 PSPtrVector subcfgs(submaxlev, std::make_shared<ParameterSet>(pset));
105 subcfgs[0] = std::make_shared<ParameterSet>(pset);
106 cout << prefix <<
"{" <<
endl;
107 print_block(prefix +
" ", &subcfgs[0], submaxlev-1);
108 cout << prefix <<
"}";
110 cout << endl << prefix <<
"]";
112 for (
unsigned int ips=0; ips<psets.size(); ++ips ) cout <<
".";
116 cout <<
"ERROR: Unknown data type for sequence key " << key <<
endl;
126 if ( dbg ) cout << myname << prefix <<
"Key to value: " << key <<
endl;
136 cout <<
"\"" << pcfg->
get<
string>(
key) <<
"\"";
138 cout <<
"ERROR: Unknown data type for non-sequence key " << key <<
endl;
149 if ( dbg ) cout << myname << prefix <<
"Key to parameter set: " <<
key <<
endl;
150 cout << prefix <<
key <<
": {";
153 cout <<
" ERROR!!!!!!!!!!!!!!!!" <<
endl;
156 int nKeysNext = pcfgnext->get_names().size();
157 if ( ! pcfgnext->get_names().size() ) {
159 }
else if ( nlevrem > 0 ) {
163 cout << prefix <<
"}";
165 for (
int ikey=0; ikey<nKeysNext; ++ikey ) cout <<
".";
170 if ( nblk == 0 ) cout << myname <<
"WARNING: Block has no entries." <<
endl;
174 const string myname =
"fcldump: ";
175 bool help = argc == 1;
176 unsigned int maxlev = 0;
179 string arg = argv[1];
180 if ( arg ==
"-h" ) help =
true;
181 else fname = argv[1];
184 istringstream ssarg(argv[2]);
188 cout <<
"Usage: " << argv[0] <<
" FCLFILE [DEPTH]" <<
endl;
189 cout <<
" DEPTH > 0 dumps fcl contents to that depth." <<
endl;
190 cout <<
" Full path to the fcl file is displayed if DEPTH is omitted" <<
endl;
195 string path =
getenv(
"FHICL_FILE_PATH");
196 if ( path.size() == 0 ) path =
".";
199 try { filepath = fpm(fname); }
201 cout << myname <<
"ERROR: Unable to find file " << fname <<
endl;
202 cout << myname <<
"Search path:" <<
endl;
203 string::size_type ipos = 0;
204 while ( ipos != string::npos ) {
205 string::size_type jpos = path.find(
":", ipos+1);
206 cout <<
" " << path.substr(ipos, jpos-ipos) <<
endl;
207 if ( jpos == string::npos )
break;
213 cout << filepath <<
endl;
214 if ( maxlev <= 0 )
return 0;
218 PSPtrVector cfgs(maxlev, std::make_shared<ParameterSet>());
int main(int argc, char **argv)
std::vector< ParameterSet > PSVector
void print_block(string prefix, PSPtr pcfgs[], unsigned int nlevrem)
std::vector< PSPtr > PSPVector
bool is_key_to_sequence(std::string const &key) const
std::vector< std::string > get_pset_names() const
bool is_key_to_table(std::string const &key) const
void swap(Handle< T > &a, Handle< T > &b)
std::string getenv(std::string const &name)
T get(std::string const &key) const
std::shared_ptr< ParameterSet > PSPtr
std::vector< double > DoubleVector
std::vector< PSPtr > PSPtrVector
std::vector< int > IntVector
std::vector< DVVector > DVVVector
std::vector< StringVector > SVVector
std::vector< string > StringVector
std::optional< T > get_if_present(std::string const &key) const
std::vector< std::string > get_names() const
std::vector< DoubleVector > DVVector
cet::coded_exception< error, detail::translate > exception
QTextStream & endl(QTextStream &s)