Teuchos_TableFormat.hpp

Go to the documentation of this file.
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 {
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

Generated on Thu Sep 18 12:30:31 2008 for Teuchos - Trilinos Tools Package by doxygen 1.3.9.1