本文整理汇总了C++中TString::ReadFile方法的典型用法代码示例。如果您正苦于以下问题:C++ TString::ReadFile方法的具体用法?C++ TString::ReadFile怎么用?C++ TString::ReadFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TString
的用法示例。
在下文中一共展示了TString::ReadFile方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: StopXrootd
/**
* Stop a previously started Xrootd server
*
* @return true if stopped, false otherwise
*/
static Bool_t StopXrootd()
{
std::ifstream pidFile("xrd.pid");
if (!pidFile) return false;
TString s; s.ReadFile(pidFile);
pidFile.close();
gSystem->Unlink("xrd.pid");
if (s.IsNull()) return false;
Info("StopXrootd", "Stopping XRootd server (pid: %s)", s.Data());
return gSystem->Exec(Form("kill -9 %s", s.Data())) == 0;
}
示例2: WriteClassWithTemplateImp
//___________________________________________________
void KVClassFactory::WriteClassWithTemplateImp()
{
// Writes the implementation file for the class
ofstream file_cpp;
file_cpp.open( GetImpFileName() );
WriteWhoWhen(file_cpp);
file_cpp << "#include \"" << fClassName.Data() << ".h\"" << endl;
if( fImpInc.GetSize() ){
TIter next(&fImpInc); TObjString* str;
while( (str = (TObjString*)next()) ){
file_cpp << "#include \"" << str->String().Data() << "\"" << endl;
}
}
file_cpp << endl << "ClassImp(" << fClassName.Data() << ")\n" << endl;
file_cpp <<
"////////////////////////////////////////////////////////////////////////////////"
<< endl;
file_cpp << "// BEGIN_HTML <!--" << endl;
file_cpp << "/* -->" << endl;
file_cpp << "<h2>" << fClassName.Data() << "</h2>" << endl;
file_cpp << "<h4>" << fClassDesc.Data() << "</h4>" << endl;
file_cpp << "<!-- */" << endl;
file_cpp << "// --> END_HTML" << endl;
file_cpp <<
"////////////////////////////////////////////////////////////////////////////////\n"
<< endl;
TString cppFile;
ifstream file_cpp_template;
//open file whose full path was stored in fTemplateCPP
if (!KVBase::
SearchAndOpenKVFile(fTemplateCPP.Data(), file_cpp_template)) {
//this should never happen!
cout << "<KVClassFactory::WriteClassWithTemplateImp>: cannot open "
<< fTemplateCPP.Data() << endl;
return;
}
cppFile.ReadFile(file_cpp_template);
file_cpp_template.close();
file_cpp << cppFile.ReplaceAll(fTemplateClassName.Data(),
fClassName.Data());
//write implementations of added methods
if( fMethods.GetSize() ){
KVString line;
TIter next( &fMethods ); KVClassMethod* meth;
while( (meth = (KVClassMethod*)next()) ){
meth->WriteImplementation(line);
line.Prepend("\n//________________________________________________________________\n");
file_cpp << line.Data();
}
}
file_cpp.close();
cout << "<KVClassFactory::WriteClassWithTemplateImp> : File " << GetImpFileName() << " generated." << endl;
}
示例3: WriteClassWithTemplateHeader
//___________________________________________________
void KVClassFactory::WriteClassWithTemplateHeader()
{
//Writes the header file for a class using a template file.
//The ClassDef line in the template file will be replaced with one corresponding to the new class.
ofstream file_h;
file_h.open( GetHeaderFileName() );
WriteWhoWhen(file_h);
WritePreProc(file_h);
ifstream file_h_template;
//open file whose full path was stored in fTemplateH
if (!KVBase::SearchAndOpenKVFile(fTemplateH.Data(), file_h_template)) {
//this should never happen!
cout <<
"<KVClassFactory::WriteClassWithTemplateHeader>: cannot open " <<
fTemplateH.Data() << endl;
return;
}
TString headFile;
headFile.ReadFile(file_h_template);
file_h_template.close();
//find ClassDef
Ssiz_t class_ind;
if ((class_ind = headFile.Index("ClassDef")) > -1) {
//cut file into two parts: before ClassDef line, after ClassDef line
TString part1 = headFile(0, class_ind - 1);
//keep part of file from "ClassDef" onwards.
TString subs = headFile(class_ind, headFile.Length() - 1);
//find next newline character i.e. the end of ClassDef line
Ssiz_t nl = subs.Index("\n");
TString part3 = subs(nl + 1, subs.Length() - 1);
//write ClassDef line
TString part2 = " ClassDef(";
part2 += fClassName;
part2 += ",1)//";
part2 += fClassDesc;
part2 += "\n";
KVString part_add;
//write declarations of added methods
if( fMethods.GetSize() ){
KVString line;
TIter next( &fMethods ); KVClassMethod* meth;
while( (meth = (KVClassMethod*)next()) ){
meth->WriteDeclaration(line);
part_add += " ";
part_add += line;
part_add += "\n";
}
}
//stick all parts together
headFile = part1 + part_add + part2 + part3;
}
file_h << headFile.ReplaceAll(fTemplateClassName.Data(),
fClassName.Data());
file_h << "\n\n#endif" << endl; //don't forget to close the preprocessor #if !!!
file_h.close();
cout << "<KVClassFactory::WriteClassWithTemplateHeader> : File " << GetHeaderFileName() << " generated." << endl;
}