]> Creatis software - bbtk.git/commitdiff
#3240 BBTK Feature New Normal - ReplaceCleanString box
authorEduardo DAVILA <davila@ei-ed-606.creatis.insa-lyon.fr>
Wed, 20 Mar 2019 13:32:56 +0000 (14:32 +0100)
committerEduardo DAVILA <davila@ei-ed-606.creatis.insa-lyon.fr>
Wed, 20 Mar 2019 13:32:56 +0000 (14:32 +0100)
packages/std/src/bbstdReplaceCleanString.cxx [new file with mode: 0644]
packages/std/src/bbstdReplaceCleanString.h [new file with mode: 0644]
packages/std/src/bbstdReplaceString.cxx

diff --git a/packages/std/src/bbstdReplaceCleanString.cxx b/packages/std/src/bbstdReplaceCleanString.cxx
new file mode 100644 (file)
index 0000000..e778035
--- /dev/null
@@ -0,0 +1,86 @@
+//===== 
+// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
+//===== 
+#include "bbstdReplaceCleanString.h"
+#include "bbstdPackage.h"
+namespace bbstd
+{
+
+BBTK_ADD_BLACK_BOX_TO_PACKAGE(std,ReplaceCleanString)
+BBTK_BLACK_BOX_IMPLEMENTATION(ReplaceCleanString,bbtk::AtomicBlackBox);
+//===== 
+// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
+//===== 
+void ReplaceCleanString::Process()
+{
+
+// THE MAIN PROCESSING METHOD BODY
+//   Here we simply set the input 'In' value to the output 'Out'
+//   And print out the output value
+// INPUT/OUTPUT ACCESSORS ARE OF THE FORM :
+//    void bbSet{Input|Output}NAME(const TYPE&)
+//    const TYPE& bbGet{Input|Output}NAME() const 
+//    Where :
+//    * NAME is the name of the input/output
+//      (the one provided in the attribute 'name' of the tag 'input')
+//    * TYPE is the C++ type of the input/output
+//      (the one provided in the attribute 'type' of the tag 'input')
+
+//    bbSetOutputOut( bbGetInputIn() );
+//    std::cout << "Output value = " <<bbGetOutputOut() << std::endl;
+  
+       std::string subjectIn = bbGetInputIn();
+    if (bbGetInputSearch().length()!=0)
+       {
+               size_t pos = 0;
+               while((pos = subjectIn.find(bbGetInputSearch(), pos)) != std::string::npos) 
+               {
+                       subjectIn.replace(pos, bbGetInputSearch().length(), bbGetInputReplace());
+                       pos += bbGetInputReplace().length();
+               } // while
+       }
+       bbSetOutputOut( subjectIn );
+}
+//===== 
+// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
+//===== 
+void ReplaceCleanString::bbUserSetDefaultValues()
+{
+
+//  SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX 
+//    Here we initialize the input 'In' to 0
+   bbSetInputReplace("");
+   bbSetInputSearch("");
+  
+
+
+}
+//===== 
+// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
+//===== 
+void ReplaceCleanString::bbUserInitializeProcessing()
+{
+
+//  THE INITIALIZATION METHOD BODY :
+//    Here does nothing 
+//    but this is where you should allocate the internal/output pointers 
+//    if any 
+
+  
+}
+//===== 
+// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
+//===== 
+void ReplaceCleanString::bbUserFinalizeProcessing()
+{
+
+//  THE FINALIZATION METHOD BODY :
+//    Here does nothing 
+//    but this is where you should desallocate the internal/output pointers 
+//    if any
+  
+}
+}
+// EO namespace bbstd
+
+
diff --git a/packages/std/src/bbstdReplaceCleanString.h b/packages/std/src/bbstdReplaceCleanString.h
new file mode 100644 (file)
index 0000000..d4c931b
--- /dev/null
@@ -0,0 +1,50 @@
+//===== 
+// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
+//===== 
+#ifndef __bbstdReplaceCleanString_h_INCLUDED__
+#define __bbstdReplaceCleanString_h_INCLUDED__
+
+#include "bbstd_EXPORT.h"
+#include "bbtkAtomicBlackBox.h"
+#include "iostream"
+
+namespace bbstd
+{
+
+class bbstd_EXPORT ReplaceCleanString
+ : 
+   public bbtk::AtomicBlackBox
+{
+  BBTK_BLACK_BOX_INTERFACE(ReplaceCleanString,bbtk::AtomicBlackBox);
+//===== 
+// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
+//===== 
+  BBTK_DECLARE_INPUT(In,std::string);
+  BBTK_DECLARE_INPUT(Replace,std::string);
+  BBTK_DECLARE_INPUT(Search,std::string);
+  BBTK_DECLARE_OUTPUT(Out,std::string);
+  BBTK_PROCESS(Process);
+  void Process();
+//===== 
+// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
+//===== 
+};
+
+BBTK_BEGIN_DESCRIBE_BLACK_BOX(ReplaceCleanString,bbtk::AtomicBlackBox);
+ BBTK_NAME("ReplaceCleanString");
+ BBTK_AUTHOR("InfoDev");
+ BBTK_DESCRIPTION("No Description.");
+ BBTK_CATEGORY("empty");
+ BBTK_INPUT(ReplaceCleanString,In,"Input string",std::string,"");
+ BBTK_INPUT(ReplaceCleanString,Replace,"New string to be put",std::string,"");
+ BBTK_INPUT(ReplaceCleanString,Search,"String to be replaced",std::string,"");
+ BBTK_OUTPUT(ReplaceCleanString,Out,"Output string",std::string,"");
+BBTK_END_DESCRIBE_BLACK_BOX(ReplaceCleanString);
+//===== 
+// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
+//===== 
+}
+// EO namespace bbstd
+
+#endif // __bbstdReplaceCleanString_h_INCLUDED__
+
index 9975048047e94798b4a89a81c7003187c3b9791c..348214bcf11ea59a66482f31a837ceaec3161288 100644 (file)
@@ -50,12 +50,15 @@ void ReplaceString::Process()
        for ( i=0 ; i<size ; i++ )
        {
                subjectInVec = bbGetInputIn()[i];
-               size_t pos = 0;
-               while((pos = subjectInVec.find(bbGetInputSearch(), pos)) != std::string::npos) 
+               if (bbGetInputSearch().length()!=0)
                {
-                       subjectInVec.replace(pos, bbGetInputSearch().length(), bbGetInputReplace());
-                       pos += bbGetInputReplace().length();
-               } // while
+                       size_t pos = 0;
+                       while((pos = subjectInVec.find(bbGetInputSearch(), pos)) != std::string::npos) 
+                       {
+                               subjectInVec.replace(pos, bbGetInputSearch().length(), bbGetInputReplace());
+                               pos += bbGetInputReplace().length();
+                       } // while
+               } // if
                tmpLst.push_back( subjectInVec );
        } // for