17 #ifndef COM_BORA_SOFTWARE__BALAU_UTIL__COMPRESSION 18 #define COM_BORA_SOFTWARE__BALAU_UTIL__COMPRESSION 30 #include <boost/iostreams/filtering_stream.hpp> 47 boost::filesystem::ofstream out(output.
getEntry(), std::ios::binary);
48 boost::iostreams::filtering_streambuf<boost::iostreams::output> filter;
49 filter.push(boost::iostreams::gzip_compressor());
51 boost::filesystem::ifstream in(input.
getEntry(), std::ios::binary);
52 boost::iostreams::copy(in, filter);
62 boost::filesystem::ofstream out(output.
getEntry(), std::ios::binary);
63 boost::iostreams::filtering_streambuf<boost::iostreams::output> filter;
64 filter.push(boost::iostreams::gzip_compressor());
66 std::istringstream in(input, std::ios::binary);
67 boost::iostreams::copy(in, filter);
77 boost::filesystem::ofstream out(output.
getEntry(), std::ios::binary);
78 boost::iostreams::filtering_streambuf<boost::iostreams::output> filter;
79 filter.push(boost::iostreams::gzip_compressor());
81 boost::iostreams::copy(input, filter);
91 boost::filesystem::ifstream in(input.
getEntry(), std::ios::binary);
92 boost::iostreams::filtering_streambuf<boost::iostreams::input> filter;
93 filter.push(boost::iostreams::gzip_decompressor());
95 boost::filesystem::ofstream out(output.
getEntry(), std::ios::binary);
96 boost::iostreams::copy(filter, out);
109 boost::filesystem::ifstream in(input.
getEntry(), std::ios::binary);
110 boost::iostreams::filtering_streambuf<boost::iostreams::input> filter;
111 filter.push(boost::iostreams::gzip_decompressor());
113 std::ostringstream out(std::ios::binary);
114 boost::iostreams::copy(filter, out);
125 boost::filesystem::ifstream inputStream(input.
getEntry(), std::ios::binary);
126 stream = std::make_unique<boost::iostreams::filtering_istream>();
127 auto * filterStream =
static_cast<boost::iostreams::filtering_istream *
>(stream.get());
128 filterStream->push(boost::iostreams::gzip_decompressor());
129 filterStream->push(inputStream);
136 GZip & operator = (
const GZip &) =
delete;
143 #endif // COM_BORA_SOFTWARE__BALAU_UTIL__COMPRESSION static void gunzip(const Resource::File &input, std::unique_ptr< std::istream > &stream)
Get an input stream of the uncompressed contents of the specified gzipped input file.
Definition: Compression.hpp:124
static void gunzip(const Resource::File &input, std::string &output)
Gunzip the specified file to a string.
Definition: Compression.hpp:108
A file on the local file system.
The root Balau namespace.
Definition: ApplicationConfiguration.hpp:23
static void gzip(std::istream &input, const Resource::File &output)
Gzip the supplied input stream to the specified output file.
Definition: Compression.hpp:76
static void gunzip(const Resource::File &input, const Resource::File &output)
Gunzip the specified input file to the specified output file.
Definition: Compression.hpp:90
boost::filesystem::directory_entry getEntry() const
Get the underlying directory entry for this file URI.
Definition: File.hpp:400
static void gzip(const Resource::File &input, const Resource::File &output)
Gzip the specified input file to the specified output file.
Definition: Compression.hpp:46
static void gzip(const std::string &input, const Resource::File &output)
Gzip the supplied string to the specified output file.
Definition: Compression.hpp:61
A file on the local file system.
Definition: File.hpp:35
GZip compression utilities.
Definition: Compression.hpp:39
Balau exceptions for resources.