Search:

SENF Extensible Network Framework

  • Home
  • Download
  • Wiki
  • BerliOS
  • ChangeLog
  • Browse SVN
  • Bug Tracker
  • Overview
  • Examples
  • HowTos
  • Glossary
  • PPI
  • Packets
  • Scheduler
  • Socket
  • Utils
  • Console
  • Daemon
  • Logger
  • Termlib
  • Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

Format.cci

Go to the documentation of this file.
00001 // $Id: Format.cci 1742 2010-11-04 14:51:56Z g0dil $
00002 //
00003 // Copyright (C) 2009
00004 // Fraunhofer (FOKUS)
00005 // Competence Center NETwork research (NET), St. Augustin, GERMANY
00006 //     Stefan Bund <g0dil@berlios.de>
00007 //
00008 // This program is free software; you can redistribute it and/or modify
00009 // it under the terms of the GNU General Public License as published by
00010 // the Free Software Foundation; either version 2 of the License, or
00011 // (at your option) any later version.
00012 //
00013 // This program is distributed in the hope that it will be useful,
00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016 // GNU General Public License for more details.
00017 //
00018 // You should have received a copy of the GNU General Public License
00019 // along with this program; if not, write to the
00020 // Free Software Foundation, Inc.,
00021 // 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00022 
00026 #include "Format.ih"
00027 
00028 // Custom includes
00029 
00030 #define prefix_ inline
00031 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00032 
00033 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00034 // senf::format::eng
00035 
00036 prefix_ senf::format::eng::eng(float v, float d)
00037     : v_ (v), d_ (d), haveWidth_ (false), width_ (0), havePrecision_ (false), precision_ (0),
00038       haveFill_ (false), fill_ (' '), mask_ (), flags_ ()
00039 {}
00040 
00041 prefix_ senf::format::eng const & senf::format::eng::setw(unsigned w)
00042     const
00043 {
00044     haveWidth_ = true;
00045     width_ = w;
00046     return *this;
00047 }
00048 
00049 prefix_ senf::format::eng const & senf::format::eng::setprecision(unsigned p)
00050     const
00051 {
00052     havePrecision_ = true;
00053     precision_ = p;
00054     return *this;
00055 }
00056 
00057 prefix_ senf::format::eng const & senf::format::eng::setfill(char c)
00058     const
00059 {
00060     haveFill_ = true;
00061     fill_ = c;
00062     return *this;
00063 }
00064 
00065 prefix_ senf::format::eng const & senf::format::eng::showbase()
00066     const
00067 {
00068     mask_ |= std::ios_base::showbase;
00069     flags_ |= std::ios_base::showbase;
00070     return *this;
00071 }
00072 
00073 prefix_ senf::format::eng const & senf::format::eng::noshowbase()
00074     const
00075 {
00076     mask_ |= std::ios_base::showbase;
00077     flags_ &= ~std::ios_base::showbase;
00078     return *this;
00079 }
00080 
00081 prefix_ senf::format::eng const & senf::format::eng::showpos()
00082     const
00083 {
00084     mask_ |= std::ios_base::showpos;
00085     flags_ |= std::ios_base::showpos;
00086     return *this;
00087 }
00088 
00089 prefix_ senf::format::eng const & senf::format::eng::noshowpos()
00090     const
00091 {
00092     mask_ |= std::ios_base::showpos;
00093     flags_ &= ~std::ios_base::showpos;
00094     return *this;
00095 }
00096 
00097 prefix_ senf::format::eng const & senf::format::eng::showpoint()
00098     const
00099 {
00100     mask_ |= std::ios_base::showpoint;
00101     flags_ |= std::ios_base::showpoint;
00102     return *this;
00103 }
00104 
00105 prefix_ senf::format::eng const & senf::format::eng::noshowpoint()
00106     const
00107 {
00108     mask_ |= std::ios_base::showpoint;
00109     flags_ &= ~std::ios_base::showpoint;
00110     return *this;
00111 }
00112 
00113 prefix_ senf::format::eng const & senf::format::eng::uppercase()
00114     const
00115 {
00116     mask_ |= std::ios_base::uppercase;
00117     flags_ |= std::ios_base::uppercase;
00118     return *this;
00119 }
00120 
00121 prefix_ senf::format::eng const & senf::format::eng::nouppercase()
00122     const
00123 {
00124     mask_ |= std::ios_base::uppercase;
00125     flags_ &= ~std::ios_base::uppercase;
00126     return *this;
00127 }
00128 
00129 prefix_ senf::format::eng const & senf::format::eng::left()
00130     const
00131 {
00132     mask_ |= std::ios_base::adjustfield;
00133     flags_ &= ~std::ios_base::adjustfield;
00134     flags_ |= std::ios_base::left;
00135     return *this;
00136 }
00137 
00138 prefix_ senf::format::eng const & senf::format::eng::internal()
00139     const
00140 {
00141     mask_ |= std::ios_base::adjustfield;
00142     flags_ &= ~std::ios_base::adjustfield;
00143     flags_ |= std::ios_base::internal;
00144     return *this;
00145 }
00146 
00147 prefix_ senf::format::eng const & senf::format::eng::right()
00148     const
00149 {
00150     mask_ |= std::ios_base::adjustfield;
00151     flags_ &= ~std::ios_base::adjustfield;
00152     flags_ |= std::ios_base::right;
00153     return *this;
00154 }
00155 
00156 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00157 // senf::format::IndentHelper
00158 
00159 prefix_ senf::format::IndentHelper::IndentHelper()
00160     : instance_level(1)
00161 {
00162     ++static_level;
00163 }
00164 
00165 prefix_ senf::format::IndentHelper::~IndentHelper()
00166 {
00167     static_level -= instance_level;
00168 }
00169 
00170 prefix_ void senf::format::IndentHelper::increase()
00171 {
00172     ++static_level;
00173     ++instance_level;
00174 }
00175 
00176 prefix_ unsigned int senf::format::IndentHelper::level()
00177     const
00178 {
00179     return static_level;
00180 }
00181 
00182 prefix_ std::ostream & senf::format::operator<<(std::ostream & os, senf::format::IndentHelper const & indent)
00183 {
00184     for (unsigned int i=0, j=indent.level(); i<j; ++i)
00185         os << "  ";
00186     return os;
00187 }
00188 
00189 
00190 
00191 
00192 
00193 
00194 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00195 #undef prefix_
00196 
00197 
00198 // Local Variables:
00199 // mode: c++
00200 // fill-column: 100
00201 // comment-column: 40
00202 // c-file-style: "senf"
00203 // indent-tabs-mode: nil
00204 // ispell-local-dictionary: "american"
00205 // compile-command: "scons -u test"
00206 // End:

Contact: senf-dev@lists.berlios.de | © 2006-2010 Fraunhofer Institute for Open Communication Systems, Network Research