Changeset 1230 in Sophya for trunk/SophyaPI


Ignore:
Timestamp:
Oct 12, 2000, 2:54:58 PM (25 years ago)
Author:
ercodmgr
Message:

Get and Set pour cxxexecutor options cmv 12/10/00

Location:
trunk/SophyaPI/PIext
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaPI/PIext/cxxexecutor.cc

    r1224 r1230  
    88#include "pistdimgapp.h"
    99
     10
     11void FillVStringFrString(string s,vector<string>& vs,char sep = ' ');
    1012
    1113
     
    3638kw = "c++args";
    3739usage = "c++args: Define user function arguments\n";
    38 usage+= "Usage: c++args arg1 arg2 arg3 ...";
     40usage+= "Usage: c++args arg1 arg2 arg3 ...\n";
     41usage+= "       c++args -? : give current arguments\n";
     42usage+= "       c++args    : reset current arguments";
    3943mpiac->RegisterCommand(kw, usage, this, hgrp);
    4044
     
    6569usage = "c++include: give personnal includes to be used\n";
    6670usage+= "Usage: c++include myinc1.h myinc2.h ...\n";
     71usage+= "       c++include -? : give current include files\n";
     72usage+= "       c++include    : reset current include files\n";
    6773usage+= "Warning: to be used before c++create... c++exec...";
    6874mpiac->RegisterCommand(kw, usage, this, hgrp);
     
    7177usage = "c++compileopt: give additionnal compile options\n";
    7278usage+= "Usage: c++compileopt -g -O5 -IMy_Inc_Dir ...\n";
     79usage+= "       c++compileopt -? : give current compile options\n";
     80usage+= "       c++compileopt    : reset current compile options\n";
    7381usage+= "Warning: to be used before c++compile";
    7482mpiac->RegisterCommand(kw, usage, this, hgrp);
     
    7684kw = "c++linkopt";
    7785usage = "c++linkopt: give additionnal link options\n";
    78 usage+= "Usage: c++linkopt -g -O5 ...";
     86usage+= "Usage: c++linkopt -g -O5 ...\n";
     87usage+= "       c++linkopt -? : give current link options\n";
     88usage+= "       c++linkopt    : reset current link options\n";
    7989usage+= "Warning: to be used before c++compile";
    8090mpiac->RegisterCommand(kw, usage, this, hgrp);
     
    8292kw = "c++mylibs";
    8393usage = "c++mylibs: give additionnal libraries\n";
    84 usage+= "Usage: c++mylibs -LMy_Lib_Dir -lmylib1 -lmylib2 ...";
     94usage+= "Usage: c++mylibs -LMy_Lib_Dir -lmylib1 -lmylib2 ...\n";
     95usage+= "       c++mylibs -? : give current additionnal libraries\n";
     96usage+= "       c++mylibs    : reset current additionnal libraries\n";
    8597usage+= "Warning: to be used before c++compile";
    8698mpiac->RegisterCommand(kw, usage, this, hgrp);
     99
     100
    87101
    88102kw = "c++setvar";
     
    127141
    128142} 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);
    132145
    133146} else if(kw == "c++create") {
     
    159172
    160173} 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);
    164176
    165177} 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);
    170180
    171181} 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);
    176184
    177185} 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
    182190
    183191} else if(kw == "c++setvar") {
    184192  if(tokens.size()<2) {
    185     cerr << " Usage: c++setvar varname varcontent " << endl;
     193    cout<<" Usage: c++setvar varname varcontent "<<endl;
    186194    return(1);
    187195  }
     
    193201} else if(kw == "c++getvar") {
    194202  if(tokens.size()<1) {
    195     cerr << " Usage: c++getvar varname " << endl;
     203    cout<<" Usage: c++getvar varname "<<endl;
    196204    return(1);
    197205  }
    198206  NamedObjMgr omg;
    199   cout << "c++getvar(" << tokens[0] << ")=" << omg.GetVar(tokens[0]) << endl;
     207  cout<<"c++getvar("<<tokens[0]<<")="<<omg.GetVar(tokens[0])<<endl;
    200208}  else if(kw == "c++varlist") {
    201209  NamedObjMgr omg;
    202   cout << omg.GetVarList();
     210  cout<<omg.GetVarList();
    203211}
    204212
     
    403411}
    404412
    405 cout<<"User code filled from file"<<filename<<endl;
     413cout<<"User code filled from file "<<filename<<endl;
    406414return 0;
    407415}
     
    492500return 0;
    493501}
     502
     503/* --Methode-- */
     504void CxxExecutor::FillArgs(vector<string>& args)
     505{
     506mCallArgs.resize(0);
     507if(args.size()<1) return;
     508for(uint_4 i=0;i<args.size();i++) mCallArgs.push_back(args[i]);
     509}
     510
     511void CxxExecutor::FillArgs(string& args)
     512{
     513mCallArgs.resize(0);
     514FillVStringFrString(args,mCallArgs,' ');
     515}
     516
     517string CxxExecutor::GetArgs(void)
     518{
     519string dum = "";
     520if(mCallArgs.size()<1) return dum;
     521for(uint_4 i=0;i<mCallArgs.size();i++) dum += mCallArgs[i] + " ";
     522return dum;
     523}
     524
     525/* --Methode-- */
     526void CxxExecutor::FillInclude(vector<string>& inc)
     527{
     528mIncList.resize(0);
     529if(inc.size()<1) return;
     530for(uint_4 i=0;i<inc.size();i++) mIncList.push_back(inc[i]);
     531}
     532
     533void CxxExecutor::FillInclude(string& inc)
     534{
     535mIncList.resize(0);
     536FillVStringFrString(inc,mIncList,' ');
     537}
     538
     539string CxxExecutor::GetInclude(void)
     540{
     541string dum = "";
     542if(mIncList.size()<1) return dum;
     543for(uint_4 i=0;i<mIncList.size();i++) dum += mIncList[i] + " ";
     544return dum;
     545}
     546
     547/* --Methode-- */
     548void CxxExecutor::FillCompileOpt(vector<string>& copt)
     549{
     550mCompOpt = "";
     551if(copt.size()<1) return;
     552for(uint_4 i=0;i<copt.size();i++) mCompOpt += copt[i] + " ";
     553}
     554
     555void CxxExecutor::FillCompileOpt(string& copt)
     556{
     557mCompOpt = copt;
     558}
     559
     560string CxxExecutor::GetCompileOpt(void)
     561{
     562return mCompOpt;
     563}
     564
     565/* --Methode-- */
     566void CxxExecutor::FillLinkOpt(vector<string>& lopt)
     567{
     568mLinkOpt = "";
     569if(lopt.size()<1) return;
     570for(uint_4 i=0;i<lopt.size();i++) mLinkOpt += lopt[i] + " ";
     571}
     572
     573void CxxExecutor::FillLinkOpt(string& lopt)
     574{
     575mLinkOpt = lopt;
     576}
     577
     578string CxxExecutor::GetLinkOpt(void)
     579{
     580return mLinkOpt;
     581}
     582
     583/* --Methode-- */
     584void CxxExecutor::FillLinkLibs(vector<string>& llibs)
     585{
     586mMyLibs = "";
     587if(llibs.size()<1) return;
     588for(uint_4 i=0;i<llibs.size();i++) mMyLibs += llibs[i] + " ";
     589}
     590
     591void CxxExecutor::FillLinkLibs(string& llibs)
     592{
     593mMyLibs = llibs;
     594}
     595
     596string CxxExecutor::GetLinkLibs(void)
     597{
     598return mMyLibs;
     599}
     600
     601
     602
    494603
    495604/* --Methode--  DO NOT DELETE.... cmv property !!!
     
    547656*/
    548657
     658
     659void 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{
     670uint_4 ls = s.size();
     671if(ls<=0 || sep=='\\') return;
     672s += sep; // add a separator at the end
     673const char* str = s.c_str();
     674ls = strlen(str); // str[ls-1]==sep cf ci-dessus
     675string dum = "";
     676for(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  
    2222           CxxExecutor(PIACmd* piac, PIStdImgApp* app);
    2323  virtual ~CxxExecutor();
     24
    2425  virtual int Execute(string& keyw,vector<string>& args);
    2526
     
    3334  int  FillUserCode(vector<string>& usercode,uint_4 first);
    3435  int  FillUserCode(string filename);
     36
    3537  int  Compile(string rootfilename="cxx_spiapp");
    3638       int CrMakefile(void);
     39
    3740  int  Link(string libname="cxx_spiapp.so",string func="usercxx");
    3841  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);
    4762
    4863private:
     
    5570};
    5671
    57 
    5872#endif
Note: See TracChangeset for help on using the changeset viewer.