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 {
00042
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 std::string thinline() const ;
00098
00101 std::string thickline() const ;
00102
00104 std::string blanks(int size) const ;
00105
00114 int computeRequiredColumnWidth(const std::string& name,
00115 const TableColumn& column) const ;
00116
00118 void setColumnWidths(const Array<int>& colWidths)
00119 {columnWidths_ = colWidths;}
00120
00127 void writeRow(
00128 std::ostream& out,
00129 const Array<RCP<TableEntry> >& entries
00130 ) const;
00131
00139 void writeRow(
00140 std::ostream& out,
00141 int rowIndex,
00142 const Array<TableColumn>& columns
00143 ) const;
00144
00146 void writeWholeTable(
00147 std::ostream& out,
00148 const std::string& tableTitle,
00149 const Array<std::string>& columnNames,
00150 const Array<TableColumn>& columns
00151 ) const ;
00152
00153 protected:
00154
00155 int defaultColumnWidth() const {return 20;}
00156
00157 private:
00158
00159 mutable int pageWidth_;
00160 int precision_;
00161 int columnSpacing_;
00162 int maxNameSize_;
00163 Array<int> columnWidths_;
00164 int lineInterval_;
00165 };
00166
00167
00168 }
00169
00170
00171 #endif