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 
00034 #ifndef _STDIO_FILEBUF_H
00035 #define _STDIO_FILEBUF_H 1
00036 
00037 #pragma GCC system_header
00038 
00039 #include <fstream>
00040 
00041 namespace __gnu_cxx
00042 {
00051   template<typename _CharT, typename _Traits = std::char_traits<_CharT> >
00052     class stdio_filebuf : public std::basic_filebuf<_CharT, _Traits>
00053     {
00054     public:
00055       
00056       typedef _CharT                        char_type;
00057       typedef _Traits                       traits_type;
00058       typedef typename traits_type::int_type        int_type;
00059       typedef typename traits_type::pos_type        pos_type;
00060       typedef typename traits_type::off_type        off_type;
00061       typedef std::size_t                               size_t;
00062 
00063     public:
00067       stdio_filebuf() : std::basic_filebuf<_CharT, _Traits>() {}
00068 
00078       stdio_filebuf(int __fd, std::ios_base::openmode __mode,
00079             size_t __size = static_cast<size_t>(BUFSIZ));
00080 
00091       stdio_filebuf(std::__c_file* __f, std::ios_base::openmode __mode,
00092             size_t __size = static_cast<size_t>(BUFSIZ));
00093 
00098       virtual
00099       ~stdio_filebuf();
00100 
00109       int
00110       fd() { return this->_M_file.fd(); }
00111 
00119       std::__c_file*
00120       file() { return this->_M_file.file(); }
00121     };
00122 
00123   template<typename _CharT, typename _Traits>
00124     stdio_filebuf<_CharT, _Traits>::~stdio_filebuf()
00125     { }
00126 
00127   template<typename _CharT, typename _Traits>
00128     stdio_filebuf<_CharT, _Traits>::
00129     stdio_filebuf(int __fd, std::ios_base::openmode __mode, size_t __size)
00130     {
00131       this->_M_file.sys_open(__fd, __mode);
00132       if (this->is_open())
00133     {
00134       this->_M_mode = __mode;
00135       this->_M_buf_size = __size;
00136       this->_M_allocate_internal_buffer();
00137       this->_M_reading = false;
00138       this->_M_writing = false;
00139       this->_M_set_buffer(-1);
00140     }
00141     }
00142 
00143   template<typename _CharT, typename _Traits>
00144     stdio_filebuf<_CharT, _Traits>::
00145     stdio_filebuf(std::__c_file* __f, std::ios_base::openmode __mode,
00146           size_t __size)
00147     {
00148       this->_M_file.sys_open(__f, __mode);
00149       if (this->is_open())
00150     {
00151       this->_M_mode = __mode;
00152       this->_M_buf_size = __size;
00153       this->_M_allocate_internal_buffer();
00154       this->_M_reading = false;
00155       this->_M_writing = false;
00156       this->_M_set_buffer(-1);
00157     }
00158     }
00159 } 
00160 
00161 #endif