From: guigues Date: Fri, 15 Feb 2008 13:02:47 +0000 (+0000) Subject: *** empty log message *** X-Git-Tag: r0.6.1~192 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=f0bb9e770f5328accf410d2e6e631ccb7bf3a642;p=bbtk.git *** empty log message *** --- diff --git a/packages/std/src/bbstdExecBbiCommand.cxx b/packages/std/src/bbstdExecBbiCommand.cxx new file mode 100755 index 0000000..0310c09 --- /dev/null +++ b/packages/std/src/bbstdExecBbiCommand.cxx @@ -0,0 +1,75 @@ +#include "bbstdExecBbiCommand.h" +#include "bbstdPackage.h" +#include "bbtkInterpreter.h" + +namespace bbstd +{ + + BBTK_ADD_BLACK_BOX_TO_PACKAGE(std,ExecBbiCommand); + BBTK_USER_BLACK_BOX_IMPLEMENTATION(ExecBbiCommand,bbtk::AtomicBlackBox); + + void ExecBbiCommand::bbUserConstructor() + { + bbSetInputIn("help"); + } + + + void ExecBbiCommand::DoProcess() + { + 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 { + ccommand=bbGetInputIn().substr(pos1,pos2-pos1); + } + for ( i=0 ; i < ccommand.length() ; i++) + { + if (ccommand[i]==39) + { + ccommand[i]=34; + } + } + bool insideComment = false; // for multiline comment + bbtk::Interpreter::mGlobalInterpreter->InterpretLine( ccommand, insideComment); + pos1=pos2+1; + pos2 = bbGetInputIn().find(";",pos2+1); + + } + + + +/* Grrr not works in windows + char * pch; + pch = strtok (bbGetInputIn(),";"); + while (pch != NULL) + { + std::string ccommand(pch); + printf("EED ExecBbiCommand::DoProcess 1.1 %s\n",ccommand.c_str()); + for ( i=0 ; i < ccommand.length() ; i++) + { + if (ccommand[i]==39) + { + ccommand[i]=34; + } + } + + printf("EED ExecBbiCommand::DoProcess 2 %s\n",ccommand.c_str()); + bbtk::Interpreter::mGlobalInterpreter->InterpretLine( ccommand ); + pch = strtok (NULL, ";"); + } +*/ +} + + +} // EO namespace bbstd + + diff --git a/packages/std/src/bbstdExecBbiCommand.h b/packages/std/src/bbstdExecBbiCommand.h new file mode 100755 index 0000000..40b6da5 --- /dev/null +++ b/packages/std/src/bbstdExecBbiCommand.h @@ -0,0 +1,35 @@ +#ifndef __bbstdExecBbiCommand_h_INCLUDED__ +#define __bbstdExecBbiCommand_h_INCLUDED__ + +#include "bbtkAtomicBlackBox.h" + +namespace bbstd +{ + + class ExecBbiCommand + : + public bbtk::AtomicBlackBox + { + BBTK_USER_BLACK_BOX_INTERFACE(ExecBbiCommand,bbtk::AtomicBlackBox); + BBTK_DECLARE_INPUT(In,std::string); +// BBTK_DECLARE_OUTPUT(Out,std::string); + BBTK_PROCESS(DoProcess); + void DoProcess(); + + protected: + virtual void bbUserConstructor(); + + }; + + BBTK_BEGIN_DESCRIBE_BLACK_BOX(ExecBbiCommand,bbtk::AtomicBlackBox); + BBTK_NAME("ExecBbiCommand"); + BBTK_AUTHOR("eduardo.davila@creatis.insa-lyon.fr"); + BBTK_DESCRIPTION("Executes bbi commands"); + BBTK_INPUT(ExecBbiCommand,In,"bbi commands separated by ';' , use '' to indicate strings ex. help 'graph' ",std::string); +// BBTK_OUTPUT(ExecBbiCommand,Out,"Concatenated string",std::string); + BBTK_END_DESCRIBE_BLACK_BOX(ExecBbiCommand); + +} // EO namespace bbstd + +#endif // __bbstdExecBbiCommand_h_INCLUDED__ + diff --git a/packages/std/src/bbstdExecSystemCommand.cxx b/packages/std/src/bbstdExecSystemCommand.cxx new file mode 100755 index 0000000..29ad5e2 --- /dev/null +++ b/packages/std/src/bbstdExecSystemCommand.cxx @@ -0,0 +1,73 @@ +#include "bbstdExecSystemCommand.h" +#include "bbstdPackage.h" +#include "bbtkInterpreter.h" + +namespace bbstd +{ + + BBTK_ADD_BLACK_BOX_TO_PACKAGE(std,ExecSystemCommand); + BBTK_USER_BLACK_BOX_IMPLEMENTATION(ExecSystemCommand,bbtk::AtomicBlackBox); + + void ExecSystemCommand::bbUserConstructor() + { + bbSetInputIn("help"); + } + + + void ExecSystemCommand::DoProcess() + { + bool ok=true; + int pos1=0,pos2; + pos2 = bbGetInputIn().find(";",pos1); + std::string ccommand; + while (ok) + { + if (pos2==-1) + { + ok=false; + ccommand=bbGetInputIn().substr(pos1,bbGetInputIn().length()-pos1 ); + } + else + { + ccommand=bbGetInputIn().substr(pos1,pos2-pos1); + } + for (int i=0 ; i < ccommand.length() ; i++) + { + if (ccommand[i]==39) + { + ccommand[i]=34; + } + } + + system ( ccommand.c_str() ); + pos1=pos2+1; + pos2 = bbGetInputIn().find(";",pos2+1); + } + /* + int i; + char *str = (char*)bbGetInputIn().c_str(); + char * pch; + pch = strtok (str,";"); + while (pch != NULL) + { + std::string ccommand(pch); + for ( i=0 ; i < ccommand.length() ; i++) + { + if (ccommand[i]==39) + { + ccommand[i]=34; + } + } + + // bbtk::Interpreter::mGlobalInterpreter->InterpretLine( ccommand ); + system ( ccommand.c_str() ); + pch = strtok (NULL, ";"); + } + // bbSetOutputOut( bbGetInputIn() ); + */ + } + + +} // EO namespace bbstd + + diff --git a/packages/std/src/bbstdExecSystemCommand.h b/packages/std/src/bbstdExecSystemCommand.h new file mode 100755 index 0000000..cc7f72a --- /dev/null +++ b/packages/std/src/bbstdExecSystemCommand.h @@ -0,0 +1,36 @@ +#ifndef __bbstdExecSystemCommand_h_INCLUDED__ +#define __bbstdExecSystemCommand_h_INCLUDED__ + +#include "bbtkAtomicBlackBox.h" + +namespace bbstd +{ + + class ExecSystemCommand + : + public bbtk::AtomicBlackBox + { + BBTK_USER_BLACK_BOX_INTERFACE(ExecSystemCommand,bbtk::AtomicBlackBox); + BBTK_DECLARE_INPUT(In,std::string); +// BBTK_DECLARE_OUTPUT(Out,std::string); + BBTK_PROCESS(DoProcess); + void DoProcess(); + + protected: + virtual void bbUserConstructor(); + + }; + + BBTK_BEGIN_DESCRIBE_BLACK_BOX(ExecSystemCommand,bbtk::AtomicBlackBox); + BBTK_NAME("ExecSystemCommand"); + BBTK_AUTHOR("eduardo.davila@creatis.insa-lyon.fr"); + BBTK_DESCRIPTION("Execute bbi commands"); + BBTK_INPUT(ExecSystemCommand,In,"bbi commands separated by ';' , use '' to indicate strings ex. help 'graph' ",std::string); +// BBTK_OUTPUT(ExecSystemCommand,Out,"Concatenated string",std::string); + BBTK_END_DESCRIBE_BLACK_BOX(ExecSystemCommand); + +} // EO namespace bbstd + +#endif // __bbstdExecSystemCommand_h_INCLUDED__ + +