PageRenderTime 33ms CodeModel.GetById 17ms app.highlight 12ms RepoModel.GetById 2ms app.codeStats 0ms

/project/jni/stlport/stlport/stl/_ios.h

https://github.com/aichunyu/FFPlayer
C Header | 178 lines | 107 code | 38 blank | 33 comment | 4 complexity | 0c35ad41eb06b3097ef5b2a2d1469b9e MD5 | raw file
  1/*
  2 * Copyright (c) 1999
  3 * Silicon Graphics Computer Systems, Inc.
  4 *
  5 * Copyright (c) 1999
  6 * Boris Fomitchev
  7 *
  8 * This material is provided "as is", with absolutely no warranty expressed
  9 * or implied. Any use is at your own risk.
 10 *
 11 * Permission to use or copy this software for any purpose is hereby granted
 12 * without fee, provided the above notices are retained on all copies.
 13 * Permission to modify the code and to distribute modified code is granted,
 14 * provided the above notices are retained, and a notice that the code was
 15 * modified is included with the above copyright notice.
 16 *
 17 */
 18#ifndef _STLP_INTERNAL_IOS_H
 19#define _STLP_INTERNAL_IOS_H
 20
 21
 22#ifndef _STLP_IOS_BASE_H
 23# include <stl/_ios_base.h>
 24#endif
 25
 26#ifndef _STLP_INTERNAL_CTYPE_H
 27# include <stl/_ctype.h>
 28#endif
 29#ifndef _STLP_INTERNAL_NUMPUNCT_H
 30# include <stl/_numpunct.h>
 31#endif
 32
 33_STLP_BEGIN_NAMESPACE
 34
 35// ----------------------------------------------------------------------
 36
 37// Class basic_ios, a subclass of ios_base.  The only important difference
 38// between the two is that basic_ios is a class template, parameterized
 39// by the character type.  ios_base exists to factor out all of the
 40// common properties that don't depend on the character type.
 41
 42// The second template parameter, _Traits, defaults to char_traits<_CharT>.
 43// The default is declared in header <iosfwd>, and it isn't declared here
 44// because C++ language rules do not allow it to be declared twice.
 45
 46template <class _CharT, class _Traits>
 47class basic_ios : public ios_base {
 48  friend class ios_base;
 49public:                         // Synonyms for types.
 50  typedef _CharT                     char_type;
 51  typedef typename _Traits::int_type int_type;
 52  typedef typename _Traits::pos_type pos_type;
 53  typedef typename _Traits::off_type off_type;
 54  typedef _Traits                    traits_type;
 55
 56public:                         // Constructor, destructor.
 57  explicit basic_ios(basic_streambuf<_CharT, _Traits>* __streambuf);
 58  virtual ~basic_ios() {}
 59
 60public:                         // Members from clause 27.4.4.2
 61  basic_ostream<_CharT, _Traits>* tie() const {
 62    return _M_tied_ostream;
 63  }
 64  basic_ostream<_CharT, _Traits>*
 65  tie(basic_ostream<char_type, traits_type>* __new_tied_ostream) {
 66    basic_ostream<char_type, traits_type>* __tmp = _M_tied_ostream;
 67    _M_tied_ostream = __new_tied_ostream;
 68    return __tmp;
 69  }
 70
 71  basic_streambuf<_CharT, _Traits>* rdbuf() const
 72    { return _M_streambuf; }
 73
 74  basic_streambuf<_CharT, _Traits>*
 75  rdbuf(basic_streambuf<char_type, traits_type>*);
 76
 77  // Copies __x's state to *this.
 78  basic_ios<_CharT, _Traits>& copyfmt(const basic_ios<_CharT, _Traits>& __x);
 79
 80  char_type fill() const { return _M_fill; }
 81  char_type fill(char_type __fill) {
 82    char_type __tmp(_M_fill);
 83    _M_fill = __fill;
 84    return __tmp;
 85  }
 86
 87public:                         // Members from 27.4.4.3.  These four functions
 88                                // can almost be defined in ios_base.
 89
 90  void clear(iostate __state = goodbit) {
 91    _M_clear_nothrow(this->rdbuf() ? __state : iostate(__state|ios_base::badbit));
 92    _M_check_exception_mask();
 93  }
 94  void setstate(iostate __state) { this->clear(rdstate() | __state); }
 95
 96  iostate exceptions() const { return this->_M_get_exception_mask(); }
 97  void exceptions(iostate __mask) {
 98    this->_M_set_exception_mask(__mask);
 99    this->clear(this->rdstate());
100  }
101
102public:                         // Locale-related member functions.
103  locale imbue(const locale&);
104
105  inline char narrow(_CharT, char) const ;
106  inline _CharT widen(char) const;
107
108  // Helper function that makes testing for EOF more convenient.
109  static bool _STLP_CALL _S_eof(int_type __c) {
110    const int_type __eof = _Traits::eof();
111    return _Traits::eq_int_type(__c, __eof);
112  }
113
114protected:
115  basic_ios();
116
117  void init(basic_streambuf<_CharT, _Traits>* __streambuf);
118
119public:
120
121  // Helper function used in istream and ostream.  It is called only from
122  // a catch clause.
123  void _M_handle_exception(ios_base::iostate __flag);
124
125private:                        // Data members
126  char_type _M_fill;            // The fill character, used for padding.
127
128  basic_streambuf<_CharT, _Traits>* _M_streambuf;
129  basic_ostream<_CharT, _Traits>*   _M_tied_ostream;
130
131};
132
133
134template <class _CharT, class _Traits>
135inline char
136basic_ios<_CharT, _Traits>::narrow(_CharT __c, char __default) const
137{ return __STATIC_CAST(const ctype<_CharT>*, this->_M_ctype_facet())->narrow(__c, __default); }
138
139template <class _CharT, class _Traits>
140inline _CharT
141basic_ios<_CharT, _Traits>::widen(char __c) const
142{ return __STATIC_CAST(const ctype<_CharT>*, this->_M_ctype_facet())->widen(__c); }
143
144# if !defined (_STLP_NO_METHOD_SPECIALIZATION)
145_STLP_TEMPLATE_NULL
146inline char
147basic_ios<char, char_traits<char> >::narrow(char __c, char) const
148{
149  return __c;
150}
151
152_STLP_TEMPLATE_NULL
153inline char
154basic_ios<char, char_traits<char> >::widen(char __c) const
155{
156  return __c;
157}
158# endif /* _STLP_NO_METHOD_SPECIALIZATION */
159
160# if defined (_STLP_USE_TEMPLATE_EXPORT)
161_STLP_EXPORT_TEMPLATE_CLASS basic_ios<char, char_traits<char> >;
162#  if ! defined (_STLP_NO_WCHAR_T)
163_STLP_EXPORT_TEMPLATE_CLASS basic_ios<wchar_t, char_traits<wchar_t> >;
164#  endif
165# endif /* _STLP_USE_TEMPLATE_EXPORT */
166
167_STLP_END_NAMESPACE
168
169#if defined (_STLP_EXPOSE_STREAM_IMPLEMENTATION) && !defined (_STLP_LINK_TIME_INSTANTIATION)
170#  include <stl/_ios.c>
171#endif
172
173#endif /* _STLP_IOS */
174
175// Local Variables:
176// mode:C++
177// End:
178