Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

more/io/iomanip.h

Go to the documentation of this file.
00001 //  Copyright (C) 2000--2002  Petter Urkedal (petter.urkedal@matfys.lth.se)
00002 //
00003 //  This file is free software; you can redistribute it and/or modify
00004 //  it under the terms of the GNU General Public License as published by
00005 //  the Free Software Foundation; either version 2 of the License, or
00006 //  (at your option) any later version.
00007 //
00008 //  This file is distributed in the hope that it will be useful,
00009 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00011 //  GNU General Public License for more details.
00012 //
00013 //  You should have received a copy of the GNU General Public License
00014 //  along with this program; if not, write to the Free Software
00015 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00016 //
00017 //  As a special exception, you may use this file as part of a free
00018 //  software library without restriction.  Specifically, if other files
00019 //  instantiate templates or use macros or inline functions from this
00020 //  file, or you compile this file and link it with other files to
00021 //  produce an executable, this file does not by itself cause the
00022 //  resulting executable to be covered by the GNU General Public
00023 //  License.  This exception does not however invalidate any other
00024 //  reasons why the executable file might be covered by the GNU General
00025 //  Public License.
00026 //
00027 //  $Id: iomanip.h,v 1.1 2002/05/30 18:01:37 petter_urkedal Exp $
00028 
00029 
00030 //  Not very much here, but setwp saves tons of code when doing lots
00031 //  of real number formatting.  Usually, we don't set the precision
00032 //  without setting the width, as well.
00033 
00034 
00035 #ifndef MORE_IOMANIP_H
00036 #define MORE_IOMANIP_H
00037 
00038 
00039 #include <string>
00040 #include <iomanip>
00041 
00042 
00043 namespace more {
00044 namespace io {
00045 
00046   /** A combinde \c std::setw and \c std::setprecision manipulator. */
00047   struct setwp
00048   {
00049       setwp(int w, int p) : width(w), precision(p) {}
00050       friend std::ostream& operator<<(std::ostream& os, setwp const& x);
00051     private:
00052       int width, precision;
00053   };
00054 
00055   struct osfill
00056   {
00057       osfill(int w, char c = ' ') : width(w), ch(c) {}
00058       friend std::ostream& operator<<(std::ostream& os, osfill const& x);
00059     private:
00060       int width;
00061       char ch;
00062   };
00063 
00064   struct oscenter
00065   {
00066       oscenter(std::string s, int w, char c = ' ')
00067           : str(s), width(w), ch(c) {}
00068       friend std::ostream& operator<<(std::ostream& os, oscenter const& x);
00069     private:
00070       std::string str;
00071       int width;
00072       char ch;
00073   };
00074 
00075   /** Typesetting languages for output streams. */
00076   enum tslang_t
00077   {
00078       tslang_none,
00079       tslang_terminfo,
00080       tslang_latex_text, // unused
00081       tslang_latex_math,
00082       tslang_html,
00083   };
00084 
00085   void set_tslang(std::ios_base&, tslang_t);
00086   tslang_t tslang(std::ios_base&);
00087 
00088   bool has_bold(std::ios_base&);
00089   bool has_underline(std::ios_base&);
00090   bool has_italic(std::ios_base&);
00091   bool has_stadout(std::ios_base&);
00092   bool has_scripts(std::ios_base&);
00093   bool has_rec_scripts(std::ios_base);
00094 
00095   /** If possible set bold face style on \c os. */
00096   template<typename Char, typename Traits>
00097     std::basic_ostream<Char, Traits>&
00098     set_bold(std::basic_ostream<Char, Traits>& os);
00099 
00100   /** Clear bold face style on \c os if set. */
00101   template<typename Char, typename Traits>
00102     std::basic_ostream<Char, Traits>&
00103     clr_bold(std::basic_ostream<Char, Traits>& os);
00104 
00105   /** If possible set underline style on \c os. */
00106   template<typename Char, typename Traits>
00107     std::basic_ostream<Char, Traits>&
00108     set_underline(std::basic_ostream<Char, Traits>& os);
00109 
00110   /** Clear underline style on \c os if set. */
00111   template<typename Char, typename Traits>
00112     std::basic_ostream<Char, Traits>&
00113     clr_underline(std::basic_ostream<Char, Traits>& os);
00114 
00115   /** If possible set italic style on \c os. */
00116   template<typename Char, typename Traits>
00117     std::basic_ostream<Char, Traits>&
00118     set_italic(std::basic_ostream<Char, Traits>& os);
00119 
00120   /** Clear italic style on \c os if set. */
00121   template<typename Char, typename Traits>
00122     std::basic_ostream<Char, Traits>&
00123     clr_italic(std::basic_ostream<Char, Traits>& os);
00124 
00125   /** If possible set standout style on \c os. */
00126   template<typename Char, typename Traits>
00127     std::basic_ostream<Char, Traits>&
00128     set_standout(std::basic_ostream<Char, Traits>& os);
00129 
00130   /** Clear standout style on \c os if set. */
00131   template<typename Char, typename Traits>
00132     std::basic_ostream<Char, Traits>&
00133     clr_standout(std::basic_ostream<Char, Traits>& os);
00134 
00135   /** Begin superscript mode if possible. */
00136   template<typename Char, typename Traits>
00137     std::basic_ostream<Char, Traits>&
00138     beg_super(std::basic_ostream<Char, Traits>& os);
00139 
00140   /** End superscript mode. */
00141   template<typename Char, typename Traits>
00142     std::basic_ostream<Char, Traits>&
00143     end_super(std::basic_ostream<Char, Traits>& os);
00144 
00145   /** Begin subscript mode if possible. */
00146   template<typename Char, typename Traits>
00147     std::basic_ostream<Char, Traits>&
00148     beg_sub(std::basic_ostream<Char, Traits>& os);
00149 
00150   /** End subscript mode. */
00151   template<typename Char, typename Traits>
00152     std::basic_ostream<Char, Traits>&
00153     end_sub(std::basic_ostream<Char, Traits>& os);
00154 
00155 
00156 }}
00157 
00158 #endif

Generated on Sat Sep 7 19:11:16 2002 for more with Doxygen 1.2.13.1. Doxygen 1.2.13.1 is written and copyright 1997-2002 by Dimitri van Heesch.