27 #include <strstream.h> 35 # define SET_BINARY_MODE(file) setmode(fileno(file), O_BINARY) 37 # define SET_BINARY_MODE(file) 44 size_t value()
const {
return val.word; }
46 struct Val {
unsigned char byte;
size_t word; } val;
56 izstream(
const char* name) : m_fp(0) { open(name); }
65 void open(
const char* name) {
87 int read(
void* buf,
size_t len) {
97 const char*
error(
int* errnum) {
101 gzFile
fp() {
return m_fp; }
114 template <
class T,
class Items>
131 if (val.byte == 255) zs > val.word;
132 else val.word = val.byte;
141 x[len.
value()] =
'\0';
147 char* x =
new char[len.
value()+1];
149 x[len.
value()] =
'\0';
178 char mode[4] =
"wb\0";
188 char mode[4] =
"wb\0";
200 ::gzwrite(m_fp, m_os->str(), m_os->pcount());
201 delete[] m_os->str();
delete m_os; m_os = 0;
203 int r =
::gzclose(m_fp); m_fp = 0;
return r;
208 int write(
const void* buf,
size_t len) {
234 gzFile
fp() {
return m_fp; }
237 if (m_os == 0) m_os =
new ostrstream;
242 if (m_os && m_os->pcount()>0) {
243 ostrstream* oss =
new ostrstream;
244 oss->fill(m_os->fill());
245 oss->flags(m_os->flags());
246 oss->precision(m_os->precision());
247 oss->width(m_os->width());
248 ::gzwrite(m_fp, m_os->str(), m_os->pcount());
249 delete[] m_os->str();
delete m_os; m_os = oss;
263 template <
class T,
class Items>
278 val.byte = 255; val.word = ::strlen(x);
279 if (val.word < 255) zs < (val.byte = val.word);
294 return zs < (
const char*) x;
void open(const char *name, int level=Z_DEFAULT_COMPRESSION)
int gzflush(gzFile file, int flush)
#define SET_BINARY_MODE(file)
int gzread(gzFile file, voidp buf, unsigned len)
void open(FILE *fp, int level=Z_DEFAULT_COMPRESSION)
void open(const char *name)
gzFile gzopen(char *path, char *mode)
ozstream(FILE *fp, int level=Z_DEFAULT_COMPRESSION)
const char * error(int *errnum)
int write(ozstream &zs, const T *x, Items items)
izstream & operator>(izstream &zs, T &x)
ozstream & operator<(ozstream &zs, const T &x)
gzFile gzdopen(int fd, char *mode)
zstringlen(class izstream &)
int read(izstream &zs, T *x, Items items)
izstream(const char *name)
ostream & operator<<(ozstream &zs, const T &x)
const char * error(int *errnum)
int write(const void *buf, size_t len)
int read(void *buf, size_t len)
char * read_string(izstream &zs)
ozstream(const char *name, int level=Z_DEFAULT_COMPRESSION)
int gzwrite(gzFile file, voidpc buf, unsigned len)
char * gzerror(gzFile file, int *errnum)
#define Z_DEFAULT_COMPRESSION