#include #include #include #include "d_html.h" #include "useful.h" using namespace std; // ---------------------------------------------------------------- d_html::d_html() { //this->w = 0; //this->h = 0; this->border = 1; this->show_head = true; //this->data.clear(); //this->col_w.clear(); //this->show_col_name = false; } // ---------------------------------------------------------------- d_html::d_html( int a, int b ) { //this->show_col_name = false; this->border = 1; this->show_head = true; //this->show_col_name = false; this->resize( a, b ); } // ---------------------------------------------------------------- void d_html::resize( int a, int b ) { //this->w = a; //this->h = b; //this->border = 1; this->head.resize( a ); this->data.resize( (a * b ) ); this->col_w.resize( a ); // column width //this->data[0] = int2str(a); //this->col_name.resize( a ); // column name } // ---------------------------------------------------------------- void d_html::set( int a, int b, string mm ) { a--; this->data[ 1 + (this->head.size() * (b-1)) + (a-1) ] = mm; } void d_html::set( int a, int b, char & mm ) { a--; this->data[ 1 + (this->head.size() * (b-1)) + (a-1) ] = mm; } // ---------------------------------------------------------------- ostream &operator<<( ostream &out, const d_html &L ) { int i, j; // empty? //if( L.data.size() == 0 ) //{ // //out << "-table empty-"; // out << "" << endl // << " " << endl // << " " << endl // << " " << endl // << "
empty table

" << endl; // // return( out ); //} // table header + border, if any out << " 0 ) out << " width=\"" << L.width << "\""; if( L.height.length() > 0 ) out << " height=\"" << L.height << "\""; out << ">\n"; if( L.title.length() > 0 ) out << " \n"; // new row if( L.show_head == true ) { cout << " \n"; for( i = 0; i < L.head.size(); i++ ) { out << " i ) { out << " width=\"" << L.col_w[i] << "\""; } if( L.head_cell_style.size() > 0 ) out << " " << L.head_cell_style; out << ">"; if( L.head_style1.size() > 0 ) out << L.head_style1; out << L.head[i]; if( L.head_style2.size() > 0 ) out << L.head_style2; out << "\n"; } cout << " \n"; } if( L.data.size() > 0 ) { for( j = 0; j < (L.data.size() / L.head.size()); j++ ) { out << " \n"; // new cells for( i = 0; i < L.head.size(); i++ ) { out << " 0 ) out << " " << L.data_cell_style; out << ">"; if( L.data[(L.head.size() * j) + i].length() > 0 ) { if( L.head_style1.size() > 0 ) out << L.data_style1; out << L.data[ (L.head.size() * j) + i]; if( L.head_style1.size() > 0 ) out << L.data_style1; } else { if( L.data_style2.size() > 0 ) out << L.data_style2; out << " "; if( L.data_style2.size() > 0 ) out << L.data_style2; } //out << " "; out << "\n"; } out << " \n"; } } out << "
" << L.title << "
\n"; return( out ); } // ----------------------------------------------------------------