OpenCores
URL https://opencores.org/ocsvn/scarts/scarts/trunk

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-gcc/] [gcc-4.1.1/] [libstdc++-v3/] [include/] [std/] [std_iomanip.h] - Blame information for rev 17

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.