/project/jni/stlport/src/stdio_streambuf.h

https://github.com/aichunyu/FFPlayer · C Header · 101 lines · 44 code · 18 blank · 39 comment · 0 complexity · fd0cb74e353f1e361de550c7e30a32c6 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. // This header is an extension. It defines two streambufs:
  19. // stdio_istreambuf, a read-only streambuf synchronized with a C stdio
  20. // FILE object, and stdio_ostreambuf, a write-only streambuf
  21. // synchronized with a C stdio FILE object. Note that neither
  22. // stdio_istreambuf nor stdio_ostreambuf is a template; both classes
  23. // are derived from basic_streambuf<char, char_traits<char> >.
  24. // Note: the imbue() member function is a no-op. In particular, these
  25. // classes assume that codecvt<char, char, mbstate_t> is always an identity
  26. // transformation. This is true of the default locale, and of all locales
  27. // defined for the C I/O library. If you need to use a locale where
  28. // the codecvt<char, char, mbstate_t> facet performs a nontrivial
  29. // conversion, then you should use basic_filebuf<> instead of stdio_istreambuf
  30. // or stdio_ostreambuf. (If you don't understand what any of this means,
  31. // then it's not a feature you need to worry about. Locales where
  32. // codecvt<char, char, mbstate_t> does something nontrivial are a rare
  33. // corner case.)
  34. #ifndef _STLP_STDIO_STREAMBUF
  35. #define _STLP_STDIO_STREAMBUF
  36. #include <streambuf>
  37. #include <cstdio> // For FILE.
  38. _STLP_BEGIN_NAMESPACE
  39. _STLP_MOVE_TO_PRIV_NAMESPACE
  40. // Base class for features common to stdio_istreambuf and stdio_ostreambuf
  41. class stdio_streambuf_base :
  42. public basic_streambuf<char, char_traits<char> > /* FILE_basic_streambuf */ {
  43. public: // Constructor, destructor.
  44. // The argument may not be null. It must be an open file pointer.
  45. stdio_streambuf_base(FILE*);
  46. // The destructor flushes the stream, but does not close it.
  47. ~stdio_streambuf_base();
  48. protected: // Virtual functions from basic_streambuf.
  49. streambuf* setbuf(char*, streamsize);
  50. pos_type seekoff(off_type, ios_base::seekdir,
  51. ios_base::openmode
  52. = ios_base::in | ios_base::out);
  53. pos_type seekpos(pos_type,
  54. ios_base::openmode
  55. = ios_base::in | ios_base::out);
  56. int sync();
  57. protected:
  58. FILE* _M_file;
  59. };
  60. class stdio_istreambuf : public stdio_streambuf_base {
  61. public: // Constructor, destructor.
  62. stdio_istreambuf(FILE* __f) : stdio_streambuf_base(__f) {}
  63. ~stdio_istreambuf();
  64. protected: // Virtual functions from basic_streambuf.
  65. streamsize showmanyc();
  66. int_type underflow();
  67. int_type uflow();
  68. virtual int_type pbackfail(int_type c = traits_type::eof());
  69. };
  70. class stdio_ostreambuf : public stdio_streambuf_base {
  71. public: // Constructor, destructor.
  72. stdio_ostreambuf(FILE* __f) : stdio_streambuf_base(__f) {}
  73. ~stdio_ostreambuf();
  74. protected: // Virtual functions from basic_streambuf.
  75. streamsize showmanyc();
  76. int_type overflow(int_type c = traits_type::eof());
  77. };
  78. _STLP_MOVE_TO_STD_NAMESPACE
  79. _STLP_END_NAMESPACE
  80. #endif /* _STLP_STDIO_STREAMBUF */
  81. // Local Variables:
  82. // mode:C++
  83. // End: