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