X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=packages%2Fstd%2Fsrc%2FbbstdExecBbiCommand.cxx;h=aab102e8288ac759327a192a7a38ecfa6634fe5b;hb=1d5111d5487f38d1cde7dcff7f1474189548acaf;hp=ae427d5bf595f549bb0991464e11b0b8983d1b67;hpb=a4fe3363034ebb3d905fc1cdbc6725539bf272a1;p=bbtk.git diff --git a/packages/std/src/bbstdExecBbiCommand.cxx b/packages/std/src/bbstdExecBbiCommand.cxx index ae427d5..aab102e 100755 --- a/packages/std/src/bbstdExecBbiCommand.cxx +++ b/packages/std/src/bbstdExecBbiCommand.cxx @@ -1,73 +1,75 @@ #include "bbstdExecBbiCommand.h" #include "bbstdPackage.h" #include "bbtkInterpreter.h" +#include "bbtkExecuter.h" namespace bbstd { BBTK_ADD_BLACK_BOX_TO_PACKAGE(std,ExecBbiCommand); - BBTK_USER_BLACK_BOX_IMPLEMENTATION(ExecBbiCommand,bbtk::AtomicBlackBox); + BBTK_BLACK_BOX_IMPLEMENTATION(ExecBbiCommand,bbtk::AtomicBlackBox); void ExecBbiCommand::bbUserConstructor() { bbSetInputIn("help"); } - void ExecBbiCommand::DoProcess() { + // Look for the interpreter - bbtk::Interpreter* I = 0; - bool delete_inter = false; - if (bbGetParent() != 0) - { - bbtk::Factory* f = ((bbtk::ComplexBlackBoxDescriptor*)bbGetParent() - ->bbGetDescriptor())->GetFactory(); + bbtk::Interpreter::Pointer I; + bool delete_inter = false; + if (bbGetParent() != 0) + { + bbtk::Factory::Pointer f + = ((bbtk::ComplexBlackBoxDescriptor*)bbGetParent() + ->bbGetDescriptor().get())->GetFactory(); if ((f != 0)&& (f->GetExecuter())) { I = f->GetExecuter()->GetInterpreter(); } - } - if (I==0) - { + } + if (I==0) + { // bbtkError("ExecBbiCommand::DoProcess() : could not find interpreter"); - I = new bbtk::Interpreter(); - delete_inter = true; - } + I = bbtk::Interpreter::New(); + delete_inter = true; + } + + unsigned int i; - int i; - bool ok=true; int pos1=0,pos2; pos2 = bbGetInputIn().find(";",pos1); std::string ccommand; while (ok==true) - { - if (pos2==-1) { - ok=false; - ccommand=bbGetInputIn().substr(pos1,bbGetInputIn().length()-pos1 ); - } else { + if (pos2==-1) + { + ok=false; + ccommand=bbGetInputIn().substr(pos1,bbGetInputIn().length()-pos1 ); + } else { ccommand=bbGetInputIn().substr(pos1,pos2-pos1); } for ( i=0 ; i < ccommand.length() ; i++) + { + if (ccommand[i]==39) { - if (ccommand[i]==39) - { ccommand[i]=34; - } - } - bool insideComment = false; // for multiline comment - I->InterpretLine( ccommand, insideComment); + } + } + + I->InterpretLine( ccommand ); pos1=pos2+1; pos2 = bbGetInputIn().find(";",pos2+1); - + } - if (delete_inter) delete I; - - /* Grrr not works in windows +// if (delete_inter) delete I; + + /* Grrr not works in windows char * pch; pch = strtok (bbGetInputIn(),";"); while (pch != NULL) @@ -80,16 +82,14 @@ namespace bbstd { ccommand[i]=34; } - } + } printf("EED ExecBbiCommand::DoProcess 2 %s\n",ccommand.c_str()); bbtk::Interpreter::mGlobalInterpreter->InterpretLine( ccommand ); pch = strtok (NULL, ";"); } -*/ -} - - + */ + } } // EO namespace bbstd