source: Sophya/trunk/SophyaPI/PIext/cxxexecutor.cc@ 1237

Last change on this file since 1237 was 1237, checked in by ercodmgr, 25 years ago
  • DataType -> DataTypeInfo
  • modifs cxxexecutor pour

nom de variable: var -> $var
pour #include "cxx_spiapp.h"

cmv 18/10/00

  • Property svn:executable set to *
File size: 18.2 KB
Line 
1#include "cxxexecutor.h"
2
3#include <typeinfo>
4
5#include "strutilxx.h"
6#include "dvlist.h"
7
8#include "nomgadapter.h"
9#include "pistdimgapp.h"
10
11
12/* --Methode-- */
13CxxExecutor::CxxExecutor(PIACmd *mpiac, PIStdImgApp* /* app */)
14 : mUserCodeFn(""), mCompOpt(""), mLinkOpt(""), mMyLibs("")
15{
16mIncList.resize(0);
17mCallArgs.resize(0);
18
19// On enregistre les nouvelles commandes
20string hgrp = "CxxExecutorCmd";
21string usage,kw;
22
23kw = "c++exec";
24usage = "c++exec: Execute the following c++ user code\n";
25usage+= "Usage: c++exec c++ user code\n";
26usage+= "Warning: c++ user code can be found in \"cxx_spiapp.h\"\n";
27usage+= " total generated code can be found in \"cxx_spiapp.cc\"";
28mpiac->RegisterCommand(kw, usage, this, hgrp);
29
30kw = "c++execfrf";
31usage = "c++execfrf: Execute c++ user code contained in a file\n";
32usage+= "Usage: c++execfrf fileuser.cc\n";
33usage+= "Warning: total generated code can be found in \"cxx_spiapp.cc\"";
34mpiac->RegisterCommand(kw, usage, this, hgrp);
35
36kw = "c++args";
37usage = "c++args: Define user function arguments for c++exec and c++execfrf\n";
38usage+= "Usage: c++args arg1 arg2 arg3 ...\n";
39usage+= " c++args -? : give current arguments\n";
40usage+= " c++args : reset current arguments";
41mpiac->RegisterCommand(kw, usage, this, hgrp);
42
43kw = "c++create";
44usage = "c++create: create a file to be used by spiapp\n";
45usage+= "Usage: c++create file.cc func c++ user code...\n";
46mpiac->RegisterCommand(kw, usage, this, hgrp);
47
48kw = "c++createfrf";
49usage = "c++createfrf: create a file \"file.cc\"to be used by spiapp\n";
50usage+= " with a user file \"fileuser.cc\"\n";
51usage+= "Usage: c++createfrf file.cc func fileuser.cc\n";
52mpiac->RegisterCommand(kw, usage, this, hgrp);
53
54kw = "c++compile";
55usage = "c++compile: compile a file (file.cc -> file.so)\n";
56usage+= "Usage: c++compile file\n";
57usage+= "Warning: give \"file\" or \"file.so\" to create \"file.so\" from \"file.cc\"\n";
58usage+= " : to be used before c++link";
59mpiac->RegisterCommand(kw, usage, this, hgrp);
60
61kw = "c++link";
62usage = "c++link: link function \"func\" in file.so to spiapp\n";
63usage+= "Usage: c++link file.so func";
64mpiac->RegisterCommand(kw, usage, this, hgrp);
65
66kw = "c++include";
67usage = "c++include: give personnal includes to be used\n";
68usage+= "Usage: c++include myinc1.h myinc2.h ...\n";
69usage+= " c++include -? : give current include files\n";
70usage+= " c++include : reset current include files\n";
71usage+= "Warning: to be used before c++create... c++exec...";
72mpiac->RegisterCommand(kw, usage, this, hgrp);
73
74kw = "c++compileopt";
75usage = "c++compileopt: give additionnal compile options\n";
76usage+= "Usage: c++compileopt -g -O5 -IMy_Inc_Dir ...\n";
77usage+= " c++compileopt -? : give current compile options\n";
78usage+= " c++compileopt : reset current compile options\n";
79usage+= "Warning: to be used before c++compile";
80mpiac->RegisterCommand(kw, usage, this, hgrp);
81
82kw = "c++linkopt";
83usage = "c++linkopt: give additionnal link options\n";
84usage+= "Usage: c++linkopt -g -O5 ...\n";
85usage+= " c++linkopt -? : give current link options\n";
86usage+= " c++linkopt : reset current link options\n";
87usage+= "Warning: to be used before c++compile";
88mpiac->RegisterCommand(kw, usage, this, hgrp);
89
90kw = "c++mylibs";
91usage = "c++mylibs: give additionnal libraries\n";
92usage+= "Usage: c++mylibs -LMy_Lib_Dir -lmylib1 -lmylib2 ...\n";
93usage+= " c++mylibs -? : give current additionnal libraries\n";
94usage+= " c++mylibs : reset current additionnal libraries\n";
95usage+= "Warning: to be used before c++compile";
96mpiac->RegisterCommand(kw, usage, this, hgrp);
97
98
99
100//// A VIRER quand variable de objmanager OK --> Pour Reza
101kw = "c++setvar";
102usage = "c++setvar: Setting test variable \n";
103usage+= "c++setvar varname varcontent ";
104mpiac->RegisterCommand(kw, usage, this, hgrp);
105
106kw = "c++getvar";
107usage = "c++getvar: Getting test variable content\n";
108usage+= "c++getvar varname ";
109mpiac->RegisterCommand(kw, usage, this, hgrp);
110
111kw = "c++varlist";
112usage = "c++getvar: Printing test variable list\n";
113usage+= "c++varlist ";
114mpiac->RegisterCommand(kw, usage, this, hgrp);
115//// A VIRER quand variable de objmanager OK --> Pour Reza
116
117}
118
119/* --Methode-- */
120CxxExecutor::~CxxExecutor()
121{
122}
123
124/* --Methode-- */
125int CxxExecutor::Execute(string& kw, vector<string>& tokens)
126{
127int rc=0;
128if(kw == "c++exec" || kw == "c++execfrf") {
129 if(tokens.size()<1) {
130 cout<<"Usage: c++exec c++ user code"<<endl;
131 cout<<"Usage: c++execfrf fileuser.cc"<<endl;
132 return(1);
133 }
134 if(kw == "c++exec") rc = FillUserCode(tokens,0);
135 if(kw == "c++execfrf") rc = FillUserCode(tokens[0]);
136 if(rc) return(1);
137 rc = CrFile(); if(rc) return(1);
138 rc = Compile(); if(rc) return(1);
139 rc = Link(); if(rc) return(1);
140 rc = Call(); if(rc) return(1);
141
142} else if(kw == "c++args") {
143 if(tokens.size()==1) if(tokens[0]=="-?")
144 {cout<<"c++args "<<GetArgs()<<endl; return(0);}
145 FillArgs(tokens);
146
147} else if(kw == "c++create") {
148 if(tokens.size()<3) {
149 cout<<"Usage: c++create file.cc func c++ user code ..."<<endl;
150 return(1);
151 }
152 rc = FillUserCode(tokens,2); if(rc) return(1);
153 rc = CrFile(tokens[0],tokens[1]); if(rc) return(1);
154
155} else if(kw == "c++createfrf") {
156 if(tokens.size()<3) {
157 cout<<"Usage: c++createfrf file.cc func fileuser.cc"<<endl;
158 return(1);
159 }
160 rc = FillUserCode(tokens[2]); if(rc) return(1);
161 rc = CrFile(tokens[0],tokens[1]); if(rc) return(1);
162
163} else if(kw == "c++compile") {
164 if(tokens.size()>=1) rc = Compile(tokens[0]);
165 else rc = Compile();
166 if(rc) return(1);
167
168} else if(kw == "c++link") {
169 if(tokens.size()>=2) rc = Link(tokens[0],tokens[1]);
170 else if(tokens.size()>=1) rc = Link(tokens[0]);
171 else rc = Link();
172 if(rc) return(1);
173
174} else if(kw == "c++include") {
175 if(tokens.size()==1) if(tokens[0]=="-?")
176 {cout<<"c++include "<<GetInclude()<<endl; return(0);}
177 FillInclude(tokens);
178
179} else if(kw == "c++compileopt") {
180 if(tokens.size()==1) if(tokens[0]=="-?")
181 {cout<<"c++compileopt "<<GetCompileOpt()<<endl; return(0);}
182 FillCompileOpt(tokens);
183
184} else if(kw == "c++linkopt") {
185 if(tokens.size()==1) if(tokens[0]=="-?")
186 {cout<<"c++linkopt "<<GetLinkOpt()<<endl; return(0);}
187 FillLinkOpt(tokens);
188
189} else if(kw == "c++mylibs") {
190 if(tokens.size()==1) if(tokens[0]=="-?")
191 {cout<<"c++mylibs "<<GetLinkLibs()<<endl; return(0);}
192 FillLinkLibs(tokens);
193
194
195//// A VIRER quand variable de objmanager OK --> Pour Reza
196} else if(kw == "c++setvar") {
197 if(tokens.size()<2) {
198 cout<<" Usage: c++setvar varname varcontent "<<endl;
199 return(1);
200 }
201 string varcont = tokens[1];
202 if(tokens.size()>2)
203 for(uint_4 i=2;i<tokens.size();i++) varcont += " " + tokens[i] ;
204 NamedObjMgr omg;
205 omg.SetVar(tokens[0], varcont);
206} else if(kw == "c++getvar") {
207 if(tokens.size()<1) {
208 cout<<" Usage: c++getvar varname "<<endl;
209 return(1);
210 }
211 NamedObjMgr omg;
212 cout<<"c++getvar("<<tokens[0]<<")="<<omg.GetVar(tokens[0])<<endl;
213} else if(kw == "c++varlist") {
214 NamedObjMgr omg;
215 cout<<omg.GetVarList();
216}
217//// A VIRER quand variable de objmanager OK --> Pour Reza
218
219
220return(0);
221}
222
223/* --Methode-- */
224int CxxExecutor::CrFile(string cfilename,string func)
225{
226ofstream os(cfilename.c_str(),ios::out);
227if(!os)
228 {cout<<"CxxExecutor::CrFile: unable to open "<<cfilename<<endl;
229 return 1;}
230
231PutInclude(os);
232os<<endl;
233
234PutIncludeUser(os);
235os<<endl;
236
237os<<"extern \"C\" {"<<endl;
238os<<" int "<<func<<"( vector<string>& args );"<<endl;
239os<<"}"<<endl<<endl;
240os<<"int "<<func<<"( vector<string>& args )"<<endl;
241os<<"{"<<endl;
242os<<"// Some definitions to help using spiapp;"<<endl;
243os<<"NamedObjMgr omg;"<<endl;
244os<<"Services2NObjMgr& srvo = *omg.GetServiceObj();"<<endl;
245os<<endl;
246
247PutObject(os);
248os<<endl;
249
250PutVar(os);
251os<<endl;
252
253os<<"//--------------------------------------------//"<<endl;
254os<<"//------------- Code utilisateur -------------//"<<endl;
255os<<"//--------------------------------------------//"<<endl;
256os<<endl;
257os<<"#include \""<<mUserCodeFn<<"\""<<endl;
258os<<endl;
259
260os<<"return 0;"<<endl;
261os<<"}"<<endl;
262
263cout<<"File "<<cfilename<<" for function "<<func<<" created"<<endl;
264cout<<"User code is in file "<<mUserCodeFn<<" included in "<<cfilename<<endl;
265return 0;
266}
267
268/* --Methode-- */
269void CxxExecutor::PutInclude(ofstream& os)
270{
271os<<"#include \"machdefs.h\""<<endl
272 <<endl
273
274 <<"//---- System et stdc++ include files"<<endl
275 <<"#include <stdio.h>"<<endl
276 <<"#include <stdlib.h>"<<endl
277 <<"#include <math.h>"<<endl
278 <<"#include <ctype.h>"<<endl
279 <<"#include <string.h>"<<endl
280 <<"#include <iostream.h>"<<endl
281 <<"#include <fstream.h>"<<endl
282 <<"#include <complex>"<<endl
283 <<endl
284
285 <<"#include <typeinfo>"<<endl
286 <<"#include <string>"<<endl
287 <<"#include <vector>"<<endl
288 <<"#include <map>"<<endl
289 <<"#include <functional>"<<endl
290 <<"#include <list>"<<endl
291 <<endl
292
293 <<"//---- Sophya include files"<<endl
294 <<"#include \"systools.h\""<<endl
295 <<"#include \"ntools.h\""<<endl
296 <<"#include \"array.h\""<<endl
297 <<"#include \"histats.h\""<<endl
298 <<endl
299
300 <<"//---- Spiapp include files"<<endl
301 <<"#include \"nobjmgr.h\""<<endl
302 <<"#include \"servnobjm.h\""<<endl
303 <<endl
304
305 <<"#define KeepObj(obj) ___nomobj = #obj; omg.AddObj(obj,___nomobj);"<<endl
306 <<"#define KeepVar(var) ___nomobj = #var; omg.GetVarList().Get(___nomobj) = var ;"<<endl
307 <<endl;
308
309return;
310}
311
312/* --Methode-- */
313void CxxExecutor::PutIncludeUser(ofstream& os)
314{
315if(mIncList.size()<1) return;
316for(uint_4 i=0;i<mIncList.size();i++)
317 os<<"#include \""<<mIncList[i]<<"\""<<endl;
318}
319
320/* --Methode-- */
321void CxxExecutor::PutObject(ofstream& os)
322{
323NamedObjMgr omg;
324NObjMgrAdapter* objmgrad;
325vector<string> objlist;
326string patt = "*";
327omg.GetObjList(patt,objlist);
328int nobjs = objlist.size();
329
330os<<"//-------------- Object List --------------"<<endl;
331os<<"//Number of objects = "<<nobjs<<endl;
332os<<"string ___nomobj;"<<endl<<endl;
333if(nobjs<=0) return;
334
335string dir,nobj,stmp,obtype;
336for(int i=0;i<nobjs;i++) {
337 objmgrad = omg.GetObjAdapter(objlist[i]);
338 omg.ParseObjectName(objlist[i],dir,nobj);
339 obtype = objmgrad->GetDataObjType();
340 stmp = "___" + nobj;
341
342 os<<"___nomobj = \""<<nobj<<"\";"<<endl;
343 os<<obtype<<"* "<<stmp
344 <<" = dynamic_cast< "<<obtype<<" * >(omg.GetObj(___nomobj));"<<endl;
345 os<<"if("<<stmp<<"==NULL) throw NullPtrError"
346 <<"(\"CxxExecutor::PutObject: Non existing object "<<nobj
347 <<"... please update file\");"<<endl;
348 os<<obtype<<"& "<<nobj<<" = (*"<<stmp<<");"<<endl<<endl;
349}
350
351return;
352}
353
354/* --Methode-- */
355void CxxExecutor::PutVar(ofstream& os)
356{
357os<<"//-------------- Variable List --------------"<<endl;
358NamedObjMgr omg;
359DVList& varlist = omg.GetVarList();
360// varlist.Show(); varlist.Print();
361DVList::ValList::const_iterator it;
362for(it=varlist.Begin(); it!=varlist.End(); it++) {
363 string key = (*it).first;
364 os<<"___nomobj = \""<<key<<"\";"<<endl;
365 os<<"MuTyV & $"<<key<<" = omg.GetVarList().Get(___nomobj);"<<endl;
366}
367
368return;
369}
370
371/* --Methode-- */
372int CxxExecutor::FillUserCode(vector<string>& usercode,uint_4 first)
373// - first is the first position in the vector<> where the code starts
374// User code is read from input. It is put into file "cxx_spiapp.h".
375{
376mUserCodeFn = "";
377uint_4 nus = usercode.size();
378if(nus<=first) {cout<<"CxxExecutor::FillUserCode: no user code"<<endl;
379 return 1;}
380mUserCodeFn = "cxx_spiapp.h";
381ofstream os(mUserCodeFn.c_str(),ios::out);
382if(!os) {cout<<"CxxExecutor::FillUserCode: unable to open "
383 <<mUserCodeFn<<endl; mUserCodeFn = ""; return 1;}
384// On ajoute un blanc pour les chaines de caracteres contenant des blancs
385for(uint_4 i=first;i<nus;i++) os<<" "<<usercode[i];
386os<<endl;
387cout<<"User code filled from standard input into "<<mUserCodeFn<<endl;
388return 0;
389}
390
391/* --Methode-- */
392int CxxExecutor::FillUserCode(string filename)
393// User code is read from "filename".
394{
395mUserCodeFn = filename;
396cout<<"User code filled from file "<<filename<<endl;
397return 0;
398}
399
400/* --Methode-- */
401int CxxExecutor::Compile(string rootfilename)
402{
403string fc = rootfilename + ".cc";
404string fl = rootfilename + ".so";
405cout<<"Compile: "<<rootfilename<<endl;
406int rc = 0;
407rc = CrMakefile();
408if(rc) return(1);
409string make = "make -f cxx_spiapp_Makefile";
410 make += " CXXFLAGS=\"" + mCompOpt + "\"";
411 make += " LDFLAGS=\"" + mLinkOpt + "\"";
412 make += " MYLIBS=\"" + mMyLibs + "\"";
413 make += " " + rootfilename;
414rc = system(make.c_str());
415if(rc)
416 {cout<<"CxxExecutor::Compile : \n"<<make<<" Failed"<<endl;
417 return 1000+rc;}
418return 0;
419}
420
421/* --Methode-- */
422int CxxExecutor::CrMakefile(void)
423{
424ofstream os("cxx_spiapp_Makefile",ios::out);
425if(!os)
426 {cout<<"CxxExecutor::CrMakefile: unable to open file for Makefile"<<endl;
427 return 1;}
428//---------------------------------------------------------------------
429os<<"MODULEDECCXXFLAGS := -msg_quiet"<<endl;
430os<<"include $(DPCBASEREP)/Include/MakefileUser.h"<<endl;
431os<<"MYLIBS ="<<endl;
432os<<"LIBS = -L$(SLB) -lPI -lextsophya -lsophya -lm"<<endl;
433os<<"ifeq ($(MACHEROS),OSF1)"<<endl;
434os<<"LIBS := $(LIBS) -lfor"<<endl;
435os<<"endif"<<endl;
436os<<"ifeq ($(MACHEROS),Linux)"<<endl;
437os<<"LIBS := $(LIBS) -ldl -lf2c"<<endl;
438os<<"endif"<<endl;
439os<<"%.so:$(OBJ)%.o"<<endl;
440os<<"%:%.cc"<<endl;
441os<<"%:%.o"<<endl;
442os<<"%.o:%.cc"<<endl;
443os<<"%.o:%.c"<<endl;
444os<<"%:%.c"<<endl;
445os<<endl;
446os<<".PRECIOUS: %.so"<<endl;
447os<<endl;
448os<<"%:%.so"<<endl;
449os<<"\t"<<"echo $@ \" made (.so) \""<<endl;
450os<<"%.so:$(OBJ)%.o"<<endl;
451os<<"\t"<<"$(LINK.cc) -shared -o $@ $< $(LIBS) $(MYLIBS)"<<endl;
452os<<"$(OBJ)%.o:%.cc"<<endl;
453os<<"\t"<<"$(COMPILE.cc) -o $@ $<"<<endl;
454os<<"$(OBJ)%.o:%.c"<<endl;
455os<<"\t"<<"$(COMPILE.c) -c $(CFLAGS) $(USERFLAGS) -o $@ $<"<<endl;
456//---------------------------------------------------------------------
457return 0;
458}
459
460/* --Methode-- */
461int CxxExecutor::Link(string libname,string func)
462{
463NamedObjMgr omg;
464PIACmd* mpiac = omg.GetImgApp()->CmdInterpreter();
465string key("link");
466vector<string> arg; arg.push_back(libname); arg.push_back(func);
467int rc = mpiac->ExecuteCommand(key,arg);
468cout<<"Link from "<<libname<<" for function "<<func
469 <<" (rc="<<rc<<")"<<endl;
470return 0;
471}
472
473/* --Methode-- */
474int CxxExecutor::Call(string func)
475{
476NamedObjMgr omg;
477PIACmd* mpiac = omg.GetImgApp()->CmdInterpreter();
478string key("call");
479vector<string> arg; arg.push_back(func);
480if(mCallArgs.size()>0)
481 for(uint_4 i=0;i<mCallArgs.size();i++) arg.push_back(mCallArgs[i]);
482mpiac->ExecuteCommand(key,arg);
483return 0;
484}
485
486/* --Methode-- */
487void CxxExecutor::FillArgs(vector<string>& args)
488{
489mCallArgs.resize(0);
490if(args.size()<1) return;
491for(uint_4 i=0;i<args.size();i++) mCallArgs.push_back(args[i]);
492}
493
494void CxxExecutor::FillArgs(string& args)
495{
496mCallArgs.resize(0);
497FillVStringFrString(args,mCallArgs,' ');
498}
499
500string CxxExecutor::GetArgs(void)
501{
502string dum = "";
503if(mCallArgs.size()<1) return dum;
504for(uint_4 i=0;i<mCallArgs.size();i++) dum += mCallArgs[i] + " ";
505return dum;
506}
507
508/* --Methode-- */
509void CxxExecutor::FillInclude(vector<string>& inc)
510{
511mIncList.resize(0);
512if(inc.size()<1) return;
513for(uint_4 i=0;i<inc.size();i++) mIncList.push_back(inc[i]);
514}
515
516void CxxExecutor::FillInclude(string& inc)
517{
518mIncList.resize(0);
519FillVStringFrString(inc,mIncList,' ');
520}
521
522string CxxExecutor::GetInclude(void)
523{
524string dum = "";
525if(mIncList.size()<1) return dum;
526for(uint_4 i=0;i<mIncList.size();i++) dum += mIncList[i] + " ";
527return dum;
528}
529
530/* --Methode-- */
531void CxxExecutor::FillCompileOpt(vector<string>& copt)
532{
533mCompOpt = "";
534if(copt.size()<1) return;
535for(uint_4 i=0;i<copt.size();i++) mCompOpt += copt[i] + " ";
536}
537
538void CxxExecutor::FillCompileOpt(string& copt)
539{
540mCompOpt = copt;
541}
542
543string CxxExecutor::GetCompileOpt(void)
544{
545return mCompOpt;
546}
547
548/* --Methode-- */
549void CxxExecutor::FillLinkOpt(vector<string>& lopt)
550{
551mLinkOpt = "";
552if(lopt.size()<1) return;
553for(uint_4 i=0;i<lopt.size();i++) mLinkOpt += lopt[i] + " ";
554}
555
556void CxxExecutor::FillLinkOpt(string& lopt)
557{
558mLinkOpt = lopt;
559}
560
561string CxxExecutor::GetLinkOpt(void)
562{
563return mLinkOpt;
564}
565
566/* --Methode-- */
567void CxxExecutor::FillLinkLibs(vector<string>& llibs)
568{
569mMyLibs = "";
570if(llibs.size()<1) return;
571for(uint_4 i=0;i<llibs.size();i++) mMyLibs += llibs[i] + " ";
572}
573
574void CxxExecutor::FillLinkLibs(string& llibs)
575{
576mMyLibs = llibs;
577}
578
579string CxxExecutor::GetLinkLibs(void)
580{
581return mMyLibs;
582}
583
584
585
586
587/* --Methode-- DO NOT DELETE.... cmv property !!!
588int CxxExecutor::FillUserCode(vector<string>& usercode,uint_4 first)
589{
590mUserCodeFn = "";
591uint_4 nus = usercode.size();
592if(nus<=first) {
593 cout<<"CxxExecutor::FillUserCode: no user code"<<endl;
594 return 1;
595}
596mUserCodeFn = "cxx_spiapp.h";
597ofstream os(mUserCodeFn.c_str(),ios::out);
598if(!os)
599 {cout<<"CxxExecutor::FillUserCode: unable to open "<<mUserCodeFn<<endl;
600 mUserCodeFn = ""; return 1;}
601// **** 1er probleme ****
602// - Pour la lisibilite et eviter les bugs avec les chaines de caracteres
603// contenant des blancs, on ne casse les lignes qu'apres un ";" a condition
604// qu'il ne soit pas dans une chaine de caracteres c'est a dire
605// entoure de "....;....".
606// - Attention aux " dans les chaines de caracteres: "...\"..."
607// - Bugs non-gere pour les tortures: ".....\\" suivi par une autre
608// chaine de caracteres qui contient un ';'
609// ex: cout<<"aaa\\"; cout<<"blabla;blabla";
610// **** 2ieme probleme ****
611// - Le decodeur de ligne va couper les commentaires qui contiennent des blancs:
612// "salut ca va" --> tokens[0]="salut tokens[1]=ca tokens[2]=va" --> "salutcava"
613// - On contourne partiellement le pb en ajoutant un blanc en debut des tokens[]
614// identifies comme etant dans une chaine de caracteres (mais impossible de gerer
615// si il y a plusieurs blancs!): "salut ca va" -> "salut ca va"
616// **** Conclusion ****
617// Pour ecrire du code sophistique, le faire dans un fichier
618string dum = "";
619bool lastchar = false;
620bool comment = false;
621for(uint_4 i=first;i<nus;i++) {
622 const char* str = usercode[i].c_str();
623 size_t lstr= strlen(str);
624 for(uint_4 j=0;j<lstr;j++) {
625 // debut de mot dans un commentaire -> ajouter un blanc
626 if(j==0 && comment) dum += " ";
627 // on arrive sur un " : debut ou fin commentaire? inactif (\")?
628 if(str[j]=='"') {
629 if(j==0) comment = (comment) ? false: true;
630 else {if(str[j-1]!='\\') comment = (comment) ? false: true;}
631 }
632 dum += str[j];
633 if( i==nus-1 && j==lstr-1 ) lastchar = true;
634 // On charge la string "dum" si : 1-/ on a un ";"
635 // 2-/ c'est le dernier charactere
636 if((str[j]==';' && !comment) || lastchar)
637 {os<<dum<<endl; dum = "";}
638 }
639}
640cout<<"User code filled from standard input into "<<mUserCodeFn<<endl;
641return 0;
642}
643*/
Note: See TracBrowser for help on using the repository browser.