Changeset 1230 in Sophya for trunk/SophyaPI
- Timestamp:
- Oct 12, 2000, 2:54:58 PM (25 years ago)
- Location:
- trunk/SophyaPI/PIext
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaPI/PIext/cxxexecutor.cc
r1224 r1230 8 8 #include "pistdimgapp.h" 9 9 10 11 void FillVStringFrString(string s,vector<string>& vs,char sep = ' '); 10 12 11 13 … … 36 38 kw = "c++args"; 37 39 usage = "c++args: Define user function arguments\n"; 38 usage+= "Usage: c++args arg1 arg2 arg3 ..."; 40 usage+= "Usage: c++args arg1 arg2 arg3 ...\n"; 41 usage+= " c++args -? : give current arguments\n"; 42 usage+= " c++args : reset current arguments"; 39 43 mpiac->RegisterCommand(kw, usage, this, hgrp); 40 44 … … 65 69 usage = "c++include: give personnal includes to be used\n"; 66 70 usage+= "Usage: c++include myinc1.h myinc2.h ...\n"; 71 usage+= " c++include -? : give current include files\n"; 72 usage+= " c++include : reset current include files\n"; 67 73 usage+= "Warning: to be used before c++create... c++exec..."; 68 74 mpiac->RegisterCommand(kw, usage, this, hgrp); … … 71 77 usage = "c++compileopt: give additionnal compile options\n"; 72 78 usage+= "Usage: c++compileopt -g -O5 -IMy_Inc_Dir ...\n"; 79 usage+= " c++compileopt -? : give current compile options\n"; 80 usage+= " c++compileopt : reset current compile options\n"; 73 81 usage+= "Warning: to be used before c++compile"; 74 82 mpiac->RegisterCommand(kw, usage, this, hgrp); … … 76 84 kw = "c++linkopt"; 77 85 usage = "c++linkopt: give additionnal link options\n"; 78 usage+= "Usage: c++linkopt -g -O5 ..."; 86 usage+= "Usage: c++linkopt -g -O5 ...\n"; 87 usage+= " c++linkopt -? : give current link options\n"; 88 usage+= " c++linkopt : reset current link options\n"; 79 89 usage+= "Warning: to be used before c++compile"; 80 90 mpiac->RegisterCommand(kw, usage, this, hgrp); … … 82 92 kw = "c++mylibs"; 83 93 usage = "c++mylibs: give additionnal libraries\n"; 84 usage+= "Usage: c++mylibs -LMy_Lib_Dir -lmylib1 -lmylib2 ..."; 94 usage+= "Usage: c++mylibs -LMy_Lib_Dir -lmylib1 -lmylib2 ...\n"; 95 usage+= " c++mylibs -? : give current additionnal libraries\n"; 96 usage+= " c++mylibs : reset current additionnal libraries\n"; 85 97 usage+= "Warning: to be used before c++compile"; 86 98 mpiac->RegisterCommand(kw, usage, this, hgrp); 99 100 87 101 88 102 kw = "c++setvar"; … … 127 141 128 142 } else if(kw == "c++args") { 129 mCallArgs.resize(0); 130 if(tokens.size()>=1) 131 for(uint_4 i=0;i<tokens.size();i++) mCallArgs.push_back(tokens[i]); 143 if(tokens.size()==1) if(tokens[0]=="-?") cout<<"c++args "<<GetArgs()<<endl; 144 FillArgs(tokens); 132 145 133 146 } else if(kw == "c++create") { … … 159 172 160 173 } else if(kw == "c++include") { 161 mIncList.resize(0); 162 if(tokens.size()>=1) 163 for(uint_4 i=0;i<tokens.size();i++) mIncList.push_back(tokens[i]); 174 if(tokens.size()==1) if(tokens[0]=="-?") cout<<"c++include "<<GetInclude()<<endl; 175 FillInclude(tokens); 164 176 165 177 } else if(kw == "c++compileopt") { 166 mCompOpt = ""; 167 if(tokens.size()>=1) { 168 for(uint_4 i=0;i<tokens.size();i++) mCompOpt += tokens[i] + " "; 169 } 178 if(tokens.size()==1) if(tokens[0]=="-?") cout<<"c++compileopt "<<GetCompileOpt()<<endl; 179 FillCompileOpt(tokens); 170 180 171 181 } else if(kw == "c++linkopt") { 172 mLinkOpt = ""; 173 if(tokens.size()>=1) { 174 for(uint_4 i=0;i<tokens.size();i++) mLinkOpt += tokens[i] + " "; 175 } 182 if(tokens.size()==1) if(tokens[0]=="-?") cout<<"c++linkopt "<<GetLinkOpt()<<endl; 183 FillLinkOpt(tokens); 176 184 177 185 } else if(kw == "c++mylibs") { 178 mMyLibs = "";179 if(tokens.size()>=1) {180 for(uint_4 i=0;i<tokens.size();i++) mMyLibs += tokens[i] + " "; 181 } 186 if(tokens.size()==1) if(tokens[0]=="-?") cout<<"c++mylibs "<<GetLinkLibs()<<endl; 187 FillLinkLibs(tokens); 188 189 182 190 183 191 } else if(kw == "c++setvar") { 184 192 if(tokens.size()<2) { 185 c err << " Usage: c++setvar varname varcontent " <<endl;193 cout<<" Usage: c++setvar varname varcontent "<<endl; 186 194 return(1); 187 195 } … … 193 201 } else if(kw == "c++getvar") { 194 202 if(tokens.size()<1) { 195 c err << " Usage: c++getvar varname " <<endl;203 cout<<" Usage: c++getvar varname "<<endl; 196 204 return(1); 197 205 } 198 206 NamedObjMgr omg; 199 cout << "c++getvar(" << tokens[0] << ")=" << omg.GetVar(tokens[0]) <<endl;207 cout<<"c++getvar("<<tokens[0]<<")="<<omg.GetVar(tokens[0])<<endl; 200 208 } else if(kw == "c++varlist") { 201 209 NamedObjMgr omg; 202 cout <<omg.GetVarList();210 cout<<omg.GetVarList(); 203 211 } 204 212 … … 403 411 } 404 412 405 cout<<"User code filled from file "<<filename<<endl;413 cout<<"User code filled from file "<<filename<<endl; 406 414 return 0; 407 415 } … … 492 500 return 0; 493 501 } 502 503 /* --Methode-- */ 504 void CxxExecutor::FillArgs(vector<string>& args) 505 { 506 mCallArgs.resize(0); 507 if(args.size()<1) return; 508 for(uint_4 i=0;i<args.size();i++) mCallArgs.push_back(args[i]); 509 } 510 511 void CxxExecutor::FillArgs(string& args) 512 { 513 mCallArgs.resize(0); 514 FillVStringFrString(args,mCallArgs,' '); 515 } 516 517 string CxxExecutor::GetArgs(void) 518 { 519 string dum = ""; 520 if(mCallArgs.size()<1) return dum; 521 for(uint_4 i=0;i<mCallArgs.size();i++) dum += mCallArgs[i] + " "; 522 return dum; 523 } 524 525 /* --Methode-- */ 526 void CxxExecutor::FillInclude(vector<string>& inc) 527 { 528 mIncList.resize(0); 529 if(inc.size()<1) return; 530 for(uint_4 i=0;i<inc.size();i++) mIncList.push_back(inc[i]); 531 } 532 533 void CxxExecutor::FillInclude(string& inc) 534 { 535 mIncList.resize(0); 536 FillVStringFrString(inc,mIncList,' '); 537 } 538 539 string CxxExecutor::GetInclude(void) 540 { 541 string dum = ""; 542 if(mIncList.size()<1) return dum; 543 for(uint_4 i=0;i<mIncList.size();i++) dum += mIncList[i] + " "; 544 return dum; 545 } 546 547 /* --Methode-- */ 548 void CxxExecutor::FillCompileOpt(vector<string>& copt) 549 { 550 mCompOpt = ""; 551 if(copt.size()<1) return; 552 for(uint_4 i=0;i<copt.size();i++) mCompOpt += copt[i] + " "; 553 } 554 555 void CxxExecutor::FillCompileOpt(string& copt) 556 { 557 mCompOpt = copt; 558 } 559 560 string CxxExecutor::GetCompileOpt(void) 561 { 562 return mCompOpt; 563 } 564 565 /* --Methode-- */ 566 void CxxExecutor::FillLinkOpt(vector<string>& lopt) 567 { 568 mLinkOpt = ""; 569 if(lopt.size()<1) return; 570 for(uint_4 i=0;i<lopt.size();i++) mLinkOpt += lopt[i] + " "; 571 } 572 573 void CxxExecutor::FillLinkOpt(string& lopt) 574 { 575 mLinkOpt = lopt; 576 } 577 578 string CxxExecutor::GetLinkOpt(void) 579 { 580 return mLinkOpt; 581 } 582 583 /* --Methode-- */ 584 void CxxExecutor::FillLinkLibs(vector<string>& llibs) 585 { 586 mMyLibs = ""; 587 if(llibs.size()<1) return; 588 for(uint_4 i=0;i<llibs.size();i++) mMyLibs += llibs[i] + " "; 589 } 590 591 void CxxExecutor::FillLinkLibs(string& llibs) 592 { 593 mMyLibs = llibs; 594 } 595 596 string CxxExecutor::GetLinkLibs(void) 597 { 598 return mMyLibs; 599 } 600 601 602 494 603 495 604 /* --Methode-- DO NOT DELETE.... cmv property !!! … … 547 656 */ 548 657 658 659 void FillVStringFrString(string s,vector<string>& vs,char sep) 660 // Use string "s" to fill vector of strings "vs" 661 // considering char "sep" as a separator. 662 // Vector is filled from its end (no reset done). 663 // Tp write a "sep" char, use \'sep' 664 // Warning: separator "sep" could not be set to '\' 665 // Ex: sep=' ': s="aaa bbb cc d " -> vs=(aaa,bbb,cc,d) 666 // Ex: sep=';': s="aaa ;bbb; cc;d " -> vs=(aaa ,bbb, cc,d ) 667 // Ex: sep=';': s=";aaa\;bbb;;;ccc;ddd" -> vs=(aaa;bbb,ccc,ddd) 668 // Ex: sep=';': s=";aaa\;bbb;;;ccc;ddd\" -> vs=(aaa;bbb,ccc,ddd\) 669 { 670 uint_4 ls = s.size(); 671 if(ls<=0 || sep=='\\') return; 672 s += sep; // add a separator at the end 673 const char* str = s.c_str(); 674 ls = strlen(str); // str[ls-1]==sep cf ci-dessus 675 string dum = ""; 676 for(uint_4 i=0; i<ls; i++) { 677 if(i==0 && str[i]==sep) { 678 continue; 679 } else if(str[i]=='\\') { 680 if(str[i+1]!=sep || i==ls-2) dum += str[i]; 681 } else if(str[i]!=sep) { 682 dum += str[i]; 683 } else { // C'est un "sep" mais est-ce vraiment un separateur? 684 if(str[i-1]=='\\' && i!=ls-1) dum += str[i]; 685 else { // C'est un separateur, ne delimite t-il pas d'autres separateurs? 686 if(dum.size()<=0) continue; 687 vs.push_back(dum); 688 dum = ""; 689 } 690 } 691 } 692 } -
trunk/SophyaPI/PIext/cxxexecutor.h
r1224 r1230 22 22 CxxExecutor(PIACmd* piac, PIStdImgApp* app); 23 23 virtual ~CxxExecutor(); 24 24 25 virtual int Execute(string& keyw,vector<string>& args); 25 26 … … 33 34 int FillUserCode(vector<string>& usercode,uint_4 first); 34 35 int FillUserCode(string filename); 36 35 37 int Compile(string rootfilename="cxx_spiapp"); 36 38 int CrMakefile(void); 39 37 40 int Link(string libname="cxx_spiapp.so",string func="usercxx"); 38 41 int Call(string func="usercxx"); 39 //int FillArgs(vector<string>& args); 40 //int FillArgs(string& args); 41 //string GetArgs(void); 42 // etc... 43 //int FillInclude(vector<string>& inc); 44 //int FillCompileOpt(vector<string>& copt); 45 //int FillLinkOpt(vector<string>& lopt); 46 //int FillLinkLibs(vector<string>& llibs); 42 43 void FillArgs(vector<string>& args); 44 void FillArgs(string& args); 45 string GetArgs(void); 46 47 void FillInclude(vector<string>& inc); 48 void FillInclude(string& inc); 49 string GetInclude(void); 50 51 void FillCompileOpt(vector<string>& copt); 52 void FillCompileOpt(string& copt); 53 string GetCompileOpt(void); 54 55 void FillLinkOpt(vector<string>& lopt); 56 void FillLinkOpt(string& lopt); 57 string GetLinkOpt(void); 58 59 void FillLinkLibs(vector<string>& llibs); 60 void FillLinkLibs(string& llibs); 61 string GetLinkLibs(void); 47 62 48 63 private: … … 55 70 }; 56 71 57 58 72 #endif
Note:
See TracChangeset
for help on using the changeset viewer.