|
Teuchos Package Browser (Single Doxygen Collection) Version of the Day
|
00001 // @HEADER 00002 // *********************************************************************** 00003 // 00004 // Teuchos: Common Tools Package 00005 // Copyright (2004) Sandia Corporation 00006 // 00007 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive 00008 // license for use of this work by or on behalf of the U.S. Government. 00009 // 00010 // This library is free software; you can redistribute it and/or modify 00011 // it under the terms of the GNU Lesser General Public License as 00012 // published by the Free Software Foundation; either version 2.1 of the 00013 // License, or (at your option) any later version. 00014 // 00015 // This library is distributed in the hope that it will be useful, but 00016 // WITHOUT ANY WARRANTY; without even the implied warranty of 00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00018 // Lesser General Public License for more details. 00019 // 00020 // You should have received a copy of the GNU Lesser General Public 00021 // License along with this library; if not, write to the Free Software 00022 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 00023 // USA 00024 // Questions? Contact Michael A. Heroux (maherou@sandia.gov) 00025 // 00026 // *********************************************************************** 00027 // @HEADER 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_in) {columnSpacing_ = columnSpacing_in;} 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 } // namespace Teuchos 00169 00170 00171 #endif
1.7.4