27int main(
int argc,
char **argv)
39 JParser<> zap(
"Auxiliary program to rename ROOT objects.");
41 zap[
'f'] =
make_field(inputFile,
"<input file>:<object name>");
43 zap[
'R'] =
make_field(rename,
"<target> <replacement>");
48 catch(
const exception &error) {
49 FATAL(error.what() << endl);
55 for (vector<JRootObjectID>::const_iterator input = inputFile.begin(); input != inputFile.end(); ++input) {
57 DEBUG(
"Input: " << *input << endl);
59 TDirectory* dir = getDirectory(*input);
62 ERROR(
"File: " << input->getFullFilename() <<
" not opened." << endl);
66 const TRegexp regexp(input->getObjectName());
68 TIter iter(dir->GetListOfKeys());
70 for (TKey* key; (key = (TKey*) iter.Next()) != NULL; ) {
72 const TString tag(key->GetName());
74 DEBUG(
"Key: " << tag <<
" match = " << tag.Contains(regexp) << endl);
78 if (tag.Contains(regexp) && isTObject(key)) {
81 TString buffer = p->GetName();
83 buffer.ReplaceAll(rename.first.c_str(), rename.second.c_str());
85 DEBUG(p->GetName() <<
" -> " << buffer << endl);
87 dynamic_cast<TNamed*
>(p)->SetName(buffer);
89 listOfObjects.push_back(p);
97 for (
TObject* p: listOfObjects) {