LTP GCOV extension - code coverage report
Current view: directory - usr/include/c++/4.3 - iomanip
Test: lcov.info
Date: 2008-08-14 Instrumented lines: 10
Code covered: 40.0 % Executed lines: 4

       1                 : // Standard stream manipulators -*- C++ -*-
       2                 : 
       3                 : // Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
       4                 : // 2006, 2007
       5                 : // Free Software Foundation, Inc.
       6                 : //
       7                 : // This file is part of the GNU ISO C++ Library.  This library is free
       8                 : // software; you can redistribute it and/or modify it under the
       9                 : // terms of the GNU General Public License as published by the
      10                 : // Free Software Foundation; either version 2, or (at your option)
      11                 : // any later version.
      12                 : 
      13                 : // This library is distributed in the hope that it will be useful,
      14                 : // but WITHOUT ANY WARRANTY; without even the implied warranty of
      15                 : // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      16                 : // GNU General Public License for more details.
      17                 : 
      18                 : // You should have received a copy of the GNU General Public License
      19                 : // along with this library; see the file COPYING.  If not, write to
      20                 : // the Free Software Foundation, 51 Franklin Street, Fifth Floor,
      21                 : // Boston, MA 02110-1301, USA.
      22                 : 
      23                 : // As a special exception, you may use this file as part of a free software
      24                 : // library without restriction.  Specifically, if other files instantiate
      25                 : // templates or use macros or inline functions from this file, or you compile
      26                 : // this file and link it with other files to produce an executable, this
      27                 : // file does not by itself cause the resulting executable to be covered by
      28                 : // the GNU General Public License.  This exception does not however
      29                 : // invalidate any other reasons why the executable file might be covered by
      30                 : // the GNU General Public License.
      31                 : 
      32                 : /** @file iomanip
      33                 :  *  This is a Standard C++ Library header.
      34                 :  */
      35                 : 
      36                 : //
      37                 : // ISO C++ 14882: 27.6.3  Standard manipulators
      38                 : //
      39                 : 
      40                 : #ifndef _GLIBCXX_IOMANIP
      41                 : #define _GLIBCXX_IOMANIP 1
      42                 : 
      43                 : #pragma GCC system_header
      44                 : 
      45                 : #include <bits/c++config.h>
      46                 : #include <iosfwd>
      47                 : #include <bits/ios_base.h>
      48                 : 
      49                 : _GLIBCXX_BEGIN_NAMESPACE(std)
      50                 : 
      51                 :   // [27.6.3] standard manipulators
      52                 :   // Also see DR 183.
      53                 : 
      54                 :   struct _Resetiosflags { ios_base::fmtflags _M_mask; };
      55                 : 
      56                 :   /**
      57                 :    *  @brief  Manipulator for @c setf.
      58                 :    *  @param  mask  A format flags mask.
      59                 :    *
      60                 :    *  Sent to a stream object, this manipulator resets the specified flags,
      61                 :    *  via @e stream.setf(0,mask).
      62                 :   */
      63                 :   inline _Resetiosflags 
      64                 :   resetiosflags(ios_base::fmtflags __mask)
      65                 :   { 
      66                 :     _Resetiosflags __x; 
      67                 :     __x._M_mask = __mask; 
      68                 :     return __x; 
      69                 :   }
      70                 : 
      71                 :   template<typename _CharT, typename _Traits>
      72                 :     inline basic_istream<_CharT, _Traits>& 
      73                 :     operator>>(basic_istream<_CharT, _Traits>& __is, _Resetiosflags __f)
      74                 :     { 
      75                 :       __is.setf(ios_base::fmtflags(0), __f._M_mask); 
      76                 :       return __is; 
      77                 :     }
      78                 : 
      79                 :   template<typename _CharT, typename _Traits>
      80                 :     inline basic_ostream<_CharT, _Traits>& 
      81                 :     operator<<(basic_ostream<_CharT, _Traits>& __os, _Resetiosflags __f)
      82                 :     { 
      83                 :       __os.setf(ios_base::fmtflags(0), __f._M_mask); 
      84                 :       return __os; 
      85                 :     }
      86                 : 
      87                 : 
      88                 :   struct _Setiosflags { ios_base::fmtflags _M_mask; };
      89                 : 
      90                 :   /**
      91                 :    *  @brief  Manipulator for @c setf.
      92                 :    *  @param  mask  A format flags mask.
      93                 :    *
      94                 :    *  Sent to a stream object, this manipulator sets the format flags
      95                 :    *  to @a mask.
      96                 :   */
      97                 :   inline _Setiosflags 
      98                 :   setiosflags(ios_base::fmtflags __mask)
      99                 :   { 
     100                 :     _Setiosflags __x; 
     101                 :     __x._M_mask = __mask; 
     102                 :     return __x; 
     103                 :   }
     104                 : 
     105                 :   template<typename _CharT, typename _Traits>
     106                 :     inline basic_istream<_CharT, _Traits>& 
     107                 :     operator>>(basic_istream<_CharT, _Traits>& __is, _Setiosflags __f)
     108                 :     { 
     109                 :       __is.setf(__f._M_mask); 
     110                 :       return __is; 
     111                 :     }
     112                 : 
     113                 :   template<typename _CharT, typename _Traits>
     114                 :     inline basic_ostream<_CharT, _Traits>& 
     115                 :     operator<<(basic_ostream<_CharT, _Traits>& __os, _Setiosflags __f)
     116                 :     { 
     117                 :       __os.setf(__f._M_mask); 
     118                 :       return __os; 
     119                 :     }
     120                 : 
     121                 : 
     122                 :   struct _Setbase { int _M_base; };
     123                 : 
     124                 :   /**
     125                 :    *  @brief  Manipulator for @c setf.
     126                 :    *  @param  base  A numeric base.
     127                 :    *
     128                 :    *  Sent to a stream object, this manipulator changes the
     129                 :    *  @c ios_base::basefield flags to @c oct, @c dec, or @c hex when @a base
     130                 :    *  is 8, 10, or 16, accordingly, and to 0 if @a base is any other value.
     131                 :   */
     132                 :   inline _Setbase 
     133                 :   setbase(int __base)
     134                 :   { 
     135                 :     _Setbase __x; 
     136                 :     __x._M_base = __base; 
     137                 :     return __x; 
     138                 :   }
     139                 : 
     140                 :   template<typename _CharT, typename _Traits>
     141                 :     inline basic_istream<_CharT, _Traits>& 
     142                 :     operator>>(basic_istream<_CharT, _Traits>& __is, _Setbase __f)
     143                 :     {
     144                 :       __is.setf(__f._M_base ==  8 ? ios_base::oct : 
     145                 :                 __f._M_base == 10 ? ios_base::dec : 
     146                 :                 __f._M_base == 16 ? ios_base::hex : 
     147                 :                 ios_base::fmtflags(0), ios_base::basefield);
     148                 :       return __is; 
     149                 :     }
     150                 :   
     151                 :   template<typename _CharT, typename _Traits>
     152                 :     inline basic_ostream<_CharT, _Traits>& 
     153                 :     operator<<(basic_ostream<_CharT, _Traits>& __os, _Setbase __f)
     154                 :     {
     155                 :       __os.setf(__f._M_base ==  8 ? ios_base::oct : 
     156                 :                 __f._M_base == 10 ? ios_base::dec : 
     157                 :                 __f._M_base == 16 ? ios_base::hex : 
     158                 :                 ios_base::fmtflags(0), ios_base::basefield);
     159                 :       return __os; 
     160                 :     }
     161                 :   
     162                 : 
     163                 :   template<typename _CharT> 
     164                 :     struct _Setfill { _CharT _M_c; };
     165                 : 
     166                 :   /**
     167                 :    *  @brief  Manipulator for @c fill.
     168                 :    *  @param  c  The new fill character.
     169                 :    *
     170                 :    *  Sent to a stream object, this manipulator calls @c fill(c) for that
     171                 :    *  object.
     172                 :   */
     173                 :   template<typename _CharT> 
     174                 :     inline _Setfill<_CharT> 
     175              33 :     setfill(_CharT __c)
     176                 :     { 
     177                 :       _Setfill<_CharT> __x; 
     178              33 :       __x._M_c = __c; 
     179                 :       return __x; 
     180                 :     }
     181                 : 
     182                 :   template<typename _CharT, typename _Traits>
     183                 :     inline basic_istream<_CharT, _Traits>& 
     184                 :     operator>>(basic_istream<_CharT, _Traits>& __is, _Setfill<_CharT> __f)
     185                 :     { 
     186                 :       __is.fill(__f._M_c); 
     187                 :       return __is; 
     188                 :     }
     189                 : 
     190                 :   template<typename _CharT, typename _Traits>
     191                 :     inline basic_ostream<_CharT, _Traits>& 
     192               0 :     operator<<(basic_ostream<_CharT, _Traits>& __os, _Setfill<_CharT> __f)
     193                 :     { 
     194               0 :       __os.fill(__f._M_c); 
     195               0 :       return __os; 
     196                 :     }
     197                 : 
     198                 : 
     199                 :   struct _Setprecision { int _M_n; };
     200                 : 
     201                 :   /**
     202                 :    *  @brief  Manipulator for @c precision.
     203                 :    *  @param  n  The new precision.
     204                 :    *
     205                 :    *  Sent to a stream object, this manipulator calls @c precision(n) for
     206                 :    *  that object.
     207                 :   */
     208                 :   inline _Setprecision 
     209                 :   setprecision(int __n)
     210                 :   { 
     211                 :     _Setprecision __x; 
     212                 :     __x._M_n = __n; 
     213                 :     return __x; 
     214                 :   }
     215                 : 
     216                 :   template<typename _CharT, typename _Traits>
     217                 :     inline basic_istream<_CharT, _Traits>& 
     218                 :     operator>>(basic_istream<_CharT, _Traits>& __is, _Setprecision __f)
     219                 :     { 
     220                 :       __is.precision(__f._M_n); 
     221                 :       return __is; 
     222                 :     }
     223                 : 
     224                 :   template<typename _CharT, typename _Traits>
     225                 :     inline basic_ostream<_CharT, _Traits>& 
     226                 :     operator<<(basic_ostream<_CharT, _Traits>& __os, _Setprecision __f)
     227                 :     { 
     228                 :       __os.precision(__f._M_n); 
     229                 :       return __os; 
     230                 :     }
     231                 : 
     232                 : 
     233                 :   struct _Setw { int _M_n; };
     234                 : 
     235                 :   /**
     236                 :    *  @brief  Manipulator for @c width.
     237                 :    *  @param  n  The new width.
     238                 :    *
     239                 :    *  Sent to a stream object, this manipulator calls @c width(n) for
     240                 :    *  that object.
     241                 :   */
     242                 :   inline _Setw 
     243             165 :   setw(int __n)
     244                 :   { 
     245                 :     _Setw __x; 
     246             165 :     __x._M_n = __n; 
     247                 :     return __x; 
     248                 :   }
     249                 : 
     250                 :   template<typename _CharT, typename _Traits>
     251                 :     inline basic_istream<_CharT, _Traits>& 
     252                 :     operator>>(basic_istream<_CharT, _Traits>& __is, _Setw __f)
     253                 :     { 
     254                 :       __is.width(__f._M_n); 
     255                 :       return __is; 
     256                 :     }
     257                 : 
     258                 :   template<typename _CharT, typename _Traits>
     259                 :     inline basic_ostream<_CharT, _Traits>& 
     260               0 :     operator<<(basic_ostream<_CharT, _Traits>& __os, _Setw __f)
     261                 :     { 
     262               0 :       __os.width(__f._M_n); 
     263               0 :       return __os; 
     264                 :     }
     265                 : 
     266                 :   // Inhibit implicit instantiations for required instantiations,
     267                 :   // which are defined via explicit instantiations elsewhere.  
     268                 :   // NB:  This syntax is a GNU extension.
     269                 : #if _GLIBCXX_EXTERN_TEMPLATE
     270                 :   extern template ostream& operator<<(ostream&, _Setfill<char>);
     271                 :   extern template ostream& operator<<(ostream&, _Setiosflags);
     272                 :   extern template ostream& operator<<(ostream&, _Resetiosflags);
     273                 :   extern template ostream& operator<<(ostream&, _Setbase);
     274                 :   extern template ostream& operator<<(ostream&, _Setprecision);
     275                 :   extern template ostream& operator<<(ostream&, _Setw);
     276                 :   extern template istream& operator>>(istream&, _Setfill<char>);
     277                 :   extern template istream& operator>>(istream&, _Setiosflags);
     278                 :   extern template istream& operator>>(istream&, _Resetiosflags);
     279                 :   extern template istream& operator>>(istream&, _Setbase);
     280                 :   extern template istream& operator>>(istream&, _Setprecision);
     281                 :   extern template istream& operator>>(istream&, _Setw);
     282                 : 
     283                 : #ifdef _GLIBCXX_USE_WCHAR_T
     284                 :   extern template wostream& operator<<(wostream&, _Setfill<wchar_t>);
     285                 :   extern template wostream& operator<<(wostream&, _Setiosflags);
     286                 :   extern template wostream& operator<<(wostream&, _Resetiosflags);
     287                 :   extern template wostream& operator<<(wostream&, _Setbase);
     288                 :   extern template wostream& operator<<(wostream&, _Setprecision);
     289                 :   extern template wostream& operator<<(wostream&, _Setw);
     290                 :   extern template wistream& operator>>(wistream&, _Setfill<wchar_t>);
     291                 :   extern template wistream& operator>>(wistream&, _Setiosflags);
     292                 :   extern template wistream& operator>>(wistream&, _Resetiosflags);
     293                 :   extern template wistream& operator>>(wistream&, _Setbase);
     294                 :   extern template wistream& operator>>(wistream&, _Setprecision);
     295                 :   extern template wistream& operator>>(wistream&, _Setw);
     296                 : #endif
     297                 : #endif
     298                 : 
     299                 : _GLIBCXX_END_NAMESPACE
     300                 : 
     301                 : #endif /* _GLIBCXX_IOMANIP */

Generated by: LTP GCOV extension version 1.6