本文整理匯總了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);
}