//___________________________________________________ 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; }
//___________________________________________________ void KVClassFactory::WriteClassImp() { //Write the class implementation file //This includes a class description in pure HTML 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; file_cpp << fClassName.Data() << "::" << fClassName. Data() << "()" << endl; file_cpp << "{\n // Default constructor\n}\n" << endl; // any other ctors ? KVList* ctor = (KVList*)fMethods.GetSubListWithMethod("1", "IsConstructor"); if( ctor->GetEntries() ){ KVString line; TIter next( ctor ); KVClassMethod* meth; while( (meth = (KVClassMethod*)next()) ){ meth->WriteImplementation(line); line.Prepend("//________________________________________________________________\n\n"); file_cpp << line.Data() << endl; } } delete ctor; file_cpp << fClassName.Data() << "::~" << fClassName. Data() << "()" << endl; file_cpp << "{\n // Destructor\n}\n" << endl; //write implementations of added methods if( fMethods.GetSize() ){ KVString line; TIter next( &fMethods ); KVClassMethod* meth; while( (meth = (KVClassMethod*)next()) ){ if( !meth->IsConstructor() ){ meth->WriteImplementation(line); line.Prepend("//________________________________________________________________\n\n"); file_cpp << line.Data() << endl; } } } file_cpp.close(); cout << "<KVClassFactory::WriteClassImp> : File " << GetImpFileName() << " generated." << endl; }