]> Creatis software - bbtk.git/blobdiff - packages/std/src/bbstdReplaceString.cxx
#2951 BBTK Feature New Normal - Replace String box with vector functionality
[bbtk.git] / packages / std / src / bbstdReplaceString.cxx
index c8ea640dfb4d9f996c9941a69f8dc6be68203f2a..9975048047e94798b4a89a81c7003187c3b9791c 100644 (file)
@@ -28,15 +28,39 @@ void ReplaceString::Process()
 
 //    bbSetOutputOut( bbGetInputIn() );
 //    std::cout << "Output value = " <<bbGetOutputOut() << std::endl;
+
   
-       std::string subject = bbGetInputIn();
+/*
+ // In 
+       std::string subjectIn = bbGetInputIn();
        size_t pos = 0;
-       while((pos = subject.find(bbGetInputSearch(), pos)) != std::string::npos) 
+       while((pos = subjectIn.find(bbGetInputSearch(), pos)) != std::string::npos) 
        {
-               subject.replace(pos, bbGetInputSearch().length(), bbGetInputReplace());
+               subjectIn.replace(pos, bbGetInputSearch().length(), bbGetInputReplace());
                pos += bbGetInputReplace().length();
-       }
-       bbSetOutputOut(subject);
+       } // while
+*/
+
+
+ // InVec
+//     std::string 
+       std::string subjectInVec;
+       std::vector< std::string > tmpLst;
+       int i,size=bbGetInputIn().size();
+       for ( i=0 ; i<size ; i++ )
+       {
+               subjectInVec = bbGetInputIn()[i];
+               size_t pos = 0;
+               while((pos = subjectInVec.find(bbGetInputSearch(), pos)) != std::string::npos) 
+               {
+                       subjectInVec.replace(pos, bbGetInputSearch().length(), bbGetInputReplace());
+                       pos += bbGetInputReplace().length();
+               } // while
+               tmpLst.push_back( subjectInVec );
+       } // for
+
+//     bbSetOutputOut( subjectIn );
+       bbSetOutputOut( tmpLst );
 
 }
 //===== 
@@ -47,7 +71,7 @@ void ReplaceString::bbUserSetDefaultValues()
 
 //  SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX 
 //    Here we initialize the input 'In' to 0
-   bbSetInputIn("");
+//   bbSetInputIn("");
    bbSetInputReplace("");
    bbSetInputSearch("");