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.hh

Go to the documentation of this file.
00001 // $Id: Format.hh 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 #ifndef HH_SENF_senf_Utils_Format_
00027 #define HH_SENF_senf_Utils_Format_ 1
00028 
00029 // Custom includes
00030 #include <limits>
00031 #include <iostream>
00032 #include <boost/utility/enable_if.hpp>
00033 #include <boost/type_traits/is_signed.hpp>
00034 #include <boost/type_traits/is_unsigned.hpp>
00035 
00036 //#include "Format.mpp"
00037 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00038 
00039 namespace senf {
00040 namespace format {
00041 
00045 #ifdef DOXYGEN
00046 
00123     streamable_type eng(float v, float d=NAN);
00124 
00125 #else
00126 
00127     class eng
00128     {
00129     public:
00130         eng(float v, float d = std::numeric_limits<float>::quiet_NaN());
00131 
00132         eng const & setw(unsigned w = 1) const;
00133         eng const & setprecision(unsigned p) const;
00134         eng const & setfill(char c) const;
00135 
00136         eng const & showbase() const;
00137         eng const & noshowbase() const;
00138         eng const & showpos() const;
00139         eng const & noshowpos() const;
00140         eng const & showpoint() const;
00141         eng const & noshowpoint() const;
00142         eng const & uppercase() const;
00143         eng const & nouppercase() const;
00144         eng const & left() const;
00145         eng const & internal() const;
00146         eng const & right() const;
00147 
00148     private:
00149         float v_;
00150         float d_;
00151 
00152         mutable bool haveWidth_;
00153         mutable unsigned width_;
00154         mutable bool havePrecision_;
00155         mutable unsigned precision_;
00156         mutable bool haveFill_;
00157         mutable char fill_;
00158         mutable std::ios_base::fmtflags mask_;
00159         mutable std::ios_base::fmtflags flags_;
00160 
00161         friend std::ostream & operator<<(std::ostream & os, eng const & v);
00162 
00163     };
00164 
00165     std::ostream & operator<<(std::ostream & os, eng const & v);
00166 
00167 #endif
00168 
00169 #ifdef DOXYGEN
00170 
00184     template <class T>
00185     streamable_type dumpint(T const & v);
00186 
00187 #else
00188 
00189     template <class T>
00190     std::string dumpint(T const & v,
00191                         typename boost::enable_if<boost::is_signed<T> >::type * = 0);
00192 
00193     template <class T>
00194     std::string dumpint(T const & v,
00195                         typename boost::enable_if<boost::is_unsigned<T> >::type * = 0);
00196 
00197     template <class T>
00198     std::string dumpint(T const & v,
00199                         typename boost::enable_if<boost::is_signed<typename T::value_type> >::type * = 0);
00200 
00201     template <class T>
00202     std::string dumpint(T const & v,
00203                         typename boost::enable_if<boost::is_unsigned<typename T::value_type> >::type * = 0);
00204 
00205 #endif
00206 
00237     class IndentHelper
00238     {
00239         static unsigned int static_level;
00240         unsigned int instance_level;
00241     public:
00242 
00243         IndentHelper();                 
00244 
00245         ~IndentHelper();                
00246 
00248         void increase();                
00249 
00250         unsigned int level() const;     
00251     };
00252 
00256     std::ostream & operator<<(std::ostream & os, IndentHelper const & indent);
00257 
00258 }}
00259 
00260 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00261 #include "Format.cci"
00262 //#include "Format.ct"
00263 #include "Format.cti"
00264 #endif
00265 
00266 
00267 // Local Variables:
00268 // mode: c++
00269 // fill-column: 100
00270 // comment-column: 40
00271 // c-file-style: "senf"
00272 // indent-tabs-mode: nil
00273 // ispell-local-dictionary: "american"
00274 // compile-command: "scons -u test"
00275 // End:

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