1*e4b17023SJohn Marino // Iostreams base classes -*- C++ -*-
2*e4b17023SJohn Marino
3*e4b17023SJohn Marino // Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
4*e4b17023SJohn Marino // 2006, 2007, 2008, 2009, 2010, 2011
5*e4b17023SJohn Marino // Free Software Foundation, Inc.
6*e4b17023SJohn Marino //
7*e4b17023SJohn Marino // This file is part of the GNU ISO C++ Library. This library is free
8*e4b17023SJohn Marino // software; you can redistribute it and/or modify it under the
9*e4b17023SJohn Marino // terms of the GNU General Public License as published by the
10*e4b17023SJohn Marino // Free Software Foundation; either version 3, or (at your option)
11*e4b17023SJohn Marino // any later version.
12*e4b17023SJohn Marino
13*e4b17023SJohn Marino // This library is distributed in the hope that it will be useful,
14*e4b17023SJohn Marino // but WITHOUT ANY WARRANTY; without even the implied warranty of
15*e4b17023SJohn Marino // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16*e4b17023SJohn Marino // GNU General Public License for more details.
17*e4b17023SJohn Marino
18*e4b17023SJohn Marino // Under Section 7 of GPL version 3, you are granted additional
19*e4b17023SJohn Marino // permissions described in the GCC Runtime Library Exception, version
20*e4b17023SJohn Marino // 3.1, as published by the Free Software Foundation.
21*e4b17023SJohn Marino
22*e4b17023SJohn Marino // You should have received a copy of the GNU General Public License and
23*e4b17023SJohn Marino // a copy of the GCC Runtime Library Exception along with this program;
24*e4b17023SJohn Marino // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
25*e4b17023SJohn Marino // <http://www.gnu.org/licenses/>.
26*e4b17023SJohn Marino
27*e4b17023SJohn Marino /** @file bits/basic_ios.h
28*e4b17023SJohn Marino * This is an internal header file, included by other library headers.
29*e4b17023SJohn Marino * Do not attempt to use it directly. @headername{ios}
30*e4b17023SJohn Marino */
31*e4b17023SJohn Marino
32*e4b17023SJohn Marino #ifndef _BASIC_IOS_H
33*e4b17023SJohn Marino #define _BASIC_IOS_H 1
34*e4b17023SJohn Marino
35*e4b17023SJohn Marino #pragma GCC system_header
36*e4b17023SJohn Marino
37*e4b17023SJohn Marino #include <bits/localefwd.h>
38*e4b17023SJohn Marino #include <bits/locale_classes.h>
39*e4b17023SJohn Marino #include <bits/locale_facets.h>
40*e4b17023SJohn Marino #include <bits/streambuf_iterator.h>
41*e4b17023SJohn Marino
_GLIBCXX_VISIBILITY(default)42*e4b17023SJohn Marino namespace std _GLIBCXX_VISIBILITY(default)
43*e4b17023SJohn Marino {
44*e4b17023SJohn Marino _GLIBCXX_BEGIN_NAMESPACE_VERSION
45*e4b17023SJohn Marino
46*e4b17023SJohn Marino template<typename _Facet>
47*e4b17023SJohn Marino inline const _Facet&
48*e4b17023SJohn Marino __check_facet(const _Facet* __f)
49*e4b17023SJohn Marino {
50*e4b17023SJohn Marino if (!__f)
51*e4b17023SJohn Marino __throw_bad_cast();
52*e4b17023SJohn Marino return *__f;
53*e4b17023SJohn Marino }
54*e4b17023SJohn Marino
55*e4b17023SJohn Marino // 27.4.5 Template class basic_ios
56*e4b17023SJohn Marino /**
57*e4b17023SJohn Marino * @brief Virtual base class for all stream classes.
58*e4b17023SJohn Marino * @ingroup io
59*e4b17023SJohn Marino *
60*e4b17023SJohn Marino * Most of the member functions called dispatched on stream objects
61*e4b17023SJohn Marino * (e.g., @c std::cout.foo(bar);) are consolidated in this class.
62*e4b17023SJohn Marino */
63*e4b17023SJohn Marino template<typename _CharT, typename _Traits>
64*e4b17023SJohn Marino class basic_ios : public ios_base
65*e4b17023SJohn Marino {
66*e4b17023SJohn Marino public:
67*e4b17023SJohn Marino //@{
68*e4b17023SJohn Marino /**
69*e4b17023SJohn Marino * These are standard types. They permit a standardized way of
70*e4b17023SJohn Marino * referring to names of (or names dependant on) the template
71*e4b17023SJohn Marino * parameters, which are specific to the implementation.
72*e4b17023SJohn Marino */
73*e4b17023SJohn Marino typedef _CharT char_type;
74*e4b17023SJohn Marino typedef typename _Traits::int_type int_type;
75*e4b17023SJohn Marino typedef typename _Traits::pos_type pos_type;
76*e4b17023SJohn Marino typedef typename _Traits::off_type off_type;
77*e4b17023SJohn Marino typedef _Traits traits_type;
78*e4b17023SJohn Marino //@}
79*e4b17023SJohn Marino
80*e4b17023SJohn Marino //@{
81*e4b17023SJohn Marino /**
82*e4b17023SJohn Marino * These are non-standard types.
83*e4b17023SJohn Marino */
84*e4b17023SJohn Marino typedef ctype<_CharT> __ctype_type;
85*e4b17023SJohn Marino typedef num_put<_CharT, ostreambuf_iterator<_CharT, _Traits> >
86*e4b17023SJohn Marino __num_put_type;
87*e4b17023SJohn Marino typedef num_get<_CharT, istreambuf_iterator<_CharT, _Traits> >
88*e4b17023SJohn Marino __num_get_type;
89*e4b17023SJohn Marino //@}
90*e4b17023SJohn Marino
91*e4b17023SJohn Marino // Data members:
92*e4b17023SJohn Marino protected:
93*e4b17023SJohn Marino basic_ostream<_CharT, _Traits>* _M_tie;
94*e4b17023SJohn Marino mutable char_type _M_fill;
95*e4b17023SJohn Marino mutable bool _M_fill_init;
96*e4b17023SJohn Marino basic_streambuf<_CharT, _Traits>* _M_streambuf;
97*e4b17023SJohn Marino
98*e4b17023SJohn Marino // Cached use_facet<ctype>, which is based on the current locale info.
99*e4b17023SJohn Marino const __ctype_type* _M_ctype;
100*e4b17023SJohn Marino // For ostream.
101*e4b17023SJohn Marino const __num_put_type* _M_num_put;
102*e4b17023SJohn Marino // For istream.
103*e4b17023SJohn Marino const __num_get_type* _M_num_get;
104*e4b17023SJohn Marino
105*e4b17023SJohn Marino public:
106*e4b17023SJohn Marino //@{
107*e4b17023SJohn Marino /**
108*e4b17023SJohn Marino * @brief The quick-and-easy status check.
109*e4b17023SJohn Marino *
110*e4b17023SJohn Marino * This allows you to write constructs such as
111*e4b17023SJohn Marino * <code>if (!a_stream) ...</code> and <code>while (a_stream) ...</code>
112*e4b17023SJohn Marino */
113*e4b17023SJohn Marino operator void*() const
114*e4b17023SJohn Marino { return this->fail() ? 0 : const_cast<basic_ios*>(this); }
115*e4b17023SJohn Marino
116*e4b17023SJohn Marino bool
117*e4b17023SJohn Marino operator!() const
118*e4b17023SJohn Marino { return this->fail(); }
119*e4b17023SJohn Marino //@}
120*e4b17023SJohn Marino
121*e4b17023SJohn Marino /**
122*e4b17023SJohn Marino * @brief Returns the error state of the stream buffer.
123*e4b17023SJohn Marino * @return A bit pattern (well, isn't everything?)
124*e4b17023SJohn Marino *
125*e4b17023SJohn Marino * See std::ios_base::iostate for the possible bit values. Most
126*e4b17023SJohn Marino * users will call one of the interpreting wrappers, e.g., good().
127*e4b17023SJohn Marino */
128*e4b17023SJohn Marino iostate
129*e4b17023SJohn Marino rdstate() const
130*e4b17023SJohn Marino { return _M_streambuf_state; }
131*e4b17023SJohn Marino
132*e4b17023SJohn Marino /**
133*e4b17023SJohn Marino * @brief [Re]sets the error state.
134*e4b17023SJohn Marino * @param __state The new state flag(s) to set.
135*e4b17023SJohn Marino *
136*e4b17023SJohn Marino * See std::ios_base::iostate for the possible bit values. Most
137*e4b17023SJohn Marino * users will not need to pass an argument.
138*e4b17023SJohn Marino */
139*e4b17023SJohn Marino void
140*e4b17023SJohn Marino clear(iostate __state = goodbit);
141*e4b17023SJohn Marino
142*e4b17023SJohn Marino /**
143*e4b17023SJohn Marino * @brief Sets additional flags in the error state.
144*e4b17023SJohn Marino * @param __state The additional state flag(s) to set.
145*e4b17023SJohn Marino *
146*e4b17023SJohn Marino * See std::ios_base::iostate for the possible bit values.
147*e4b17023SJohn Marino */
148*e4b17023SJohn Marino void
149*e4b17023SJohn Marino setstate(iostate __state)
150*e4b17023SJohn Marino { this->clear(this->rdstate() | __state); }
151*e4b17023SJohn Marino
152*e4b17023SJohn Marino // Flip the internal state on for the proper state bits, then re
153*e4b17023SJohn Marino // throws the propagated exception if bit also set in
154*e4b17023SJohn Marino // exceptions().
155*e4b17023SJohn Marino void
156*e4b17023SJohn Marino _M_setstate(iostate __state)
157*e4b17023SJohn Marino {
158*e4b17023SJohn Marino // 27.6.1.2.1 Common requirements.
159*e4b17023SJohn Marino // Turn this on without causing an ios::failure to be thrown.
160*e4b17023SJohn Marino _M_streambuf_state |= __state;
161*e4b17023SJohn Marino if (this->exceptions() & __state)
162*e4b17023SJohn Marino __throw_exception_again;
163*e4b17023SJohn Marino }
164*e4b17023SJohn Marino
165*e4b17023SJohn Marino /**
166*e4b17023SJohn Marino * @brief Fast error checking.
167*e4b17023SJohn Marino * @return True if no error flags are set.
168*e4b17023SJohn Marino *
169*e4b17023SJohn Marino * A wrapper around rdstate.
170*e4b17023SJohn Marino */
171*e4b17023SJohn Marino bool
172*e4b17023SJohn Marino good() const
173*e4b17023SJohn Marino { return this->rdstate() == 0; }
174*e4b17023SJohn Marino
175*e4b17023SJohn Marino /**
176*e4b17023SJohn Marino * @brief Fast error checking.
177*e4b17023SJohn Marino * @return True if the eofbit is set.
178*e4b17023SJohn Marino *
179*e4b17023SJohn Marino * Note that other iostate flags may also be set.
180*e4b17023SJohn Marino */
181*e4b17023SJohn Marino bool
182*e4b17023SJohn Marino eof() const
183*e4b17023SJohn Marino { return (this->rdstate() & eofbit) != 0; }
184*e4b17023SJohn Marino
185*e4b17023SJohn Marino /**
186*e4b17023SJohn Marino * @brief Fast error checking.
187*e4b17023SJohn Marino * @return True if either the badbit or the failbit is set.
188*e4b17023SJohn Marino *
189*e4b17023SJohn Marino * Checking the badbit in fail() is historical practice.
190*e4b17023SJohn Marino * Note that other iostate flags may also be set.
191*e4b17023SJohn Marino */
192*e4b17023SJohn Marino bool
193*e4b17023SJohn Marino fail() const
194*e4b17023SJohn Marino { return (this->rdstate() & (badbit | failbit)) != 0; }
195*e4b17023SJohn Marino
196*e4b17023SJohn Marino /**
197*e4b17023SJohn Marino * @brief Fast error checking.
198*e4b17023SJohn Marino * @return True if the badbit is set.
199*e4b17023SJohn Marino *
200*e4b17023SJohn Marino * Note that other iostate flags may also be set.
201*e4b17023SJohn Marino */
202*e4b17023SJohn Marino bool
203*e4b17023SJohn Marino bad() const
204*e4b17023SJohn Marino { return (this->rdstate() & badbit) != 0; }
205*e4b17023SJohn Marino
206*e4b17023SJohn Marino /**
207*e4b17023SJohn Marino * @brief Throwing exceptions on errors.
208*e4b17023SJohn Marino * @return The current exceptions mask.
209*e4b17023SJohn Marino *
210*e4b17023SJohn Marino * This changes nothing in the stream. See the one-argument version
211*e4b17023SJohn Marino * of exceptions(iostate) for the meaning of the return value.
212*e4b17023SJohn Marino */
213*e4b17023SJohn Marino iostate
214*e4b17023SJohn Marino exceptions() const
215*e4b17023SJohn Marino { return _M_exception; }
216*e4b17023SJohn Marino
217*e4b17023SJohn Marino /**
218*e4b17023SJohn Marino * @brief Throwing exceptions on errors.
219*e4b17023SJohn Marino * @param __except The new exceptions mask.
220*e4b17023SJohn Marino *
221*e4b17023SJohn Marino * By default, error flags are set silently. You can set an
222*e4b17023SJohn Marino * exceptions mask for each stream; if a bit in the mask becomes set
223*e4b17023SJohn Marino * in the error flags, then an exception of type
224*e4b17023SJohn Marino * std::ios_base::failure is thrown.
225*e4b17023SJohn Marino *
226*e4b17023SJohn Marino * If the error flag is already set when the exceptions mask is
227*e4b17023SJohn Marino * added, the exception is immediately thrown. Try running the
228*e4b17023SJohn Marino * following under GCC 3.1 or later:
229*e4b17023SJohn Marino * @code
230*e4b17023SJohn Marino * #include <iostream>
231*e4b17023SJohn Marino * #include <fstream>
232*e4b17023SJohn Marino * #include <exception>
233*e4b17023SJohn Marino *
234*e4b17023SJohn Marino * int main()
235*e4b17023SJohn Marino * {
236*e4b17023SJohn Marino * std::set_terminate (__gnu_cxx::__verbose_terminate_handler);
237*e4b17023SJohn Marino *
238*e4b17023SJohn Marino * std::ifstream f ("/etc/motd");
239*e4b17023SJohn Marino *
240*e4b17023SJohn Marino * std::cerr << "Setting badbit\n";
241*e4b17023SJohn Marino * f.setstate (std::ios_base::badbit);
242*e4b17023SJohn Marino *
243*e4b17023SJohn Marino * std::cerr << "Setting exception mask\n";
244*e4b17023SJohn Marino * f.exceptions (std::ios_base::badbit);
245*e4b17023SJohn Marino * }
246*e4b17023SJohn Marino * @endcode
247*e4b17023SJohn Marino */
248*e4b17023SJohn Marino void
249*e4b17023SJohn Marino exceptions(iostate __except)
250*e4b17023SJohn Marino {
251*e4b17023SJohn Marino _M_exception = __except;
252*e4b17023SJohn Marino this->clear(_M_streambuf_state);
253*e4b17023SJohn Marino }
254*e4b17023SJohn Marino
255*e4b17023SJohn Marino // Constructor/destructor:
256*e4b17023SJohn Marino /**
257*e4b17023SJohn Marino * @brief Constructor performs initialization.
258*e4b17023SJohn Marino *
259*e4b17023SJohn Marino * The parameter is passed by derived streams.
260*e4b17023SJohn Marino */
261*e4b17023SJohn Marino explicit
262*e4b17023SJohn Marino basic_ios(basic_streambuf<_CharT, _Traits>* __sb)
263*e4b17023SJohn Marino : ios_base(), _M_tie(0), _M_fill(), _M_fill_init(false), _M_streambuf(0),
264*e4b17023SJohn Marino _M_ctype(0), _M_num_put(0), _M_num_get(0)
265*e4b17023SJohn Marino { this->init(__sb); }
266*e4b17023SJohn Marino
267*e4b17023SJohn Marino /**
268*e4b17023SJohn Marino * @brief Empty.
269*e4b17023SJohn Marino *
270*e4b17023SJohn Marino * The destructor does nothing. More specifically, it does not
271*e4b17023SJohn Marino * destroy the streambuf held by rdbuf().
272*e4b17023SJohn Marino */
273*e4b17023SJohn Marino virtual
274*e4b17023SJohn Marino ~basic_ios() { }
275*e4b17023SJohn Marino
276*e4b17023SJohn Marino // Members:
277*e4b17023SJohn Marino /**
278*e4b17023SJohn Marino * @brief Fetches the current @e tied stream.
279*e4b17023SJohn Marino * @return A pointer to the tied stream, or NULL if the stream is
280*e4b17023SJohn Marino * not tied.
281*e4b17023SJohn Marino *
282*e4b17023SJohn Marino * A stream may be @e tied (or synchronized) to a second output
283*e4b17023SJohn Marino * stream. When this stream performs any I/O, the tied stream is
284*e4b17023SJohn Marino * first flushed. For example, @c std::cin is tied to @c std::cout.
285*e4b17023SJohn Marino */
286*e4b17023SJohn Marino basic_ostream<_CharT, _Traits>*
287*e4b17023SJohn Marino tie() const
288*e4b17023SJohn Marino { return _M_tie; }
289*e4b17023SJohn Marino
290*e4b17023SJohn Marino /**
291*e4b17023SJohn Marino * @brief Ties this stream to an output stream.
292*e4b17023SJohn Marino * @param __tiestr The output stream.
293*e4b17023SJohn Marino * @return The previously tied output stream, or NULL if the stream
294*e4b17023SJohn Marino * was not tied.
295*e4b17023SJohn Marino *
296*e4b17023SJohn Marino * This sets up a new tie; see tie() for more.
297*e4b17023SJohn Marino */
298*e4b17023SJohn Marino basic_ostream<_CharT, _Traits>*
299*e4b17023SJohn Marino tie(basic_ostream<_CharT, _Traits>* __tiestr)
300*e4b17023SJohn Marino {
301*e4b17023SJohn Marino basic_ostream<_CharT, _Traits>* __old = _M_tie;
302*e4b17023SJohn Marino _M_tie = __tiestr;
303*e4b17023SJohn Marino return __old;
304*e4b17023SJohn Marino }
305*e4b17023SJohn Marino
306*e4b17023SJohn Marino /**
307*e4b17023SJohn Marino * @brief Accessing the underlying buffer.
308*e4b17023SJohn Marino * @return The current stream buffer.
309*e4b17023SJohn Marino *
310*e4b17023SJohn Marino * This does not change the state of the stream.
311*e4b17023SJohn Marino */
312*e4b17023SJohn Marino basic_streambuf<_CharT, _Traits>*
313*e4b17023SJohn Marino rdbuf() const
314*e4b17023SJohn Marino { return _M_streambuf; }
315*e4b17023SJohn Marino
316*e4b17023SJohn Marino /**
317*e4b17023SJohn Marino * @brief Changing the underlying buffer.
318*e4b17023SJohn Marino * @param __sb The new stream buffer.
319*e4b17023SJohn Marino * @return The previous stream buffer.
320*e4b17023SJohn Marino *
321*e4b17023SJohn Marino * Associates a new buffer with the current stream, and clears the
322*e4b17023SJohn Marino * error state.
323*e4b17023SJohn Marino *
324*e4b17023SJohn Marino * Due to historical accidents which the LWG refuses to correct, the
325*e4b17023SJohn Marino * I/O library suffers from a design error: this function is hidden
326*e4b17023SJohn Marino * in derived classes by overrides of the zero-argument @c rdbuf(),
327*e4b17023SJohn Marino * which is non-virtual for hysterical raisins. As a result, you
328*e4b17023SJohn Marino * must use explicit qualifications to access this function via any
329*e4b17023SJohn Marino * derived class. For example:
330*e4b17023SJohn Marino *
331*e4b17023SJohn Marino * @code
332*e4b17023SJohn Marino * std::fstream foo; // or some other derived type
333*e4b17023SJohn Marino * std::streambuf* p = .....;
334*e4b17023SJohn Marino *
335*e4b17023SJohn Marino * foo.ios::rdbuf(p); // ios == basic_ios<char>
336*e4b17023SJohn Marino * @endcode
337*e4b17023SJohn Marino */
338*e4b17023SJohn Marino basic_streambuf<_CharT, _Traits>*
339*e4b17023SJohn Marino rdbuf(basic_streambuf<_CharT, _Traits>* __sb);
340*e4b17023SJohn Marino
341*e4b17023SJohn Marino /**
342*e4b17023SJohn Marino * @brief Copies fields of __rhs into this.
343*e4b17023SJohn Marino * @param __rhs The source values for the copies.
344*e4b17023SJohn Marino * @return Reference to this object.
345*e4b17023SJohn Marino *
346*e4b17023SJohn Marino * All fields of __rhs are copied into this object except that rdbuf()
347*e4b17023SJohn Marino * and rdstate() remain unchanged. All values in the pword and iword
348*e4b17023SJohn Marino * arrays are copied. Before copying, each callback is invoked with
349*e4b17023SJohn Marino * erase_event. After copying, each (new) callback is invoked with
350*e4b17023SJohn Marino * copyfmt_event. The final step is to copy exceptions().
351*e4b17023SJohn Marino */
352*e4b17023SJohn Marino basic_ios&
353*e4b17023SJohn Marino copyfmt(const basic_ios& __rhs);
354*e4b17023SJohn Marino
355*e4b17023SJohn Marino /**
356*e4b17023SJohn Marino * @brief Retrieves the @a empty character.
357*e4b17023SJohn Marino * @return The current fill character.
358*e4b17023SJohn Marino *
359*e4b17023SJohn Marino * It defaults to a space (' ') in the current locale.
360*e4b17023SJohn Marino */
361*e4b17023SJohn Marino char_type
362*e4b17023SJohn Marino fill() const
363*e4b17023SJohn Marino {
364*e4b17023SJohn Marino if (!_M_fill_init)
365*e4b17023SJohn Marino {
366*e4b17023SJohn Marino _M_fill = this->widen(' ');
367*e4b17023SJohn Marino _M_fill_init = true;
368*e4b17023SJohn Marino }
369*e4b17023SJohn Marino return _M_fill;
370*e4b17023SJohn Marino }
371*e4b17023SJohn Marino
372*e4b17023SJohn Marino /**
373*e4b17023SJohn Marino * @brief Sets a new @a empty character.
374*e4b17023SJohn Marino * @param __ch The new character.
375*e4b17023SJohn Marino * @return The previous fill character.
376*e4b17023SJohn Marino *
377*e4b17023SJohn Marino * The fill character is used to fill out space when P+ characters
378*e4b17023SJohn Marino * have been requested (e.g., via setw), Q characters are actually
379*e4b17023SJohn Marino * used, and Q<P. It defaults to a space (' ') in the current locale.
380*e4b17023SJohn Marino */
381*e4b17023SJohn Marino char_type
382*e4b17023SJohn Marino fill(char_type __ch)
383*e4b17023SJohn Marino {
384*e4b17023SJohn Marino char_type __old = this->fill();
385*e4b17023SJohn Marino _M_fill = __ch;
386*e4b17023SJohn Marino return __old;
387*e4b17023SJohn Marino }
388*e4b17023SJohn Marino
389*e4b17023SJohn Marino // Locales:
390*e4b17023SJohn Marino /**
391*e4b17023SJohn Marino * @brief Moves to a new locale.
392*e4b17023SJohn Marino * @param __loc The new locale.
393*e4b17023SJohn Marino * @return The previous locale.
394*e4b17023SJohn Marino *
395*e4b17023SJohn Marino * Calls @c ios_base::imbue(loc), and if a stream buffer is associated
396*e4b17023SJohn Marino * with this stream, calls that buffer's @c pubimbue(loc).
397*e4b17023SJohn Marino *
398*e4b17023SJohn Marino * Additional l10n notes are at
399*e4b17023SJohn Marino * http://gcc.gnu.org/onlinedocs/libstdc++/manual/localization.html
400*e4b17023SJohn Marino */
401*e4b17023SJohn Marino locale
402*e4b17023SJohn Marino imbue(const locale& __loc);
403*e4b17023SJohn Marino
404*e4b17023SJohn Marino /**
405*e4b17023SJohn Marino * @brief Squeezes characters.
406*e4b17023SJohn Marino * @param __c The character to narrow.
407*e4b17023SJohn Marino * @param __dfault The character to narrow.
408*e4b17023SJohn Marino * @return The narrowed character.
409*e4b17023SJohn Marino *
410*e4b17023SJohn Marino * Maps a character of @c char_type to a character of @c char,
411*e4b17023SJohn Marino * if possible.
412*e4b17023SJohn Marino *
413*e4b17023SJohn Marino * Returns the result of
414*e4b17023SJohn Marino * @code
415*e4b17023SJohn Marino * std::use_facet<ctype<char_type> >(getloc()).narrow(c,dfault)
416*e4b17023SJohn Marino * @endcode
417*e4b17023SJohn Marino *
418*e4b17023SJohn Marino * Additional l10n notes are at
419*e4b17023SJohn Marino * http://gcc.gnu.org/onlinedocs/libstdc++/manual/localization.html
420*e4b17023SJohn Marino */
421*e4b17023SJohn Marino char
422*e4b17023SJohn Marino narrow(char_type __c, char __dfault) const
423*e4b17023SJohn Marino { return __check_facet(_M_ctype).narrow(__c, __dfault); }
424*e4b17023SJohn Marino
425*e4b17023SJohn Marino /**
426*e4b17023SJohn Marino * @brief Widens characters.
427*e4b17023SJohn Marino * @param __c The character to widen.
428*e4b17023SJohn Marino * @return The widened character.
429*e4b17023SJohn Marino *
430*e4b17023SJohn Marino * Maps a character of @c char to a character of @c char_type.
431*e4b17023SJohn Marino *
432*e4b17023SJohn Marino * Returns the result of
433*e4b17023SJohn Marino * @code
434*e4b17023SJohn Marino * std::use_facet<ctype<char_type> >(getloc()).widen(c)
435*e4b17023SJohn Marino * @endcode
436*e4b17023SJohn Marino *
437*e4b17023SJohn Marino * Additional l10n notes are at
438*e4b17023SJohn Marino * http://gcc.gnu.org/onlinedocs/libstdc++/manual/localization.html
439*e4b17023SJohn Marino */
440*e4b17023SJohn Marino char_type
441*e4b17023SJohn Marino widen(char __c) const
442*e4b17023SJohn Marino { return __check_facet(_M_ctype).widen(__c); }
443*e4b17023SJohn Marino
444*e4b17023SJohn Marino protected:
445*e4b17023SJohn Marino // 27.4.5.1 basic_ios constructors
446*e4b17023SJohn Marino /**
447*e4b17023SJohn Marino * @brief Empty.
448*e4b17023SJohn Marino *
449*e4b17023SJohn Marino * The default constructor does nothing and is not normally
450*e4b17023SJohn Marino * accessible to users.
451*e4b17023SJohn Marino */
452*e4b17023SJohn Marino basic_ios()
453*e4b17023SJohn Marino : ios_base(), _M_tie(0), _M_fill(char_type()), _M_fill_init(false),
454*e4b17023SJohn Marino _M_streambuf(0), _M_ctype(0), _M_num_put(0), _M_num_get(0)
455*e4b17023SJohn Marino { }
456*e4b17023SJohn Marino
457*e4b17023SJohn Marino /**
458*e4b17023SJohn Marino * @brief All setup is performed here.
459*e4b17023SJohn Marino *
460*e4b17023SJohn Marino * This is called from the public constructor. It is not virtual and
461*e4b17023SJohn Marino * cannot be redefined.
462*e4b17023SJohn Marino */
463*e4b17023SJohn Marino void
464*e4b17023SJohn Marino init(basic_streambuf<_CharT, _Traits>* __sb);
465*e4b17023SJohn Marino
466*e4b17023SJohn Marino void
467*e4b17023SJohn Marino _M_cache_locale(const locale& __loc);
468*e4b17023SJohn Marino };
469*e4b17023SJohn Marino
470*e4b17023SJohn Marino _GLIBCXX_END_NAMESPACE_VERSION
471*e4b17023SJohn Marino } // namespace
472*e4b17023SJohn Marino
473*e4b17023SJohn Marino #include <bits/basic_ios.tcc>
474*e4b17023SJohn Marino
475*e4b17023SJohn Marino #endif /* _BASIC_IOS_H */
476