//=====
#include "bbstdVectorFilterString.h"
#include "bbstdPackage.h"
+
+#include <string>
+#include <stdlib.h>
namespace bbstd
{
// 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 VectorFilterString::CountConnectedRepetitions()
+{
+ std::vector<std::string> vOut0;
+ std::vector<std::string> vOut1;
+ std::vector<std::string> vOut2;
+ std::vector<std::string> vOut3;
+ std::vector<std::string> vOut4;
+ std::vector<std::string> vOut5;
+ std::vector<std::string> vOut6;
+ std::vector<std::string> vOut7;
+ std::vector<std::string> vOut8;
+ std::vector<std::string> vOut9;
+ ConnectionRepetitions( bbGetInputIn0() , &vOut0 );
+ ConnectionRepetitions( bbGetInputIn1() , &vOut1 );
+ ConnectionRepetitions( bbGetInputIn2() , &vOut2 );
+ ConnectionRepetitions( bbGetInputIn3() , &vOut3 );
+ ConnectionRepetitions( bbGetInputIn4() , &vOut4 );
+ ConnectionRepetitions( bbGetInputIn5() , &vOut5 );
+ ConnectionRepetitions( bbGetInputIn6() , &vOut6 );
+ ConnectionRepetitions( bbGetInputIn7() , &vOut7 );
+ ConnectionRepetitions( bbGetInputIn8() , &vOut8 );
+ ConnectionRepetitions( bbGetInputIn9() , &vOut9 );
+ bbSetOutputOut0( vOut0 );
+ bbSetOutputOut1( vOut1 );
+ bbSetOutputOut2( vOut2 );
+ bbSetOutputOut3( vOut3 );
+ bbSetOutputOut4( vOut4 );
+ bbSetOutputOut5( vOut5 );
+ bbSetOutputOut6( vOut6 );
+ bbSetOutputOut7( vOut7 );
+ bbSetOutputOut8( vOut8 );
+ bbSetOutputOut9( vOut9 );
+}
+
void VectorFilterString::ConnectionRepetitions( std::vector<std::string> vIn,std::vector<std::string> *vOut )
{
int i,size=vIn.size();
{
acum++;
} else {
- itmp=i;
+ itmp = i;
vOut->push_back(std::to_string(acum));
- acum=1;
+ acum = 1;
}
} // for
vOut->push_back(std::to_string(acum));
void VectorFilterString::InsertStringPos()
{
- printf("VectorFilterString::InsertStringPos Start\n" );
std::vector<std::string> vOut0;
std::vector<std::string> vOut1;
std::vector<std::string> vOut2;
std::vector<std::string> vOut7;
std::vector<std::string> vOut8;
std::vector<std::string> vOut9;
-
int i,size = bbGetInputIn0().size();
std::string sk1 = bbGetInputsk1();
- printf("VectorFilterString::InsertStringPos sk1=%s sk2=%s \n", bbGetInputsk1().c_str() , bbGetInputsk2().c_str() );
int pos = atoi( bbGetInputsk2().c_str() );
-
- printf("VectorFilterString::InsertStringPos pos=%d sk1=%s \n", pos, sk1.c_str() );
for (i=0; i<size; i++)
{
vOut0.push_back( bbGetInputIn0()[i].insert(pos,sk1) );
- printf("VectorFilterString::InsertStringPos i=%s \n", vOut0[i].c_str() );
if ( i < bbGetInputIn1().size() ) { vOut1.push_back( bbGetInputIn1()[i].insert(pos,sk1) ); }
if ( i < bbGetInputIn2().size() ) { vOut2.push_back( bbGetInputIn2()[i].insert(pos,sk1) ); }
if ( i < bbGetInputIn3().size() ) { vOut3.push_back( bbGetInputIn3()[i].insert(pos,sk1) ); }
if ( i < bbGetInputIn8().size() ) { vOut8.push_back( bbGetInputIn8()[i].insert(pos,sk1) ); }
if ( i < bbGetInputIn9().size() ) { vOut9.push_back( bbGetInputIn9()[i].insert(pos,sk1) ); }
} // for i
+ bbSetOutputOut0( vOut0 );
+ bbSetOutputOut1( vOut1 );
+ bbSetOutputOut2( vOut2 );
+ bbSetOutputOut3( vOut3 );
+ bbSetOutputOut4( vOut4 );
+ bbSetOutputOut5( vOut5 );
+ bbSetOutputOut6( vOut6 );
+ bbSetOutputOut7( vOut7 );
+ bbSetOutputOut8( vOut8 );
+ bbSetOutputOut9( vOut9 );
+}
+
+void VectorFilterString::InvertLists()
+{
+ std::vector<std::string> vOut0;
+ std::vector<std::string> vOut1;
+ std::vector<std::string> vOut2;
+ std::vector<std::string> vOut3;
+ std::vector<std::string> vOut4;
+ std::vector<std::string> vOut5;
+ std::vector<std::string> vOut6;
+ std::vector<std::string> vOut7;
+ std::vector<std::string> vOut8;
+ std::vector<std::string> vOut9;
+ int i,size = bbGetInputIn0().size();
+ for (i=size-1; i>=0; i--)
+ {
+ if ( i < bbGetInputIn0().size() ) { vOut0.push_back( bbGetInputIn0()[i] ); }
+ if ( i < bbGetInputIn1().size() ) { vOut1.push_back( bbGetInputIn1()[i] ); }
+ if ( i < bbGetInputIn2().size() ) { vOut2.push_back( bbGetInputIn2()[i] ); }
+ if ( i < bbGetInputIn3().size() ) { vOut3.push_back( bbGetInputIn3()[i] ); }
+ if ( i < bbGetInputIn4().size() ) { vOut4.push_back( bbGetInputIn4()[i] ); }
+ if ( i < bbGetInputIn5().size() ) { vOut5.push_back( bbGetInputIn5()[i] ); }
+ if ( i < bbGetInputIn6().size() ) { vOut6.push_back( bbGetInputIn6()[i] ); }
+ if ( i < bbGetInputIn7().size() ) { vOut7.push_back( bbGetInputIn7()[i] ); }
+ if ( i < bbGetInputIn8().size() ) { vOut8.push_back( bbGetInputIn8()[i] ); }
+ if ( i < bbGetInputIn9().size() ) { vOut9.push_back( bbGetInputIn9()[i] ); }
+ } // for i
+ bbSetOutputOut0( vOut0 );
+ bbSetOutputOut1( vOut1 );
+ bbSetOutputOut2( vOut2 );
+ bbSetOutputOut3( vOut3 );
+ bbSetOutputOut4( vOut4 );
+ bbSetOutputOut5( vOut5 );
+ bbSetOutputOut6( vOut6 );
+ bbSetOutputOut7( vOut7 );
+ bbSetOutputOut8( vOut8 );
+ bbSetOutputOut9( vOut9 );
+}
+
+
+void VectorFilterString::SwitchElement(std::vector<std::string> *pVec, int i, int ii )
+{
+ std::string tmp;
+ if ( ( i < pVec->size() ) && ( ii < pVec->size() ) )
+ {
+ tmp = (*pVec)[i];
+ (*pVec)[i] = (*pVec)[ii];
+ (*pVec)[ii] = tmp;
+ } // if size
+}
+
+void VectorFilterString::OrderLists()
+{
+ std::vector<std::string> vOut0=bbGetInputIn0();
+ std::vector<std::string> vOut1=bbGetInputIn1();
+ std::vector<std::string> vOut2=bbGetInputIn2();
+ std::vector<std::string> vOut3=bbGetInputIn3();
+ std::vector<std::string> vOut4=bbGetInputIn4();
+ std::vector<std::string> vOut5=bbGetInputIn5();
+ std::vector<std::string> vOut6=bbGetInputIn6();
+ std::vector<std::string> vOut7=bbGetInputIn7();
+ std::vector<std::string> vOut8=bbGetInputIn8();
+ std::vector<std::string> vOut9=bbGetInputIn9();
+ int i,ii,size = bbGetInputIn0().size();
+ bool ok;
+ for (i=0; i<size; i++)
+ {
+ for (ii=i; ii<size; ii++)
+ {
+ ok=false;
+ if (bbGetInputType()==5)
+ {
+ if ( vOut0[i] > vOut0[ii] )
+ {
+ ok = true;
+ } // if vIn0[i] > vIn0[ii] // string version
+ } // if Type == 5
+ if (bbGetInputType()==6)
+ {
+// if ( std::stod( vOut0[i] ) > std::stod( vOut0[ii] ) )
+ if ( ::atof( vOut0[i].c_str() ) > ::atof( vOut0[ii].c_str() ) )
+ {
+ ok = true;
+ } // if vIn0[i] > vIn0[ii] double version
+ } // if Type == 6
+
+ if (ok==true)
+ {
+ SwitchElement( &vOut0 , i ,ii );
+ SwitchElement( &vOut1 , i ,ii );
+ SwitchElement( &vOut2 , i ,ii );
+ SwitchElement( &vOut3 , i ,ii );
+ SwitchElement( &vOut4 , i ,ii );
+ SwitchElement( &vOut5 , i ,ii );
+ SwitchElement( &vOut6 , i ,ii );
+ SwitchElement( &vOut7 , i ,ii );
+ SwitchElement( &vOut8 , i ,ii );
+ SwitchElement( &vOut9 , i ,ii );
+ } // if ok
+ } // for ii
+ } // for i
bbSetOutputOut0( vOut0 );
bbSetOutputOut1( vOut1 );
bbSetOutputOut2( vOut2 );
bbSetOutputOut7( vOut7 );
bbSetOutputOut8( vOut8 );
bbSetOutputOut9( vOut9 );
-printf("VectorFilterString::InsertStringPos End\n" );
}
+void VectorFilterString::SubString()
+{
+ std::vector<std::string> vOut0;
+ std::vector<std::string> vOut1;
+ std::vector<std::string> vOut2;
+ std::vector<std::string> vOut3;
+ std::vector<std::string> vOut4;
+ std::vector<std::string> vOut5;
+ std::vector<std::string> vOut6;
+ std::vector<std::string> vOut7;
+ std::vector<std::string> vOut8;
+ std::vector<std::string> vOut9;
+ int i,size = bbGetInputIn0().size();
+ int sk1 = atoi( bbGetInputsk1().c_str() );
+ int sk2 = atoi( bbGetInputsk2().c_str() );
+ for (i=0; i<size; i++)
+ {
+ if ( i < bbGetInputIn0().size() ) { vOut0.push_back( bbGetInputIn0()[i].substr(sk1,sk2) ); }
+ if ( i < bbGetInputIn1().size() ) { vOut1.push_back( bbGetInputIn1()[i].substr(sk1,sk2) ); }
+ if ( i < bbGetInputIn2().size() ) { vOut2.push_back( bbGetInputIn2()[i].substr(sk1,sk2) ); }
+ if ( i < bbGetInputIn3().size() ) { vOut3.push_back( bbGetInputIn3()[i].substr(sk1,sk2) ); }
+ if ( i < bbGetInputIn4().size() ) { vOut4.push_back( bbGetInputIn4()[i].substr(sk1,sk2) ); }
+ if ( i < bbGetInputIn5().size() ) { vOut5.push_back( bbGetInputIn5()[i].substr(sk1,sk2) ); }
+ if ( i < bbGetInputIn6().size() ) { vOut6.push_back( bbGetInputIn6()[i].substr(sk1,sk2) ); }
+ if ( i < bbGetInputIn7().size() ) { vOut7.push_back( bbGetInputIn7()[i].substr(sk1,sk2) ); }
+ if ( i < bbGetInputIn8().size() ) { vOut8.push_back( bbGetInputIn8()[i].substr(sk1,sk2) ); }
+ if ( i < bbGetInputIn9().size() ) { vOut9.push_back( bbGetInputIn9()[i].substr(sk1,sk2) ); }
+ } // for i
+ bbSetOutputOut0( vOut0 );
+ bbSetOutputOut1( vOut1 );
+ bbSetOutputOut2( vOut2 );
+ bbSetOutputOut3( vOut3 );
+ bbSetOutputOut4( vOut4 );
+ bbSetOutputOut5( vOut5 );
+ bbSetOutputOut6( vOut6 );
+ bbSetOutputOut7( vOut7 );
+ bbSetOutputOut8( vOut8 );
+ bbSetOutputOut9( vOut9 );
+}
-void VectorFilterString::Process()
+void VectorFilterString::EraseDuplicateLines()
{
+ std::vector< std::vector< std::string > * > pLstVec;
+ std::vector< std::vector< std::string > * > pLstVecOut;
+ std::vector< std::string > In0 = bbGetInputIn0();
+ std::vector< std::string > In1 = bbGetInputIn1();
+ std::vector< std::string > In2 = bbGetInputIn2();
+ std::vector< std::string > In3 = bbGetInputIn3();
+ std::vector< std::string > In4 = bbGetInputIn4();
+ std::vector< std::string > In5 = bbGetInputIn5();
+ std::vector< std::string > In6 = bbGetInputIn6();
+ std::vector< std::string > In7 = bbGetInputIn7();
+ std::vector< std::string > In8 = bbGetInputIn8();
+ std::vector< std::string > In9 = bbGetInputIn9();
+ if (bbGetInputIn0().size()!=0) { pLstVec.push_back( &In0 ); }
+ if (bbGetInputIn1().size()!=0) { pLstVec.push_back( &In1 ); }
+ if (bbGetInputIn2().size()!=0) { pLstVec.push_back( &In2 ); }
+ if (bbGetInputIn3().size()!=0) { pLstVec.push_back( &In3 ); }
+ if (bbGetInputIn4().size()!=0) { pLstVec.push_back( &In4 ); }
+ if (bbGetInputIn5().size()!=0) { pLstVec.push_back( &In5 ); }
+ if (bbGetInputIn6().size()!=0) { pLstVec.push_back( &In6 ); }
+ if (bbGetInputIn7().size()!=0) { pLstVec.push_back( &In7 ); }
+ if (bbGetInputIn8().size()!=0) { pLstVec.push_back( &In8 ); }
+ if (bbGetInputIn9().size()!=0) { pLstVec.push_back( &In9 ); }
+ std::vector< std::string > Out0;
+ std::vector< std::string > Out1;
+ std::vector< std::string > Out2;
+ std::vector< std::string > Out3;
+ std::vector< std::string > Out4;
+ std::vector< std::string > Out5;
+ std::vector< std::string > Out6;
+ std::vector< std::string > Out7;
+ std::vector< std::string > Out8;
+ std::vector< std::string > Out9;
+ pLstVecOut.push_back( &Out0 );
+ pLstVecOut.push_back( &Out1 );
+ pLstVecOut.push_back( &Out2 );
+ pLstVecOut.push_back( &Out3 );
+ pLstVecOut.push_back( &Out4 );
+ pLstVecOut.push_back( &Out5 );
+ pLstVecOut.push_back( &Out6 );
+ pLstVecOut.push_back( &Out7 );
+ pLstVecOut.push_back( &Out8 );
+ pLstVecOut.push_back( &Out9 );
+ std::string tmp1;
+ std::string tmp2;
+ if (bbGetInputIn0().size()!=0) // At least one element
+ {
+ bool okSizeVec=true;
+ int ipLstvec;
+ for (ipLstvec=1;ipLstvec<pLstVec.size();ipLstvec++)
+ {
+ if ( (*pLstVec[ipLstvec]).size()!=(*pLstVec[0]).size() ) { okSizeVec=false; }
+ }
+ if ( okSizeVec==false)
+ {
+ printf("EED VectorFilterString::Process WARNING! vectors are not of the same size.\n");
+ } else {
+ int iLine;
+ int ipLstvec2;
+ bool okLine;
+ int size = 0;
+ if (bbGetInputType()==8) { size = pLstVec.size(); }
+ if (bbGetInputType()==9) { size = 1; }
+ for (iLine=1 ; iLine < (*pLstVec[0]).size() ; iLine++ )
+ {
+ okLine=false;
+// for ( ipLstvec2=0 ; ipLstvec2<pLstVec.size() ; ipLstvec2++)
+// for ( ipLstvec2=0 ; ipLstvec2<1 ; ipLstvec2++)
+ for ( ipLstvec2=0 ; ipLstvec2<size ; ipLstvec2++)
+ {
+ tmp1=(*pLstVec[ipLstvec2])[iLine];
+ tmp2=(*pLstVec[ipLstvec2])[iLine-1];
+ if ( tmp1.compare(tmp2)!=0 ) { okLine=true; }
+ } // for ipLstVec2
+ if ( (okLine==true) || (iLine==1) )
+ {
+ for (ipLstvec2=0 ; ipLstvec2<pLstVec.size() ; ipLstvec2++)
+ {
+ (*pLstVecOut[ipLstvec2]).push_back( (*pLstVec[ipLstvec2])[iLine] );
+ } // for
+ } // if okLine
+ } // for iLine
+ } // if okSizeVec
+ } // bbGetInputIn0() size
+ bbSetOutputOut0( Out0 );
+ bbSetOutputOut1( Out1 );
+ bbSetOutputOut2( Out2 );
+ bbSetOutputOut3( Out3 );
+ bbSetOutputOut4( Out4 );
+ bbSetOutputOut5( Out5 );
+ bbSetOutputOut6( Out6 );
+ bbSetOutputOut7( Out7 );
+ bbSetOutputOut8( Out8 );
+ bbSetOutputOut9( Out9 );
+}
+
+
+void VectorFilterString::Process()
+{
// THE MAIN PROCESSING METHOD BODY
// Here we simply set the input 'In' value to the output 'Out'
// And print out the output value
if (bbGetInputType()==0)
{
- std::vector<std::string> vOut0;
- std::vector<std::string> vOut1;
- std::vector<std::string> vOut2;
- std::vector<std::string> vOut3;
- std::vector<std::string> vOut4;
- std::vector<std::string> vOut5;
- std::vector<std::string> vOut6;
- std::vector<std::string> vOut7;
- std::vector<std::string> vOut8;
- std::vector<std::string> vOut9;
- ConnectionRepetitions( bbGetInputIn0() , &vOut0 );
- ConnectionRepetitions( bbGetInputIn1() , &vOut1 );
- ConnectionRepetitions( bbGetInputIn2() , &vOut2 );
- ConnectionRepetitions( bbGetInputIn3() , &vOut3 );
- ConnectionRepetitions( bbGetInputIn4() , &vOut4 );
- ConnectionRepetitions( bbGetInputIn5() , &vOut5 );
- ConnectionRepetitions( bbGetInputIn6() , &vOut6 );
- ConnectionRepetitions( bbGetInputIn7() , &vOut7 );
- ConnectionRepetitions( bbGetInputIn8() , &vOut8 );
- ConnectionRepetitions( bbGetInputIn9() , &vOut9 );
- bbSetOutputOut0( vOut0 );
- bbSetOutputOut1( vOut1 );
- bbSetOutputOut2( vOut2 );
- bbSetOutputOut3( vOut3 );
- bbSetOutputOut4( vOut4 );
- bbSetOutputOut5( vOut5 );
- bbSetOutputOut6( vOut6 );
- bbSetOutputOut7( vOut7 );
- bbSetOutputOut8( vOut8 );
- bbSetOutputOut9( vOut9 );
+ CountConnectedRepetitions();
}
if (bbGetInputType()==2)
{
InsertStringPos();
}
+
+ if (bbGetInputType()==4)
+ {
+ InvertLists();
+ }
+
+ if ( (bbGetInputType()==5) || (bbGetInputType()==6) )
+ {
+ OrderLists();
+ }
+
+ if (bbGetInputType()==7)
+ {
+ SubString();
+ }
+ if ( (bbGetInputType()==8) || (bbGetInputType()==9) )
+ {
+ EraseDuplicateLines();
+ }
}
//=====
// 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)