19e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project/* 29e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * A C++ I/O streams interface to the zlib gz* functions 39e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * 49e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * by Ludwig Schwardt <schwardt@sun.ac.za> 59e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * original version by Kevin Ruland <kevin@rodin.wustl.edu> 69e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * 79e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * This version is standard-compliant and compatible with gcc 3.x. 89e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project */ 99e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project 109e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project#ifndef ZFSTREAM_H 119e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project#define ZFSTREAM_H 129e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project 139e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project#include <istream> // not iostream, since we don't need cin/cout 149e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project#include <ostream> 159e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project#include "zlib.h" 169e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project 179e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project/*****************************************************************************/ 189e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project 199e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project/** 209e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * @brief Gzipped file stream buffer class. 219e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * 229e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * This class implements basic_filebuf for gzipped files. It doesn't yet support 239e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * seeking (allowed by zlib but slow/limited), putback and read/write access 249e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * (tricky). Otherwise, it attempts to be a drop-in replacement for the standard 259e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * file streambuf. 269e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project*/ 279e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Projectclass gzfilebuf : public std::streambuf 289e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project{ 299e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Projectpublic: 309e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project // Default constructor. 319e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project gzfilebuf(); 329e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project 339e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project // Destructor. 349e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project virtual 359e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project ~gzfilebuf(); 369e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project 379e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project /** 389e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * @brief Set compression level and strategy on the fly. 399e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * @param comp_level Compression level (see zlib.h for allowed values) 409e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * @param comp_strategy Compression strategy (see zlib.h for allowed values) 419e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * @return Z_OK on success, Z_STREAM_ERROR otherwise. 429e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * 439e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * Unfortunately, these parameters cannot be modified separately, as the 449e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * previous zfstream version assumed. Since the strategy is seldom changed, 459e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * it can default and setcompression(level) then becomes like the old 469e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * setcompressionlevel(level). 479e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project */ 489e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project int 499e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project setcompression(int comp_level, 509e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project int comp_strategy = Z_DEFAULT_STRATEGY); 519e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project 529e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project /** 539e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * @brief Check if file is open. 549e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * @return True if file is open. 559e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project */ 569e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project bool 579e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project is_open() const { return (file != NULL); } 589e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project 599e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project /** 609e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * @brief Open gzipped file. 619e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * @param name File name. 629e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * @param mode Open mode flags. 639e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * @return @c this on success, NULL on failure. 649e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project */ 659e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project gzfilebuf* 669e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project open(const char* name, 679e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project std::ios_base::openmode mode); 689e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project 699e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project /** 709e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * @brief Attach to already open gzipped file. 719e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * @param fd File descriptor. 729e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * @param mode Open mode flags. 739e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * @return @c this on success, NULL on failure. 749e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project */ 759e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project gzfilebuf* 769e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project attach(int fd, 779e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project std::ios_base::openmode mode); 789e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project 799e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project /** 809e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * @brief Close gzipped file. 819e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * @return @c this on success, NULL on failure. 829e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project */ 839e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project gzfilebuf* 849e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project close(); 859e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project 869e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Projectprotected: 879e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project /** 889e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * @brief Convert ios open mode int to mode string used by zlib. 899e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * @return True if valid mode flag combination. 909e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project */ 919e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project bool 929e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project open_mode(std::ios_base::openmode mode, 939e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project char* c_mode) const; 949e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project 959e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project /** 969e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * @brief Number of characters available in stream buffer. 979e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * @return Number of characters. 989e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * 999e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * This indicates number of characters in get area of stream buffer. 1009e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * These characters can be read without accessing the gzipped file. 1019e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project */ 1029e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project virtual std::streamsize 1039e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project showmanyc(); 1049e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project 1059e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project /** 1069e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * @brief Fill get area from gzipped file. 1079e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * @return First character in get area on success, EOF on error. 1089e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * 1099e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * This actually reads characters from gzipped file to stream 1109e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * buffer. Always buffered. 1119e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project */ 1129e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project virtual int_type 1139e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project underflow(); 1149e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project 1159e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project /** 1169e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * @brief Write put area to gzipped file. 1179e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * @param c Extra character to add to buffer contents. 1189e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * @return Non-EOF on success, EOF on error. 1199e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * 1209e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * This actually writes characters in stream buffer to 1219e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * gzipped file. With unbuffered output this is done one 1229e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * character at a time. 1239e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project */ 1249e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project virtual int_type 1259e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project overflow(int_type c = traits_type::eof()); 1269e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project 1279e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project /** 1289e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * @brief Installs external stream buffer. 1299e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * @param p Pointer to char buffer. 1309e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * @param n Size of external buffer. 1319e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * @return @c this on success, NULL on failure. 1329e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * 1339e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * Call setbuf(0,0) to enable unbuffered output. 1349e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project */ 1359e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project virtual std::streambuf* 1369e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project setbuf(char_type* p, 1379e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project std::streamsize n); 1389e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project 1399e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project /** 1409e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * @brief Flush stream buffer to file. 1419e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * @return 0 on success, -1 on error. 1429e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * 1439e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * This calls underflow(EOF) to do the job. 1449e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project */ 1459e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project virtual int 1469e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project sync(); 1479e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project 1489e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project// 1499e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project// Some future enhancements 1509e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project// 1519e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project// virtual int_type uflow(); 1529e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project// virtual int_type pbackfail(int_type c = traits_type::eof()); 1539e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project// virtual pos_type 1549e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project// seekoff(off_type off, 1559e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project// std::ios_base::seekdir way, 1569e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project// std::ios_base::openmode mode = std::ios_base::in|std::ios_base::out); 1579e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project// virtual pos_type 1589e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project// seekpos(pos_type sp, 1599e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project// std::ios_base::openmode mode = std::ios_base::in|std::ios_base::out); 1609e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project 1619e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Projectprivate: 1629e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project /** 1639e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * @brief Allocate internal buffer. 1649e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * 1659e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * This function is safe to call multiple times. It will ensure 1669e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * that a proper internal buffer exists if it is required. If the 1679e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * buffer already exists or is external, the buffer pointers will be 1689e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * reset to their original state. 1699e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project */ 1709e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project void 1719e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project enable_buffer(); 1729e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project 1739e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project /** 1749e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * @brief Destroy internal buffer. 1759e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * 1769e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * This function is safe to call multiple times. It will ensure 1779e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * that the internal buffer is deallocated if it exists. In any 1789e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * case, it will also reset the buffer pointers. 1799e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project */ 1809e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project void 1819e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project disable_buffer(); 1829e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project 1839e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project /** 1849e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * Underlying file pointer. 1859e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project */ 1869e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project gzFile file; 1879e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project 1889e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project /** 1899e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * Mode in which file was opened. 1909e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project */ 1919e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project std::ios_base::openmode io_mode; 1929e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project 1939e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project /** 1949e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * @brief True if this object owns file descriptor. 1959e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * 1969e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * This makes the class responsible for closing the file 1979e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * upon destruction. 1989e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project */ 1999e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project bool own_fd; 2009e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project 2019e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project /** 2029e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * @brief Stream buffer. 2039e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * 2049e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * For simplicity this remains allocated on the free store for the 2059e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * entire life span of the gzfilebuf object, unless replaced by setbuf. 2069e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project */ 2079e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project char_type* buffer; 2089e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project 2099e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project /** 2109e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * @brief Stream buffer size. 2119e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * 2129e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * Defaults to system default buffer size (typically 8192 bytes). 2139e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * Modified by setbuf. 2149e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project */ 2159e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project std::streamsize buffer_size; 2169e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project 2179e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project /** 2189e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * @brief True if this object owns stream buffer. 2199e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * 2209e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * This makes the class responsible for deleting the buffer 2219e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * upon destruction. 2229e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project */ 2239e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project bool own_buffer; 2249e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project}; 2259e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project 2269e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project/*****************************************************************************/ 2279e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project 2289e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project/** 2299e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * @brief Gzipped file input stream class. 2309e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * 2319e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * This class implements ifstream for gzipped files. Seeking and putback 2329e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * is not supported yet. 2339e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project*/ 2349e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Projectclass gzifstream : public std::istream 2359e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project{ 2369e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Projectpublic: 2379e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project // Default constructor 2389e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project gzifstream(); 2399e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project 2409e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project /** 2419e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * @brief Construct stream on gzipped file to be opened. 2429e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * @param name File name. 2439e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * @param mode Open mode flags (forced to contain ios::in). 2449e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project */ 2459e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project explicit 2469e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project gzifstream(const char* name, 2479e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project std::ios_base::openmode mode = std::ios_base::in); 2489e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project 2499e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project /** 2509e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * @brief Construct stream on already open gzipped file. 2519e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * @param fd File descriptor. 2529e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * @param mode Open mode flags (forced to contain ios::in). 2539e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project */ 2549e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project explicit 2559e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project gzifstream(int fd, 2569e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project std::ios_base::openmode mode = std::ios_base::in); 2579e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project 2589e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project /** 2599e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * Obtain underlying stream buffer. 2609e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project */ 2619e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project gzfilebuf* 2629e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project rdbuf() const 2639e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project { return const_cast<gzfilebuf*>(&sb); } 2649e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project 2659e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project /** 2669e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * @brief Check if file is open. 2679e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * @return True if file is open. 2689e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project */ 2699e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project bool 2709e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project is_open() { return sb.is_open(); } 2719e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project 2729e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project /** 2739e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * @brief Open gzipped file. 2749e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * @param name File name. 2759e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * @param mode Open mode flags (forced to contain ios::in). 2769e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * 2779e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * Stream will be in state good() if file opens successfully; 2789e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * otherwise in state fail(). This differs from the behavior of 2799e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * ifstream, which never sets the state to good() and therefore 2809e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * won't allow you to reuse the stream for a second file unless 2819e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * you manually clear() the state. The choice is a matter of 2829e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * convenience. 2839e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project */ 2849e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project void 2859e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project open(const char* name, 2869e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project std::ios_base::openmode mode = std::ios_base::in); 2879e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project 2889e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project /** 2899e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * @brief Attach to already open gzipped file. 2909e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * @param fd File descriptor. 2919e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * @param mode Open mode flags (forced to contain ios::in). 2929e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * 2939e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * Stream will be in state good() if attach succeeded; otherwise 2949e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * in state fail(). 2959e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project */ 2969e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project void 2979e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project attach(int fd, 2989e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project std::ios_base::openmode mode = std::ios_base::in); 2999e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project 3009e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project /** 3019e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * @brief Close gzipped file. 3029e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * 3039e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * Stream will be in state fail() if close failed. 3049e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project */ 3059e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project void 3069e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project close(); 3079e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project 3089e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Projectprivate: 3099e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project /** 3109e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * Underlying stream buffer. 3119e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project */ 3129e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project gzfilebuf sb; 3139e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project}; 3149e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project 3159e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project/*****************************************************************************/ 3169e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project 3179e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project/** 3189e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * @brief Gzipped file output stream class. 3199e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * 3209e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * This class implements ofstream for gzipped files. Seeking and putback 3219e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * is not supported yet. 3229e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project*/ 3239e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Projectclass gzofstream : public std::ostream 3249e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project{ 3259e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Projectpublic: 3269e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project // Default constructor 3279e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project gzofstream(); 3289e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project 3299e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project /** 3309e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * @brief Construct stream on gzipped file to be opened. 3319e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * @param name File name. 3329e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * @param mode Open mode flags (forced to contain ios::out). 3339e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project */ 3349e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project explicit 3359e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project gzofstream(const char* name, 3369e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project std::ios_base::openmode mode = std::ios_base::out); 3379e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project 3389e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project /** 3399e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * @brief Construct stream on already open gzipped file. 3409e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * @param fd File descriptor. 3419e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * @param mode Open mode flags (forced to contain ios::out). 3429e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project */ 3439e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project explicit 3449e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project gzofstream(int fd, 3459e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project std::ios_base::openmode mode = std::ios_base::out); 3469e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project 3479e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project /** 3489e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * Obtain underlying stream buffer. 3499e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project */ 3509e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project gzfilebuf* 3519e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project rdbuf() const 3529e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project { return const_cast<gzfilebuf*>(&sb); } 3539e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project 3549e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project /** 3559e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * @brief Check if file is open. 3569e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * @return True if file is open. 3579e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project */ 3589e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project bool 3599e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project is_open() { return sb.is_open(); } 3609e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project 3619e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project /** 3629e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * @brief Open gzipped file. 3639e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * @param name File name. 3649e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * @param mode Open mode flags (forced to contain ios::out). 3659e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * 3669e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * Stream will be in state good() if file opens successfully; 3679e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * otherwise in state fail(). This differs from the behavior of 3689e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * ofstream, which never sets the state to good() and therefore 3699e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * won't allow you to reuse the stream for a second file unless 3709e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * you manually clear() the state. The choice is a matter of 3719e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * convenience. 3729e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project */ 3739e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project void 3749e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project open(const char* name, 3759e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project std::ios_base::openmode mode = std::ios_base::out); 3769e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project 3779e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project /** 3789e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * @brief Attach to already open gzipped file. 3799e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * @param fd File descriptor. 3809e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * @param mode Open mode flags (forced to contain ios::out). 3819e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * 3829e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * Stream will be in state good() if attach succeeded; otherwise 3839e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * in state fail(). 3849e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project */ 3859e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project void 3869e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project attach(int fd, 3879e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project std::ios_base::openmode mode = std::ios_base::out); 3889e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project 3899e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project /** 3909e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * @brief Close gzipped file. 3919e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * 3929e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * Stream will be in state fail() if close failed. 3939e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project */ 3949e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project void 3959e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project close(); 3969e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project 3979e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Projectprivate: 3989e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project /** 3999e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * Underlying stream buffer. 4009e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project */ 4019e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project gzfilebuf sb; 4029e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project}; 4039e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project 4049e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project/*****************************************************************************/ 4059e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project 4069e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project/** 4079e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * @brief Gzipped file output stream manipulator class. 4089e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * 4099e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * This class defines a two-argument manipulator for gzofstream. It is used 4109e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project * as base for the setcompression(int,int) manipulator. 4119e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project*/ 4129e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Projecttemplate<typename T1, typename T2> 4139e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project class gzomanip2 4149e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project { 4159e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project public: 4169e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project // Allows insertor to peek at internals 4179e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project template <typename Ta, typename Tb> 4189e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project friend gzofstream& 4199e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project operator<<(gzofstream&, 4209e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project const gzomanip2<Ta,Tb>&); 4219e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project 4229e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project // Constructor 4239e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project gzomanip2(gzofstream& (*f)(gzofstream&, T1, T2), 4249e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project T1 v1, 4259e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project T2 v2); 4269e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project private: 4279e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project // Underlying manipulator function 4289e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project gzofstream& 4299e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project (*func)(gzofstream&, T1, T2); 4309e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project 4319e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project // Arguments for manipulator function 4329e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project T1 val1; 4339e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project T2 val2; 4349e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project }; 4359e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project 4369e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project/*****************************************************************************/ 4379e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project 4389e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project// Manipulator function thunks through to stream buffer 4399e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Projectinline gzofstream& 4409e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Projectsetcompression(gzofstream &gzs, int l, int s = Z_DEFAULT_STRATEGY) 4419e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project{ 4429e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project (gzs.rdbuf())->setcompression(l, s); 4439e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project return gzs; 4449e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project} 4459e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project 4469e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project// Manipulator constructor stores arguments 4479e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Projecttemplate<typename T1, typename T2> 4489e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project inline 4499e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project gzomanip2<T1,T2>::gzomanip2(gzofstream &(*f)(gzofstream &, T1, T2), 4509e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project T1 v1, 4519e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project T2 v2) 4529e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project : func(f), val1(v1), val2(v2) 4539e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project { } 4549e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project 4559e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project// Insertor applies underlying manipulator function to stream 4569e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Projecttemplate<typename T1, typename T2> 4579e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project inline gzofstream& 4589e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project operator<<(gzofstream& s, const gzomanip2<T1,T2>& m) 4599e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project { return (*m.func)(s, m.val1, m.val2); } 4609e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project 4619e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project// Insert this onto stream to simplify setting of compression level 4629e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Projectinline gzomanip2<int,int> 4639e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Projectsetcompression(int l, int s = Z_DEFAULT_STRATEGY) 4649e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project{ return gzomanip2<int,int>(&setcompression, l, s); } 4659e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project 4669e38dfa2f95fce609707a0941f10af9a785288deThe Android Open Source Project#endif // ZFSTREAM_H 467