void endDoc() { curTf_ = 0; set_.clear(); }
void endDoc() { docNum_++; set_.clear(); }
bool ProcessComponent(const char* comp_name, const string& vc_name, const string& filter_modules, const string& filter_disabled, const string& filter_headers, const char* define) { ProjLines.clear(); ProjAssoc.clear(); int comp_len=strlen(comp_name); char buf[1024]; printf("Processing %s...\n",comp_name); FILE* vc_file=fopen(vc_name.c_str(),"r"); if(!vc_file) { printf("Couldn't open %s for reading.\n",vc_name.c_str()); return false; } BufState=0; while(fgets(buf,1024,vc_file)) { ParseBufVC(buf,filter_modules,filter_disabled,filter_headers); } fclose(vc_file); string script_name=Map["ScriptsDirectory"]; script_name+="scripts.cfg"; FILE* script_file=fopen(script_name.c_str(),"r"); if(!script_file) { printf("Couldn't open %s for reading.\n",script_name.c_str()); return false; } Modules.clear(); DisabledModules.clear(); Headers.clear(); while(fgets(buf,1024,vc_file)) { int pos=0; bool enabled=false; string line(buf); StrVec vec; int tok=strsplit(line,vec); if(!tok) continue; if(!vec[0].compare("@")) { pos++; enabled=true; }; if(tok<pos+3) continue; if(!vec[pos].compare(comp_name) && !vec[pos+1].compare("module")) { if(enabled) Modules.insert(stolower(vec[pos+2]+".fos")); else DisabledModules.insert(stolower(vec[pos+2]+".fos")); } } fclose(script_file); for(StrSet::iterator it=Modules.begin(),end=Modules.end(); it!=end; ++it) { Defines.clear(); Defines.insert(string(define)); IgnoreDepth=0; Depth=0; string name=*it; printf("Preprocessing %s...\n",name.c_str()); int idx=name.find_last_of("/"); string dir=""; if(idx!=-1) { dir=name.substr(0,idx+1); name=name.substr(idx+1,name.length()-idx-1); } if(!RecursiveParse(name,dir)) { printf("Failed to preprocess %s.\n",name.c_str()); return false; } } // write the project file vc_file=fopen(vc_name.c_str(),"w"); if(!vc_file) { printf("Couldn't open %s for writing.\n","test.log"); return false; } for(int i=0,j=ProjLines.size(); i<j; i++) { if(ProjAssoc.count(i)) { string name=ProjAssoc[i]; StrSet* the_set=NULL; if(!name.compare(filter_modules)) the_set=&Modules; else if(!name.compare(filter_disabled)) the_set=&DisabledModules; else if(!name.compare(filter_headers)) { the_set=&Headers; fprintf(vc_file, "\t\t\t<File\n" "\t\t\t\tRelativePath=\".\\intellisense"); if(!strcmp(comp_name,"client")) fprintf(vc_file,"_client"); else if(!strcmp(comp_name,"mapper")) fprintf(vc_file,"_mapper"); fprintf(vc_file,".h\"\n" "\t\t\t\t>\n" "\t\t\t</File>\n"); } for(StrSet::iterator it=the_set->begin(),end=the_set->end(); it!=end; ++it) { fprintf(vc_file, "\t\t\t<File\n" "\t\t\t\tRelativePath=\"%s%s\"\n" "\t\t\t\t>\n" "\t\t\t</File>\n", Map["FilesRelativePath"].c_str(),it->c_str()); } } fprintf(vc_file,"%s",ProjLines[i].c_str()); } fclose(vc_file); printf("Processing %s complete.\n",comp_name); return true; }