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

Subversion Repositories altor32

[/] [altor32/] [trunk/] [gcc-x64/] [or1knd-elf/] [or1knd-elf/] [include/] [c++/] [4.8.0/] [istream] - Blame information for rev 35

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 35 ultra_embe
// Input streams -*- C++ -*-
2
 
3
// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
4
// 2006, 2007, 2008, 2009, 2010, 2011, 2012
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 3, 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
// Under Section 7 of GPL version 3, you are granted additional
19
// permissions described in the GCC Runtime Library Exception, version
20
// 3.1, as published by the Free Software Foundation.
21
 
22
// You should have received a copy of the GNU General Public License and
23
// a copy of the GCC Runtime Library Exception along with this program;
24
// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
25
// .
26
 
27
//
28
// ISO C++ 14882: 27.6.1  Input streams
29
//
30
 
31
/** @file include/istream
32
 *  This is a Standard C++ Library header.
33
 */
34
 
35
#ifndef _GLIBCXX_ISTREAM
36
#define _GLIBCXX_ISTREAM 1
37
 
38
#pragma GCC system_header
39
 
40
#include 
41
#include 
42
 
43
namespace std _GLIBCXX_VISIBILITY(default)
44
{
45
_GLIBCXX_BEGIN_NAMESPACE_VERSION
46
 
47
  /**
48
   *  @brief  Template class basic_istream.
49
   *  @ingroup io
50
   *
51
   *  @tparam _CharT  Type of character stream.
52
   *  @tparam _Traits  Traits for character type, defaults to
53
   *                   char_traits<_CharT>.
54
   *
55
   *  This is the base class for all input streams.  It provides text
56
   *  formatting of all builtin types, and communicates with any class
57
   *  derived from basic_streambuf to do the actual input.
58
  */
59
  template
60
    class basic_istream : virtual public basic_ios<_CharT, _Traits>
61
    {
62
    public:
63
      // Types (inherited from basic_ios (27.4.4)):
64
      typedef _CharT                                    char_type;
65
      typedef typename _Traits::int_type                int_type;
66
      typedef typename _Traits::pos_type                pos_type;
67
      typedef typename _Traits::off_type                off_type;
68
      typedef _Traits                                   traits_type;
69
 
70
      // Non-standard Types:
71
      typedef basic_streambuf<_CharT, _Traits>           __streambuf_type;
72
      typedef basic_ios<_CharT, _Traits>         __ios_type;
73
      typedef basic_istream<_CharT, _Traits>             __istream_type;
74
      typedef num_get<_CharT, istreambuf_iterator<_CharT, _Traits> >
75
                                                        __num_get_type;
76
      typedef ctype<_CharT>                             __ctype_type;
77
 
78
    protected:
79
      // Data Members:
80
      /**
81
       *  The number of characters extracted in the previous unformatted
82
       *  function; see gcount().
83
      */
84
      streamsize                _M_gcount;
85
 
86
    public:
87
      /**
88
       *  @brief  Base constructor.
89
       *
90
       *  This ctor is almost never called by the user directly, rather from
91
       *  derived classes' initialization lists, which pass a pointer to
92
       *  their own stream buffer.
93
      */
94
      explicit
95
      basic_istream(__streambuf_type* __sb)
96
      : _M_gcount(streamsize(0))
97
      { this->init(__sb); }
98
 
99
      /**
100
       *  @brief  Base destructor.
101
       *
102
       *  This does very little apart from providing a virtual base dtor.
103
      */
104
      virtual
105
      ~basic_istream()
106
      { _M_gcount = streamsize(0); }
107
 
108
      /// Safe prefix/suffix operations.
109
      class sentry;
110
      friend class sentry;
111
 
112
      //@{
113
      /**
114
       *  @brief  Interface for manipulators.
115
       *
116
       *  Manipulators such as @c std::ws and @c std::dec use these
117
       *  functions in constructs like
118
       *  std::cin >> std::ws.
119
       *  For more information, see the iomanip header.
120
      */
121
      __istream_type&
122
      operator>>(__istream_type& (*__pf)(__istream_type&))
123
      { return __pf(*this); }
124
 
125
      __istream_type&
126
      operator>>(__ios_type& (*__pf)(__ios_type&))
127
      {
128
        __pf(*this);
129
        return *this;
130
      }
131
 
132
      __istream_type&
133
      operator>>(ios_base& (*__pf)(ios_base&))
134
      {
135
        __pf(*this);
136
        return *this;
137
      }
138
      //@}
139
 
140
      //@{
141
      /**
142
       *  @name Extractors
143
       *
144
       *  All the @c operator>> functions (aka formatted input
145
       *  functions) have some common behavior.  Each starts by
146
       *  constructing a temporary object of type std::basic_istream::sentry
147
       *  with the second argument (noskipws) set to false.  This has several
148
       *  effects, concluding with the setting of a status flag; see the
149
       *  sentry documentation for more.
150
       *
151
       *  If the sentry status is good, the function tries to extract
152
       *  whatever data is appropriate for the type of the argument.
153
       *
154
       *  If an exception is thrown during extraction, ios_base::badbit
155
       *  will be turned on in the stream's error state without causing an
156
       *  ios_base::failure to be thrown.  The original exception will then
157
       *  be rethrown.
158
      */
159
 
160
      //@{
161
      /**
162
       *  @brief  Integer arithmetic extractors
163
       *  @param  __n A variable of builtin integral type.
164
       *  @return  @c *this if successful
165
       *
166
       *  These functions use the stream's current locale (specifically, the
167
       *  @c num_get facet) to parse the input data.
168
      */
169
      __istream_type&
170
      operator>>(bool& __n)
171
      { return _M_extract(__n); }
172
 
173
      __istream_type&
174
      operator>>(short& __n);
175
 
176
      __istream_type&
177
      operator>>(unsigned short& __n)
178
      { return _M_extract(__n); }
179
 
180
      __istream_type&
181
      operator>>(int& __n);
182
 
183
      __istream_type&
184
      operator>>(unsigned int& __n)
185
      { return _M_extract(__n); }
186
 
187
      __istream_type&
188
      operator>>(long& __n)
189
      { return _M_extract(__n); }
190
 
191
      __istream_type&
192
      operator>>(unsigned long& __n)
193
      { return _M_extract(__n); }
194
 
195
#ifdef _GLIBCXX_USE_LONG_LONG
196
      __istream_type&
197
      operator>>(long long& __n)
198
      { return _M_extract(__n); }
199
 
200
      __istream_type&
201
      operator>>(unsigned long long& __n)
202
      { return _M_extract(__n); }
203
#endif
204
      //@}
205
 
206
      //@{
207
      /**
208
       *  @brief  Floating point arithmetic extractors
209
       *  @param  __f A variable of builtin floating point type.
210
       *  @return  @c *this if successful
211
       *
212
       *  These functions use the stream's current locale (specifically, the
213
       *  @c num_get facet) to parse the input data.
214
      */
215
      __istream_type&
216
      operator>>(float& __f)
217
      { return _M_extract(__f); }
218
 
219
      __istream_type&
220
      operator>>(double& __f)
221
      { return _M_extract(__f); }
222
 
223
      __istream_type&
224
      operator>>(long double& __f)
225
      { return _M_extract(__f); }
226
      //@}
227
 
228
      /**
229
       *  @brief  Basic arithmetic extractors
230
       *  @param  __p A variable of pointer type.
231
       *  @return  @c *this if successful
232
       *
233
       *  These functions use the stream's current locale (specifically, the
234
       *  @c num_get facet) to parse the input data.
235
      */
236
      __istream_type&
237
      operator>>(void*& __p)
238
      { return _M_extract(__p); }
239
 
240
      /**
241
       *  @brief  Extracting into another streambuf.
242
       *  @param  __sb  A pointer to a streambuf
243
       *
244
       *  This function behaves like one of the basic arithmetic extractors,
245
       *  in that it also constructs a sentry object and has the same error
246
       *  handling behavior.
247
       *
248
       *  If @p __sb is NULL, the stream will set failbit in its error state.
249
       *
250
       *  Characters are extracted from this stream and inserted into the
251
       *  @p __sb streambuf until one of the following occurs:
252
       *
253
       *  - the input stream reaches end-of-file,
254
       *  - insertion into the output buffer fails (in this case, the
255
       *    character that would have been inserted is not extracted), or
256
       *  - an exception occurs (and in this case is caught)
257
       *
258
       *  If the function inserts no characters, failbit is set.
259
      */
260
      __istream_type&
261
      operator>>(__streambuf_type* __sb);
262
      //@}
263
 
264
      // [27.6.1.3] unformatted input
265
      /**
266
       *  @brief  Character counting
267
       *  @return  The number of characters extracted by the previous
268
       *           unformatted input function dispatched for this stream.
269
      */
270
      streamsize
271
      gcount() const
272
      { return _M_gcount; }
273
 
274
      //@{
275
      /**
276
       *  @name Unformatted Input Functions
277
       *
278
       *  All the unformatted input functions have some common behavior.
279
       *  Each starts by constructing a temporary object of type
280
       *  std::basic_istream::sentry with the second argument (noskipws)
281
       *  set to true.  This has several effects, concluding with the
282
       *  setting of a status flag; see the sentry documentation for more.
283
       *
284
       *  If the sentry status is good, the function tries to extract
285
       *  whatever data is appropriate for the type of the argument.
286
       *
287
       *  The number of characters extracted is stored for later retrieval
288
       *  by gcount().
289
       *
290
       *  If an exception is thrown during extraction, ios_base::badbit
291
       *  will be turned on in the stream's error state without causing an
292
       *  ios_base::failure to be thrown.  The original exception will then
293
       *  be rethrown.
294
      */
295
 
296
      /**
297
       *  @brief  Simple extraction.
298
       *  @return  A character, or eof().
299
       *
300
       *  Tries to extract a character.  If none are available, sets failbit
301
       *  and returns traits::eof().
302
      */
303
      int_type
304
      get();
305
 
306
      /**
307
       *  @brief  Simple extraction.
308
       *  @param  __c  The character in which to store data.
309
       *  @return  *this
310
       *
311
       *  Tries to extract a character and store it in @a __c.  If none are
312
       *  available, sets failbit and returns traits::eof().
313
       *
314
       *  @note  This function is not overloaded on signed char and
315
       *         unsigned char.
316
      */
317
      __istream_type&
318
      get(char_type& __c);
319
 
320
      /**
321
       *  @brief  Simple multiple-character extraction.
322
       *  @param  __s  Pointer to an array.
323
       *  @param  __n  Maximum number of characters to store in @a __s.
324
       *  @param  __delim  A "stop" character.
325
       *  @return  *this
326
       *
327
       *  Characters are extracted and stored into @a __s until one of the
328
       *  following happens:
329
       *
330
       *  - @c __n-1 characters are stored
331
       *  - the input sequence reaches EOF
332
       *  - the next character equals @a __delim, in which case the character
333
       *    is not extracted
334
       *
335
       * If no characters are stored, failbit is set in the stream's error
336
       * state.
337
       *
338
       * In any case, a null character is stored into the next location in
339
       * the array.
340
       *
341
       *  @note  This function is not overloaded on signed char and
342
       *         unsigned char.
343
      */
344
      __istream_type&
345
      get(char_type* __s, streamsize __n, char_type __delim);
346
 
347
      /**
348
       *  @brief  Simple multiple-character extraction.
349
       *  @param  __s  Pointer to an array.
350
       *  @param  __n  Maximum number of characters to store in @a s.
351
       *  @return  *this
352
       *
353
       *  Returns @c get(__s,__n,widen('\\n')).
354
      */
355
      __istream_type&
356
      get(char_type* __s, streamsize __n)
357
      { return this->get(__s, __n, this->widen('\n')); }
358
 
359
      /**
360
       *  @brief  Extraction into another streambuf.
361
       *  @param  __sb  A streambuf in which to store data.
362
       *  @param  __delim  A "stop" character.
363
       *  @return  *this
364
       *
365
       *  Characters are extracted and inserted into @a __sb until one of the
366
       *  following happens:
367
       *
368
       *  - the input sequence reaches EOF
369
       *  - insertion into the output buffer fails (in this case, the
370
       *    character that would have been inserted is not extracted)
371
       *  - the next character equals @a __delim (in this case, the character
372
       *    is not extracted)
373
       *  - an exception occurs (and in this case is caught)
374
       *
375
       * If no characters are stored, failbit is set in the stream's error
376
       * state.
377
      */
378
      __istream_type&
379
      get(__streambuf_type& __sb, char_type __delim);
380
 
381
      /**
382
       *  @brief  Extraction into another streambuf.
383
       *  @param  __sb  A streambuf in which to store data.
384
       *  @return  *this
385
       *
386
       *  Returns @c get(__sb,widen('\\n')).
387
      */
388
      __istream_type&
389
      get(__streambuf_type& __sb)
390
      { return this->get(__sb, this->widen('\n')); }
391
 
392
      /**
393
       *  @brief  String extraction.
394
       *  @param  __s  A character array in which to store the data.
395
       *  @param  __n  Maximum number of characters to extract.
396
       *  @param  __delim  A "stop" character.
397
       *  @return  *this
398
       *
399
       *  Extracts and stores characters into @a __s until one of the
400
       *  following happens.  Note that these criteria are required to be
401
       *  tested in the order listed here, to allow an input line to exactly
402
       *  fill the @a __s array without setting failbit.
403
       *
404
       *  -# the input sequence reaches end-of-file, in which case eofbit
405
       *     is set in the stream error state
406
       *  -# the next character equals @c __delim, in which case the character
407
       *     is extracted (and therefore counted in @c gcount()) but not stored
408
       *  -# @c __n-1 characters are stored, in which case failbit is set
409
       *     in the stream error state
410
       *
411
       *  If no characters are extracted, failbit is set.  (An empty line of
412
       *  input should therefore not cause failbit to be set.)
413
       *
414
       *  In any case, a null character is stored in the next location in
415
       *  the array.
416
      */
417
      __istream_type&
418
      getline(char_type* __s, streamsize __n, char_type __delim);
419
 
420
      /**
421
       *  @brief  String extraction.
422
       *  @param  __s  A character array in which to store the data.
423
       *  @param  __n  Maximum number of characters to extract.
424
       *  @return  *this
425
       *
426
       *  Returns @c getline(__s,__n,widen('\\n')).
427
      */
428
      __istream_type&
429
      getline(char_type* __s, streamsize __n)
430
      { return this->getline(__s, __n, this->widen('\n')); }
431
 
432
      /**
433
       *  @brief  Discarding characters
434
       *  @param  __n  Number of characters to discard.
435
       *  @param  __delim  A "stop" character.
436
       *  @return  *this
437
       *
438
       *  Extracts characters and throws them away until one of the
439
       *  following happens:
440
       *  - if @a __n @c != @c std::numeric_limits::max(), @a __n
441
       *    characters are extracted
442
       *  - the input sequence reaches end-of-file
443
       *  - the next character equals @a __delim (in this case, the character
444
       *    is extracted); note that this condition will never occur if
445
       *    @a __delim equals @c traits::eof().
446
       *
447
       *  NB: Provide three overloads, instead of the single function
448
       *  (with defaults) mandated by the Standard: this leads to a
449
       *  better performing implementation, while still conforming to
450
       *  the Standard.
451
      */
452
      __istream_type&
453
      ignore(streamsize __n, int_type __delim);
454
 
455
      __istream_type&
456
      ignore(streamsize __n);
457
 
458
      __istream_type&
459
      ignore();
460
 
461
      /**
462
       *  @brief  Looking ahead in the stream
463
       *  @return  The next character, or eof().
464
       *
465
       *  If, after constructing the sentry object, @c good() is false,
466
       *  returns @c traits::eof().  Otherwise reads but does not extract
467
       *  the next input character.
468
      */
469
      int_type
470
      peek();
471
 
472
      /**
473
       *  @brief  Extraction without delimiters.
474
       *  @param  __s  A character array.
475
       *  @param  __n  Maximum number of characters to store.
476
       *  @return  *this
477
       *
478
       *  If the stream state is @c good(), extracts characters and stores
479
       *  them into @a __s until one of the following happens:
480
       *  - @a __n characters are stored
481
       *  - the input sequence reaches end-of-file, in which case the error
482
       *    state is set to @c failbit|eofbit.
483
       *
484
       *  @note  This function is not overloaded on signed char and
485
       *         unsigned char.
486
      */
487
      __istream_type&
488
      read(char_type* __s, streamsize __n);
489
 
490
      /**
491
       *  @brief  Extraction until the buffer is exhausted, but no more.
492
       *  @param  __s  A character array.
493
       *  @param  __n  Maximum number of characters to store.
494
       *  @return  The number of characters extracted.
495
       *
496
       *  Extracts characters and stores them into @a __s depending on the
497
       *  number of characters remaining in the streambuf's buffer,
498
       *  @c rdbuf()->in_avail(), called @c A here:
499
       *  - if @c A @c == @c -1, sets eofbit and extracts no characters
500
       *  - if @c A @c == @c 0, extracts no characters
501
       *  - if @c A @c > @c 0, extracts @c min(A,n)
502
       *
503
       *  The goal is to empty the current buffer, and to not request any
504
       *  more from the external input sequence controlled by the streambuf.
505
      */
506
      streamsize
507
      readsome(char_type* __s, streamsize __n);
508
 
509
      /**
510
       *  @brief  Unextracting a single character.
511
       *  @param  __c  The character to push back into the input stream.
512
       *  @return  *this
513
       *
514
       *  If @c rdbuf() is not null, calls @c rdbuf()->sputbackc(c).
515
       *
516
       *  If @c rdbuf() is null or if @c sputbackc() fails, sets badbit in
517
       *  the error state.
518
       *
519
       *  @note  This function first clears eofbit.  Since no characters
520
       *         are extracted, the next call to @c gcount() will return 0,
521
       *         as required by DR 60.
522
      */
523
      __istream_type&
524
      putback(char_type __c);
525
 
526
      /**
527
       *  @brief  Unextracting the previous character.
528
       *  @return  *this
529
       *
530
       *  If @c rdbuf() is not null, calls @c rdbuf()->sungetc(c).
531
       *
532
       *  If @c rdbuf() is null or if @c sungetc() fails, sets badbit in
533
       *  the error state.
534
       *
535
       *  @note  This function first clears eofbit.  Since no characters
536
       *         are extracted, the next call to @c gcount() will return 0,
537
       *         as required by DR 60.
538
      */
539
      __istream_type&
540
      unget();
541
 
542
      /**
543
       *  @brief  Synchronizing the stream buffer.
544
       *  @return  0 on success, -1 on failure
545
       *
546
       *  If @c rdbuf() is a null pointer, returns -1.
547
       *
548
       *  Otherwise, calls @c rdbuf()->pubsync(), and if that returns -1,
549
       *  sets badbit and returns -1.
550
       *
551
       *  Otherwise, returns 0.
552
       *
553
       *  @note  This function does not count the number of characters
554
       *         extracted, if any, and therefore does not affect the next
555
       *         call to @c gcount().
556
      */
557
      int
558
      sync();
559
 
560
      /**
561
       *  @brief  Getting the current read position.
562
       *  @return  A file position object.
563
       *
564
       *  If @c fail() is not false, returns @c pos_type(-1) to indicate
565
       *  failure.  Otherwise returns @c rdbuf()->pubseekoff(0,cur,in).
566
       *
567
       *  @note  This function does not count the number of characters
568
       *         extracted, if any, and therefore does not affect the next
569
       *         call to @c gcount().  At variance with putback, unget and
570
       *         seekg, eofbit is not cleared first.
571
      */
572
      pos_type
573
      tellg();
574
 
575
      /**
576
       *  @brief  Changing the current read position.
577
       *  @param  __pos  A file position object.
578
       *  @return  *this
579
       *
580
       *  If @c fail() is not true, calls @c rdbuf()->pubseekpos(__pos).  If
581
       *  that function fails, sets failbit.
582
       *
583
       *  @note  This function first clears eofbit.  It does not count the
584
       *         number of characters extracted, if any, and therefore does
585
       *         not affect the next call to @c gcount().
586
      */
587
      __istream_type&
588
      seekg(pos_type);
589
 
590
      /**
591
       *  @brief  Changing the current read position.
592
       *  @param  __off  A file offset object.
593
       *  @param  __dir  The direction in which to seek.
594
       *  @return  *this
595
       *
596
       *  If @c fail() is not true, calls @c rdbuf()->pubseekoff(__off,__dir).
597
       *  If that function fails, sets failbit.
598
       *
599
       *  @note  This function first clears eofbit.  It does not count the
600
       *         number of characters extracted, if any, and therefore does
601
       *         not affect the next call to @c gcount().
602
      */
603
      __istream_type&
604
      seekg(off_type, ios_base::seekdir);
605
      //@}
606
 
607
    protected:
608
      basic_istream()
609
      : _M_gcount(streamsize(0))
610
      { this->init(0); }
611
 
612
      template
613
        __istream_type&
614
        _M_extract(_ValueT& __v);
615
    };
616
 
617
  /// Explicit specialization declarations, defined in src/istream.cc.
618
  template<>
619
    basic_istream&
620
    basic_istream::
621
    getline(char_type* __s, streamsize __n, char_type __delim);
622
 
623
  template<>
624
    basic_istream&
625
    basic_istream::
626
    ignore(streamsize __n);
627
 
628
  template<>
629
    basic_istream&
630
    basic_istream::
631
    ignore(streamsize __n, int_type __delim);
632
 
633
#ifdef _GLIBCXX_USE_WCHAR_T
634
  template<>
635
    basic_istream&
636
    basic_istream::
637
    getline(char_type* __s, streamsize __n, char_type __delim);
638
 
639
  template<>
640
    basic_istream&
641
    basic_istream::
642
    ignore(streamsize __n);
643
 
644
  template<>
645
    basic_istream&
646
    basic_istream::
647
    ignore(streamsize __n, int_type __delim);
648
#endif
649
 
650
  /**
651
   *  @brief  Performs setup work for input streams.
652
   *
653
   *  Objects of this class are created before all of the standard
654
   *  extractors are run.  It is responsible for exception-safe
655
   *  prefix and suffix operations, although only prefix actions
656
   *  are currently required by the standard.
657
  */
658
  template
659
    class basic_istream<_CharT, _Traits>::sentry
660
    {
661
      // Data Members.
662
      bool _M_ok;
663
 
664
    public:
665
      /// Easy access to dependant types.
666
      typedef _Traits                                   traits_type;
667
      typedef basic_streambuf<_CharT, _Traits>           __streambuf_type;
668
      typedef basic_istream<_CharT, _Traits>             __istream_type;
669
      typedef typename __istream_type::__ctype_type     __ctype_type;
670
      typedef typename _Traits::int_type                __int_type;
671
 
672
      /**
673
       *  @brief  The constructor performs all the work.
674
       *  @param  __is  The input stream to guard.
675
       *  @param  __noskipws  Whether to consume whitespace or not.
676
       *
677
       *  If the stream state is good (@a __is.good() is true), then the
678
       *  following actions are performed, otherwise the sentry state
679
       *  is false (not okay) and failbit is set in the
680
       *  stream state.
681
       *
682
       *  The sentry's preparatory actions are:
683
       *
684
       *  -# if the stream is tied to an output stream, @c is.tie()->flush()
685
       *     is called to synchronize the output sequence
686
       *  -# if @a __noskipws is false, and @c ios_base::skipws is set in
687
       *     @c is.flags(), the sentry extracts and discards whitespace
688
       *     characters from the stream.  The currently imbued locale is
689
       *     used to determine whether each character is whitespace.
690
       *
691
       *  If the stream state is still good, then the sentry state becomes
692
       *  true (@a okay).
693
      */
694
      explicit
695
      sentry(basic_istream<_CharT, _Traits>& __is, bool __noskipws = false);
696
 
697
      /**
698
       *  @brief  Quick status checking.
699
       *  @return  The sentry state.
700
       *
701
       *  For ease of use, sentries may be converted to booleans.  The
702
       *  return value is that of the sentry state (true == okay).
703
      */
704
#if __cplusplus >= 201103L
705
      explicit
706
#endif
707
      operator bool() const
708
      { return _M_ok; }
709
    };
710
 
711
  //@{
712
  /**
713
   *  @brief  Character extractors
714
   *  @param  __in  An input stream.
715
   *  @param  __c  A character reference.
716
   *  @return  in
717
   *
718
   *  Behaves like one of the formatted arithmetic extractors described in
719
   *  std::basic_istream.  After constructing a sentry object with good
720
   *  status, this function extracts a character (if one is available) and
721
   *  stores it in @a __c.  Otherwise, sets failbit in the input stream.
722
  */
723
  template
724
    basic_istream<_CharT, _Traits>&
725
    operator>>(basic_istream<_CharT, _Traits>& __in, _CharT& __c);
726
 
727
  template
728
    inline basic_istream&
729
    operator>>(basic_istream& __in, unsigned char& __c)
730
    { return (__in >> reinterpret_cast(__c)); }
731
 
732
  template
733
    inline basic_istream&
734
    operator>>(basic_istream& __in, signed char& __c)
735
    { return (__in >> reinterpret_cast(__c)); }
736
  //@}
737
 
738
  //@{
739
  /**
740
   *  @brief  Character string extractors
741
   *  @param  __in  An input stream.
742
   *  @param  __s  A pointer to a character array.
743
   *  @return  __in
744
   *
745
   *  Behaves like one of the formatted arithmetic extractors described in
746
   *  std::basic_istream.  After constructing a sentry object with good
747
   *  status, this function extracts up to @c n characters and stores them
748
   *  into the array starting at @a __s.  @c n is defined as:
749
   *
750
   *  - if @c width() is greater than zero, @c n is width() otherwise
751
   *  - @c n is the number of elements of the largest array of *
752
   *  - @c char_type that can store a terminating @c eos.
753
   *  - [27.6.1.2.3]/6
754
   *
755
   *  Characters are extracted and stored until one of the following happens:
756
   *  - @c n-1 characters are stored
757
   *  - EOF is reached
758
   *  - the next character is whitespace according to the current locale
759
   *  - the next character is a null byte (i.e., @c charT() )
760
   *
761
   *  @c width(0) is then called for the input stream.
762
   *
763
   *  If no characters are extracted, sets failbit.
764
  */
765
  template
766
    basic_istream<_CharT, _Traits>&
767
    operator>>(basic_istream<_CharT, _Traits>& __in, _CharT* __s);
768
 
769
  // Explicit specialization declaration, defined in src/istream.cc.
770
  template<>
771
    basic_istream&
772
    operator>>(basic_istream& __in, char* __s);
773
 
774
  template
775
    inline basic_istream&
776
    operator>>(basic_istream& __in, unsigned char* __s)
777
    { return (__in >> reinterpret_cast(__s)); }
778
 
779
  template
780
    inline basic_istream&
781
    operator>>(basic_istream& __in, signed char* __s)
782
    { return (__in >> reinterpret_cast(__s)); }
783
  //@}
784
 
785
  /**
786
   *  @brief  Template class basic_iostream
787
   *  @ingroup io
788
   *
789
   *  @tparam _CharT  Type of character stream.
790
   *  @tparam _Traits  Traits for character type, defaults to
791
   *                   char_traits<_CharT>.
792
   *
793
   *  This class multiply inherits from the input and output stream classes
794
   *  simply to provide a single interface.
795
  */
796
  template
797
    class basic_iostream
798
    : public basic_istream<_CharT, _Traits>,
799
      public basic_ostream<_CharT, _Traits>
800
    {
801
    public:
802
      // _GLIBCXX_RESOLVE_LIB_DEFECTS
803
      // 271. basic_iostream missing typedefs
804
      // Types (inherited):
805
      typedef _CharT                                    char_type;
806
      typedef typename _Traits::int_type                int_type;
807
      typedef typename _Traits::pos_type                pos_type;
808
      typedef typename _Traits::off_type                off_type;
809
      typedef _Traits                                   traits_type;
810
 
811
      // Non-standard Types:
812
      typedef basic_istream<_CharT, _Traits>             __istream_type;
813
      typedef basic_ostream<_CharT, _Traits>             __ostream_type;
814
 
815
      /**
816
       *  @brief  Constructor does nothing.
817
       *
818
       *  Both of the parent classes are initialized with the same
819
       *  streambuf pointer passed to this constructor.
820
      */
821
      explicit
822
      basic_iostream(basic_streambuf<_CharT, _Traits>* __sb)
823
      : __istream_type(__sb), __ostream_type(__sb) { }
824
 
825
      /**
826
       *  @brief  Destructor does nothing.
827
      */
828
      virtual
829
      ~basic_iostream() { }
830
 
831
    protected:
832
      basic_iostream()
833
      : __istream_type(), __ostream_type() { }
834
    };
835
 
836
  /**
837
   *  @brief  Quick and easy way to eat whitespace
838
   *
839
   *  This manipulator extracts whitespace characters, stopping when the
840
   *  next character is non-whitespace, or when the input sequence is empty.
841
   *  If the sequence is empty, @c eofbit is set in the stream, but not
842
   *  @c failbit.
843
   *
844
   *  The current locale is used to distinguish whitespace characters.
845
   *
846
   *  Example:
847
   *  @code
848
   *     MyClass   mc;
849
   *
850
   *     std::cin >> std::ws >> mc;
851
   *  @endcode
852
   *  will skip leading whitespace before calling operator>> on cin and your
853
   *  object.  Note that the same effect can be achieved by creating a
854
   *  std::basic_istream::sentry inside your definition of operator>>.
855
  */
856
  template
857
    basic_istream<_CharT, _Traits>&
858
    ws(basic_istream<_CharT, _Traits>& __is);
859
 
860
#if __cplusplus >= 201103L
861
  // [27.7.1.6] Rvalue stream extraction
862
  /**
863
   *  @brief  Generic extractor for rvalue stream
864
   *  @param  __is  An input stream.
865
   *  @param  __x  A reference to the extraction target.
866
   *  @return  is
867
   *
868
   *  This is just a forwarding function to allow extraction from
869
   *  rvalue streams since they won't bind to the extractor functions
870
   *  that take an lvalue reference.
871
  */
872
  template
873
    inline basic_istream<_CharT, _Traits>&
874
    operator>>(basic_istream<_CharT, _Traits>&& __is, _Tp& __x)
875
    { return (__is >> __x); }
876
#endif // C++11
877
 
878
_GLIBCXX_END_NAMESPACE_VERSION
879
} // namespace
880
 
881
#include 
882
 
883
#endif  /* _GLIBCXX_ISTREAM */

powered by: WebSVN 2.1.0

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