stdio_filebuf.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef _STDIO_FILEBUF_H
00030 #define _STDIO_FILEBUF_H 1
00031
00032 #pragma GCC system_header
00033
00034 #include <fstream>
00035
00036 _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046 template<typename _CharT, typename _Traits = std::char_traits<_CharT> >
00047 class stdio_filebuf : public std::basic_filebuf<_CharT, _Traits>
00048 {
00049 public:
00050
00051 typedef _CharT char_type;
00052 typedef _Traits traits_type;
00053 typedef typename traits_type::int_type int_type;
00054 typedef typename traits_type::pos_type pos_type;
00055 typedef typename traits_type::off_type off_type;
00056 typedef std::size_t size_t;
00057
00058 public:
00059
00060
00061
00062 stdio_filebuf() : std::basic_filebuf<_CharT, _Traits>() {}
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073 stdio_filebuf(int __fd, std::ios_base::openmode __mode,
00074 size_t __size = static_cast<size_t>(BUFSIZ));
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086 stdio_filebuf(std::__c_file* __f, std::ios_base::openmode __mode,
00087 size_t __size = static_cast<size_t>(BUFSIZ));
00088
00089
00090
00091
00092
00093 virtual
00094 ~stdio_filebuf();
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104 int
00105 fd() { return this->_M_file.fd(); }
00106
00107
00108
00109
00110
00111
00112
00113
00114 std::__c_file*
00115 file() { return this->_M_file.file(); }
00116 };
00117
00118 template<typename _CharT, typename _Traits>
00119 stdio_filebuf<_CharT, _Traits>::~stdio_filebuf()
00120 { }
00121
00122 template<typename _CharT, typename _Traits>
00123 stdio_filebuf<_CharT, _Traits>::
00124 stdio_filebuf(int __fd, std::ios_base::openmode __mode, size_t __size)
00125 {
00126 this->_M_file.sys_open(__fd, __mode);
00127 if (this->is_open())
00128 {
00129 this->_M_mode = __mode;
00130 this->_M_buf_size = __size;
00131 this->_M_allocate_internal_buffer();
00132 this->_M_reading = false;
00133 this->_M_writing = false;
00134 this->_M_set_buffer(-1);
00135 }
00136 }
00137
00138 template<typename _CharT, typename _Traits>
00139 stdio_filebuf<_CharT, _Traits>::
00140 stdio_filebuf(std::__c_file* __f, std::ios_base::openmode __mode,
00141 size_t __size)
00142 {
00143 this->_M_file.sys_open(__f, __mode);
00144 if (this->is_open())
00145 {
00146 this->_M_mode = __mode;
00147 this->_M_buf_size = __size;
00148 this->_M_allocate_internal_buffer();
00149 this->_M_reading = false;
00150 this->_M_writing = false;
00151 this->_M_set_buffer(-1);
00152 }
00153 }
00154
00155 _GLIBCXX_END_NAMESPACE
00156
00157 #endif