2 // 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)
4 #include "bbstdWriteColumnsString.h"
5 #include "bbstdPackage.h"
9 BBTK_ADD_BLACK_BOX_TO_PACKAGE(std,WriteColumnsString)
10 BBTK_BLACK_BOX_IMPLEMENTATION(WriteColumnsString,bbtk::AtomicBlackBox);
12 // 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)
14 void WriteColumnsString::Process()
16 std::ofstream write_fi;
17 write_fi.open(bbGetInputFileName().c_str());
18 std::vector<std::string> headers = bbGetInputHeaders(); //Headers Input
19 bool onHeaders = bbGetInputOnHeaders();
20 std::vector<std::vector<std::string> > values;
21 values.push_back( bbGetInputlstData1() );
22 values.push_back( bbGetInputlstData2() );
23 values.push_back( bbGetInputlstData3() );
24 values.push_back( bbGetInputlstData4() );
25 values.push_back( bbGetInputlstData5() );
26 values.push_back( bbGetInputlstData6() );
27 values.push_back( bbGetInputlstData7() );
28 values.push_back( bbGetInputlstData8() );
29 values.push_back( bbGetInputlstData9() );
30 std::vector<std::vector<std::string> >::iterator it;
34 for(it = values.begin() ; it != values.end() ; )
38 it = values.erase(it);
47 int i,size = values.size();
48 for ( i=0 ; i<size-1 ; i++ )
50 if ( values[i].size() != values[i+1].size() )
59 if(write_fi.is_open())
61 if(onHeaders == true) // If onHeaders is true, the file is write with Headers.
63 //Add each header input write to file
64 for(unsigned int i=0 ;i< headers.size(); i++ )
66 if(i==(headers.size()-1))
68 write_fi << headers[i] << "\n";
70 write_fi << headers[i] << "\t";
74 unsigned int colSize = values[0].size();
75 for(unsigned int j=0 ; j<colSize ; j++)
77 for(unsigned int i=0;i<values.size();i++)
79 if(i==(values.size()-1))
81 write_fi << values[i][j] << "\n";
83 write_fi << values[i][j] << "\t";
87 } else { // if write_fi.is_open()
88 std::cout<<"EED WriteColumnsString::Process Imposible to open file."<<std::endl;
92 printf("EED WriteColumnsString::Process Warning! The size of the vectors are not equal. \n");
96 bbSetOutputOutFileName(bbGetInputFileName().c_str());
101 // 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)
103 void WriteColumnsString::bbUserSetDefaultValues()
106 // SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX
107 // Here we initialize the input 'In' to 0
108 bbSetInputFileName("");
109 bbSetInputFileName("true");
112 // 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)
114 void WriteColumnsString::bbUserInitializeProcessing()
117 // THE INITIALIZATION METHOD BODY :
119 // but this is where you should allocate the internal/output pointers
123 // 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)
125 void WriteColumnsString::bbUserFinalizeProcessing()
128 // THE FINALIZATION METHOD BODY :
130 // but this is where you should desallocate the internal/output pointers
135 // EO namespace bbstd