]> Creatis software - bbtk.git/blob - packages/std/src/bbstdWriteColumnsString.cxx
#2975 BBTK Bug New Normal - Clean comments
[bbtk.git] / packages / std / src / bbstdWriteColumnsString.cxx
1 //===== 
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)
3 //===== 
4 #include "bbstdWriteColumnsString.h"
5 #include "bbstdPackage.h"
6 namespace bbstd
7 {
8
9 BBTK_ADD_BLACK_BOX_TO_PACKAGE(std,WriteColumnsString)
10 BBTK_BLACK_BOX_IMPLEMENTATION(WriteColumnsString,bbtk::AtomicBlackBox);
11 //===== 
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)
13 //===== 
14 void WriteColumnsString::Process()
15 {
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;
31         for(it = values.begin() ; it != values.end() ; )
32         {
33                 if((*it).empty())
34                 {
35                         it = values.erase(it);
36                 }else
37                 {
38                         it++;
39                 }
40         }
41         if(write_fi.is_open())
42         {       
43                 if(onHeaders == true) // If onHeaders is true, the file is write with Headers.
44                 {
45                         //Add each header input write to file
46                         for(unsigned int i=0 ;i< headers.size(); i++ )
47                         {
48                                 if(i==(headers.size()-1))
49                                 {
50                                         write_fi << headers[i] << "\n";
51                                 }else{
52                                         write_fi << headers[i] << "\t";
53                                 }
54
55                         }//for headersSize
56                 }
57                 unsigned int colSize = values[0].size();
58                 for(unsigned int j=0;j<colSize;j++)
59                 {
60                         for(unsigned int i=0;i<values.size();i++)
61                         {
62                                 if(i==(values.size()-1))
63                                 {
64                                         write_fi << values[i][j] << "\n";
65                                 }else{
66                                         write_fi << values[i][j] << "\t";
67                                 }
68                         }
69                 }
70         }// if write_fi.is_open()
71         else
72         {
73                 std::cout<<"No es posible abrir"<<std::endl;
74         }//else
75         write_fi.close();
76         bbSetOutputOutFileName(bbGetInputFileName().c_str());  
77 }
78 //===== 
79 // 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)
80 //===== 
81 void WriteColumnsString::bbUserSetDefaultValues()
82 {
83
84 //  SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX 
85 //    Here we initialize the input 'In' to 0
86    bbSetInputFileName("");      
87    bbSetInputFileName("true");
88   
89 }
90 //===== 
91 // 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)
92 //===== 
93 void WriteColumnsString::bbUserInitializeProcessing()
94 {
95
96 //  THE INITIALIZATION METHOD BODY :
97 //    Here does nothing 
98 //    but this is where you should allocate the internal/output pointers 
99 //    if any 
100
101   
102 }
103 //===== 
104 // 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)
105 //===== 
106 void WriteColumnsString::bbUserFinalizeProcessing()
107 {
108
109 //  THE FINALIZATION METHOD BODY :
110 //    Here does nothing 
111 //    but this is where you should desallocate the internal/output pointers 
112 //    if any
113   
114 }
115 }
116 // EO namespace bbstd
117
118