Teuchos - Trilinos Tools Package Version of the Day
Teuchos_TableEntry.cpp
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 #include "Teuchos_TableEntry.hpp"
00030 
00031 using namespace Teuchos;
00032 
00033 
00034 /* --------- base class methods ---------------------------------------------- */
00035 
00036 std::string TableEntry::toChoppedString(int maxWidth) const
00037 {
00038   return toString().substr(0, maxWidth);
00039 }
00040 
00041 
00042 
00043 /* --------- DoubleEntry methods -------------------------------------------- */
00044 
00045 DoubleEntry::DoubleEntry(const double& value, int precision)
00046   : TableEntry(), data_(value), precision_(precision)
00047 {}
00048 
00049 std::string DoubleEntry::toString() const 
00050 {
00051   std::ostringstream toss;
00052   toss << std::setprecision(precision_) << data_;
00053   return toss.str();
00054 }
00055 
00056 
00057 
00058 /* --------- IntEntry methods -------------------------------------------- */
00059 
00060 IntEntry::IntEntry(int value)
00061   : TableEntry(), data_(value)
00062 {}
00063 
00064 std::string IntEntry::toString() const 
00065 {
00066   std::ostringstream toss;
00067   toss << data_;
00068   return toss.str();
00069 }
00070 
00071 
00072 
00073 /* --------- StringEntry methods -------------------------------------------- */
00074 
00075 StringEntry::StringEntry(std::string value)
00076   : TableEntry(), data_(value)
00077 {}
00078 
00079 std::string StringEntry::toString() const 
00080 {
00081   return data_;
00082 }
00083 
00084 
00085 
00086 
00087 
00088 /* --------- CompoundEntryWithParentheses methods ------------------------- */
00089 
00090 CompoundEntryWithParentheses
00091 ::CompoundEntryWithParentheses(const RCP<TableEntry>& first,
00092                                 const RCP<TableEntry>& second,
00093                                 bool spaceBeforeParens)
00094   : TableEntry(), 
00095     first_(first), 
00096     second_(second), 
00097     spaceBeforeParens_(spaceBeforeParens)
00098 {}
00099 
00100 std::string CompoundEntryWithParentheses::toString() const 
00101 {
00102   std::ostringstream toss;
00103   
00104   toss << first_->toString();
00105   if (spaceBeforeParens_) toss << " ";
00106   toss << "(" << second_->toString() << ")";
00107   
00108   return toss.str();
00109 }
00110 
00111 
00112 
00113 
00114 
00115 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines