00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef TEUCHOS_TABLEFORMAT_H
00030 #define TEUCHOS_TABLEFORMAT_H
00031
00036 #include "Teuchos_ConfigDefs.hpp"
00037 #include "Teuchos_TableColumn.hpp"
00038 #include <iostream>
00039
00040 namespace Teuchos
00041 {
00052 class TableFormat
00053 {
00054 public:
00056 TableFormat()
00057 : pageWidth_(80), precision_(4), columnSpacing_(4),
00058 maxNameSize_(40), columnWidths_(), lineInterval_(10)
00059 {}
00060
00063 int pageWidth() const {return pageWidth_;}
00064
00067 int precision() const {return precision_;}
00068
00071 int columnSpacing() const {return columnSpacing_;}
00072
00076 void setPageWidth(int pw) const {pageWidth_ = pw;}
00077
00079 void setPrecision(int p) {precision_ = p;}
00080
00082 void setColumnSpacing(int columnSpacing) {columnSpacing_ = columnSpacing;}
00083
00089 void setRowsBetweenLines(int lineInterval) {lineInterval_=lineInterval;}
00090
00097 string thinline() const ;
00098
00101 string thickline() const ;
00102
00104 string blanks(int size) const ;
00105
00113 int computeRequiredColumnWidth(const string& name,
00114 const TableColumn& column) const ;
00115
00117 void setColumnWidths(const Array<int>& colWidths)
00118 {columnWidths_ = colWidths;}
00119
00126 void writeRow(RefCountPtr<std::ostream>& out,
00127 const Array<RefCountPtr<TableEntry> >& entries) const ;
00128
00136 void writeRow(RefCountPtr<std::ostream>& out,
00137 int rowIndex,
00138 const Array<TableColumn>& columns) const ;
00139
00141 void writeWholeTable(RefCountPtr<std::ostream>& out,
00142 const string& tableTitle,
00143 const Array<string>& columnNames,
00144 const Array<TableColumn>& columns) const ;
00145
00146
00147 protected:
00148 int defaultColumnWidth() const {return 20;}
00149
00150 private:
00151 mutable int pageWidth_;
00152 int precision_;
00153 int columnSpacing_;
00154 int maxNameSize_;
00155 Array<int> columnWidths_;
00156 int lineInterval_;
00157 };
00158
00159
00160
00161 }
00162 #endif