compressed_ifstream.h
Go to the documentation of this file.
00001 // Copyright (c) 2009-2010  INRIA Sophia-Antipolis (France).
00002 // All rights reserved.
00003 //
00004 //This file is part of ESBTL.
00005 //
00006 //ESBTL is free software: you can redistribute it and/or modify
00007 //it under the terms of the GNU General Public License as published by
00008 //the Free Software Foundation, either version 3 of the License, or
00009 //(at your option) any later version.
00010 //
00011 //ESBTL 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 //You should have received a copy of the GNU General Public License
00017 //along with ESBTL.  If not, see <http://www.gnu.org/licenses/>.
00018 //
00019 //
00020 //Additional permission under GNU GPL version 3 section 7
00021 //
00022 //If you modify this Library, or any covered work, by linking or
00023 //combining it with CGAL (or a modified version of that library), the
00024 //licensors of this Library grant you additional permission to convey
00025 //the resulting work. Corresponding Source for a non-source form of
00026 //such a combination shall include the source code for the parts of CGAL
00027 //used as well as that of the covered work. 
00028 //
00029 //
00030 //
00031 // Author(s)     :  Sébastien Loriot
00032 
00033 
00034 
00035 #ifndef ESBTL_COMPRESSED_IFSTREAM_H
00036 #define ESBTL_COMPRESSED_IFSTREAM_H
00037 
00038 #include <ESBTL/internal/compressed_ifstream.h>
00039 #include <boost/iostreams/filtering_stream.hpp>
00040 #include <boost/iostreams/filter/bzip2.hpp>
00041 #include <boost/iostreams/filter/gzip.hpp>
00042 #include <boost/iostreams/filter/zlib.hpp>
00043 
00045 namespace ESBTL{
00046   namespace internal{
00047   template<>
00048   class Ifstream_compress<BZIP2>
00049   {
00050     boost::iostreams::filtering_stream<boost::iostreams::input> input_;
00051   public:
00052     boost::iostreams::filtering_stream<boost::iostreams::input>&
00053     get(std::ifstream& input){
00054       input_.push(boost::iostreams::bzip2_decompressor());
00055       input_.push(input);
00056       return input_;
00057     }
00058   };
00059   
00060   template<>
00061   class Ifstream_compress<GZIP>
00062   {
00063     boost::iostreams::filtering_stream<boost::iostreams::input> input_;
00064   public:
00065     boost::iostreams::filtering_stream<boost::iostreams::input>&
00066     get(std::ifstream& input){
00067       input_.push(boost::iostreams::gzip_decompressor());
00068       input_.push(input);
00069       return input_;
00070     }
00071   };
00072   
00073 } } //ESBTL::internal
00075 #endif //ESBTL_COMPRESSED_IFSTREAM_H