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;
88 return ::gzread(m_fp,
buf,
len);
97 const char*
error(
int* errnum) {
98 return ::gzerror(m_fp, errnum);
114template <
class T,
class Items>
116 return ::gzread(zs.
fp(), x, items*
sizeof(
T));
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;
221 return ::gzflush(m_fp, _flush);
231 return ::gzerror(m_fp, errnum);
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;
263template <
class T,
class Items>
265 return ::gzwrite(zs.
fp(), (
voidp) x, items*
sizeof(
T));
278 val.byte = 255; val.word =
::strlen(x);
279 if (val.word < 255) zs < (val.byte = val.word);
294 return zs < (
const char*) x;
izstream(const char *name)
void open(const char *name)
const char * error(int *errnum)
int read(void *buf, size_t len)
int write(const void *buf, size_t len)
void open(FILE *fp, int level=Z_DEFAULT_COMPRESSION)
ozstream(FILE *fp, int level=Z_DEFAULT_COMPRESSION)
void open(const char *name, int level=Z_DEFAULT_COMPRESSION)
ozstream(const char *name, int level=Z_DEFAULT_COMPRESSION)
const char * error(int *errnum)
zstringlen(class izstream &)
int ZEXPORT gzclose(gzFile file)
gzFile ZEXPORT gzopen(char *path, const char *mode) const
gzFile ZEXPORT gzdopen(int fd, const char *mode)
int ZEXPORT gzread(gzFile file, voidp buf, unsigned len)
int ZEXPORT gzwrite(gzFile file, voidpc buf, unsigned len)
size_t strlen(const char *)
#define Z_DEFAULT_COMPRESSION
ozstream & operator<(ozstream &zs, const T &x)
char * read_string(izstream &zs)
ostream & operator<<(ozstream &zs, const T &x)
#define SET_BINARY_MODE(file)
int write(ozstream &zs, const T *x, Items items)
izstream & operator>(izstream &zs, T &x)
int read(izstream &zs, T *x, Items items)