fw4spl
RawZ.cpp
1 /* ***** BEGIN LICENSE BLOCK *****
2  * FW4SPL - Copyright (C) IRCAD, 2009-2016.
3  * Distributed under the terms of the GNU Lesser General Public License (LGPL) as
4  * published by the Free Software Foundation.
5  * ****** END LICENSE BLOCK ****** */
6 
7 #include "fwMemory/stream/in/RawZ.hpp"
8 
9 #include <fwCore/macros.hpp>
10 
11 #include <boost/filesystem/fstream.hpp>
12 #include <boost/filesystem/path.hpp>
13 #include <boost/iostreams/filter/gzip.hpp>
14 #include <boost/iostreams/filtering_stream.hpp>
15 
16 namespace fwMemory
17 {
18 namespace stream
19 {
20 namespace in
21 {
22 
23 struct FilteringStream : ::boost::iostreams::filtering_istream
24 {
25 
27  {
28  try
29  {
30  this->reset();
31  }
32  catch (...)
33  {
34  }
35  }
36 
37  SPTR(void) heldStream;
38 };
39 
40 SPTR(std::istream) RawZ::get()
41 {
42  SPTR(::boost::filesystem::ifstream) fs
43  = std::make_shared< ::boost::filesystem::ifstream>(m_path, std::ios::in|std::ios::binary);
44 
45  SPTR(FilteringStream) filter = std::make_shared< FilteringStream >();
46 
47  filter->heldStream = fs;
48 
49  filter->push(::boost::iostreams::gzip_decompressor());
50  filter->push(*fs);
51 
52  return filter;
53 }
54 
55 } // namespace in
56 } // namespace stream
57 } // namespace fwMemory
58 
#define SPTR(_cls_)
The namespace fwMemory contains tools to manage memory. Use for dump.
Definition: SReader.hpp:20
This file defines fwCore base macros.