00001 // filebuf with encoding state type -*- C++ -*- 00002 00003 // Copyright (C) 2002, 2003, 2004, 2007, 2009 Free Software Foundation, Inc. 00004 // 00005 // This file is part of the GNU ISO C++ Library. This library is free 00006 // software; you can redistribute it and/or modify it under the 00007 // terms of the GNU General Public License as published by the 00008 // Free Software Foundation; either version 3, or (at your option) 00009 // any later version. 00010 00011 // This library is distributed in the hope that it will be useful, 00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 // GNU General Public License for more details. 00015 00016 // Under Section 7 of GPL version 3, you are granted additional 00017 // permissions described in the GCC Runtime Library Exception, version 00018 // 3.1, as published by the Free Software Foundation. 00019 00020 // You should have received a copy of the GNU General Public License and 00021 // a copy of the GCC Runtime Library Exception along with this program; 00022 // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see 00023 // <http://www.gnu.org/licenses/>. 00024 00025 /** @file ext/enc_filebuf.h 00026 * This file is a GNU extension to the Standard C++ Library. 00027 */ 00028 00029 #ifndef _EXT_ENC_FILEBUF_H 00030 #define _EXT_ENC_FILEBUF_H 1 00031 00032 #include <fstream> 00033 #include <locale> 00034 #include <ext/codecvt_specializations.h> 00035 00036 _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) 00037 00038 /// class enc_filebuf. 00039 template<typename _CharT> 00040 class enc_filebuf 00041 : public std::basic_filebuf<_CharT, encoding_char_traits<_CharT> > 00042 { 00043 public: 00044 typedef encoding_char_traits<_CharT> traits_type; 00045 typedef typename traits_type::state_type state_type; 00046 typedef typename traits_type::pos_type pos_type; 00047 00048 enc_filebuf(state_type& __state) 00049 : std::basic_filebuf<_CharT, encoding_char_traits<_CharT> >() 00050 { this->_M_state_beg = __state; } 00051 00052 private: 00053 // concept requirements: 00054 // Set state type to something useful. 00055 // Something more than copyconstructible is needed here, so 00056 // require default and copy constructible + assignment operator. 00057 __glibcxx_class_requires(state_type, _SGIAssignableConcept) 00058 }; 00059 00060 _GLIBCXX_END_NAMESPACE 00061 00062 #endif