本文整理汇总了C++中TList::AddBefore方法的典型用法代码示例。如果您正苦于以下问题:C++ TList::AddBefore方法的具体用法?C++ TList::AddBefore怎么用?C++ TList::AddBefore使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TList
的用法示例。
在下文中一共展示了TList::AddBefore方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: merge
void merge(TString outfile, TString firstfile, TString pat=defaultPattern)
{
TList decayModes;
bool save=false;
TString dir=".";
TString first="";
long flags=0,id=0,size=0,modtime=0;
if(firstfile.Contains("~"))
{
cout<<"ERROR: input path cannot contain '~' character."<<endl;
return;
}
// Check pattern
TRegexp pattern(pat,true);
if(pattern.Status()!=0)
{
cout<<"ERROR: Wrong regular expression."<<endl;
return;
}
// Load libraries
loadLibs();
gSystem->GetPathInfo(firstfile, &id, &size, &flags, &modtime);
bool isDirectory = flags&2;
if(isDirectory)
{
dir=firstfile;
first="";
}
else
{
//Separate directory from filename
int separator=firstfile.Last('/');
if(separator!=-1) dir=firstfile(0,separator+1);
first=firstfile(separator+1,firstfile.Length());
}
cout<<"Output file: "<<outfile<<endl;
cout<<"Input dir: "<<dir<<endl;
if(!isDirectory) cout<<"First file: "<<first<<endl;
cout<<endl;
// Get file list and add first file if present
TList *files = getFileList(first,dir,pattern);
if(!isDirectory)
{
TFile *ff = new TFile(firstfile,"READ");
files->AddBefore(files->First(),ff);
}
// Merge files
TIter next(files);
TFile *file;
while(file = (TFile*)next())
{
if(!file->IsOpen()) continue;
ReadFile(file,decayModes);
cout<<"=============================="<<endl;
save=true;
}
// Save output
if(save)
{
cout<<"Saving..."<<endl;
SaveOutput(outfile,decayModes);
cout<<"Output saved to "<<outfile<<endl<<endl;
}
else cout<<"Nothing to save."<<endl<<endl;
// Closing files
cout<<"Closing files..."<<endl;
TIter cl(files);
while(file = (TFile*)cl()) { file->Close(); delete file; }
delete files;
gSystem->Exit(0);
}