/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. #ifndef _STLP_IOS_BASE_H
  21. # include <stl/_ios_base.h>
  22. #endif
  23. #ifndef _STLP_INTERNAL_CTYPE_H
  24. # include <stl/_ctype.h>
  25. #endif
  26. #ifndef _STLP_INTERNAL_NUMPUNCT_H
  27. # include <stl/_numpunct.h>
  28. #endif
  29. _STLP_BEGIN_NAMESPACE
  30. // ----------------------------------------------------------------------
  31. // Class basic_ios, a subclass of ios_base. The only important difference
  32. // between the two is that basic_ios is a class template, parameterized
  33. // by the character type. ios_base exists to factor out all of the
  34. // common properties that don't depend on the character type.
  35. // The second template parameter, _Traits, defaults to char_traits<_CharT>.
  36. // The default is declared in header <iosfwd>, and it isn't declared here
  37. // because C++ language rules do not allow it to be declared twice.
  38. template <class _CharT, class _Traits>
  39. class basic_ios : public ios_base {
  40. friend class ios_base;
  41. public: // Synonyms for types.
  42. typedef _CharT char_type;
  43. typedef typename _Traits::int_type int_type;
  44. typedef typename _Traits::pos_type pos_type;
  45. typedef typename _Traits::off_type off_type;
  46. typedef _Traits traits_type;
  47. public: // Constructor, destructor.
  48. explicit basic_ios(basic_streambuf<_CharT, _Traits>* __streambuf);
  49. virtual ~basic_ios() {}
  50. public: // Members from clause 27.4.4.2
  51. basic_ostream<_CharT, _Traits>* tie() const {
  52. return _M_tied_ostream;
  53. }
  54. basic_ostream<_CharT, _Traits>*
  55. tie(basic_ostream<char_type, traits_type>* __new_tied_ostream) {
  56. basic_ostream<char_type, traits_type>* __tmp = _M_tied_ostream;
  57. _M_tied_ostream = __new_tied_ostream;
  58. return __tmp;
  59. }
  60. basic_streambuf<_CharT, _Traits>* rdbuf() const
  61. { return _M_streambuf; }
  62. basic_streambuf<_CharT, _Traits>*
  63. rdbuf(basic_streambuf<char_type, traits_type>*);
  64. // Copies __x's state to *this.
  65. basic_ios<_CharT, _Traits>& copyfmt(const basic_ios<_CharT, _Traits>& __x);
  66. char_type fill() const { return _M_fill; }
  67. char_type fill(char_type __fill) {
  68. char_type __tmp(_M_fill);
  69. _M_fill = __fill;
  70. return __tmp;
  71. }
  72. public: // Members from 27.4.4.3. These four functions
  73. // can almost be defined in ios_base.
  74. void clear(iostate __state = goodbit) {
  75. _M_clear_nothrow(this->rdbuf() ? __state : iostate(__state|ios_base::badbit));
  76. _M_check_exception_mask();
  77. }
  78. void setstate(iostate __state) { this->clear(rdstate() | __state); }
  79. iostate exceptions() const { return this->_M_get_exception_mask(); }
  80. void exceptions(iostate __mask) {
  81. this->_M_set_exception_mask(__mask);
  82. this->clear(this->rdstate());
  83. }
  84. public: // Locale-related member functions.
  85. locale imbue(const locale&);
  86. inline char narrow(_CharT, char) const ;
  87. inline _CharT widen(char) const;
  88. // Helper function that makes testing for EOF more convenient.
  89. static bool _STLP_CALL _S_eof(int_type __c) {
  90. const int_type __eof = _Traits::eof();
  91. return _Traits::eq_int_type(__c, __eof);
  92. }
  93. protected:
  94. basic_ios();
  95. void init(basic_streambuf<_CharT, _Traits>* __streambuf);
  96. public:
  97. // Helper function used in istream and ostream. It is called only from
  98. // a catch clause.
  99. void _M_handle_exception(ios_base::iostate __flag);
  100. private: // Data members
  101. char_type _M_fill; // The fill character, used for padding.
  102. basic_streambuf<_CharT, _Traits>* _M_streambuf;
  103. basic_ostream<_CharT, _Traits>* _M_tied_ostream;
  104. };
  105. template <class _CharT, class _Traits>
  106. inline char
  107. basic_ios<_CharT, _Traits>::narrow(_CharT __c, char __default) const
  108. { return __STATIC_CAST(const ctype<_CharT>*, this->_M_ctype_facet())->narrow(__c, __default); }
  109. template <class _CharT, class _Traits>
  110. inline _CharT
  111. basic_ios<_CharT, _Traits>::widen(char __c) const
  112. { return __STATIC_CAST(const ctype<_CharT>*, this->_M_ctype_facet())->widen(__c); }
  113. # if !defined (_STLP_NO_METHOD_SPECIALIZATION)
  114. _STLP_TEMPLATE_NULL
  115. inline char
  116. basic_ios<char, char_traits<char> >::narrow(char __c, char) const
  117. {
  118. return __c;
  119. }
  120. _STLP_TEMPLATE_NULL
  121. inline char
  122. basic_ios<char, char_traits<char> >::widen(char __c) const
  123. {
  124. return __c;
  125. }
  126. # endif /* _STLP_NO_METHOD_SPECIALIZATION */
  127. # if defined (_STLP_USE_TEMPLATE_EXPORT)
  128. _STLP_EXPORT_TEMPLATE_CLASS basic_ios<char, char_traits<char> >;
  129. # if ! defined (_STLP_NO_WCHAR_T)
  130. _STLP_EXPORT_TEMPLATE_CLASS basic_ios<wchar_t, char_traits<wchar_t> >;
  131. # endif
  132. # endif /* _STLP_USE_TEMPLATE_EXPORT */
  133. _STLP_END_NAMESPACE
  134. #if defined (_STLP_EXPOSE_STREAM_IMPLEMENTATION) && !defined (_STLP_LINK_TIME_INSTANTIATION)
  135. # include <stl/_ios.c>
  136. #endif
  137. #endif /* _STLP_IOS */
  138. // Local Variables:
  139. // mode:C++
  140. // End: