Rizin
unix-like reverse engineering framework and cli tools
gzofstream Class Reference

Gzipped file output stream class. More...

#include <zfstream.h>

Inheritance diagram for gzofstream:
gzfilestream_common

Public Member Functions

 gzofstream ()
 
 gzofstream (const char *name, int io_mode=ios::out)
 
 gzofstream (int fd, int io_mode=ios::out)
 
virtual ~gzofstream ()
 
 gzofstream ()
 
 gzofstream (const char *name, std::ios_base::openmode mode=std::ios_base::out)
 Construct stream on gzipped file to be opened. More...
 
 gzofstream (int fd, std::ios_base::openmode mode=std::ios_base::out)
 Construct stream on already open gzipped file. More...
 
gzfilebufrdbuf () const
 
bool is_open ()
 Check if file is open. More...
 
void open (const char *name, std::ios_base::openmode mode=std::ios_base::out)
 Open gzipped file. More...
 
void attach (int fd, std::ios_base::openmode mode=std::ios_base::out)
 Attach to already open gzipped file. More...
 
void close ()
 Close gzipped file. More...
 
- Public Member Functions inherited from gzfilestream_common
virtual ~gzfilestream_common ()
 
void attach (int fd, int io_mode)
 
void open (const char *name, int io_mode)
 
void close ()
 

Private Attributes

gzfilebuf sb
 

Additional Inherited Members

- Protected Member Functions inherited from gzfilestream_common
 gzfilestream_common ()
 

Detailed Description

Gzipped file output stream class.

This class implements ofstream for gzipped files. Seeking and putback is not supported yet.

Definition at line 80 of file zfstream.h.

Constructor & Destructor Documentation

◆ gzofstream() [1/6]

gzofstream::gzofstream ( )

Definition at line 311 of file zfstream.cpp.

311  :
313 {
314  clear( ios::badbit );
315 }
gzfilebuf * rdbuf()
Definition: zfstream.cpp:286

◆ gzofstream() [2/6]

gzofstream::gzofstream ( const char *  name,
int  io_mode = ios::out 
)

Definition at line 317 of file zfstream.cpp.

317  :
319 {
320  gzfilestream_common::open( name, io_mode );
321 }
void open(const char *name, int io_mode)
Definition: zfstream.cpp:270
Definition: z80asm.h:102

References gzfilestream_common::open().

◆ gzofstream() [3/6]

gzofstream::gzofstream ( int  fd,
int  io_mode = ios::out 
)

Definition at line 323 of file zfstream.cpp.

323  :
325 {
326  gzfilestream_common::attach( fd, io_mode );
327 }
void attach(int fd, int io_mode)
Definition: zfstream.cpp:261
static const z80_opcode fd[]
Definition: z80_tab.h:997

References gzfilestream_common::attach(), and fd.

◆ ~gzofstream()

gzofstream::~gzofstream ( )
virtual

Definition at line 329 of file zfstream.cpp.

329 { }

◆ gzofstream() [4/6]

gzofstream::gzofstream ( )

◆ gzofstream() [5/6]

gzofstream::gzofstream ( const char *  name,
std::ios_base::openmode  mode = std::ios_base::out 
)
explicit

Construct stream on gzipped file to be opened.

Parameters
nameFile name.
modeOpen mode flags (forced to contain ios::out).

Definition at line 434 of file zfstream.cc.

436 : std::ostream(NULL), sb()
437 {
438  this->init(&sb);
439  this->open(name, mode);
440 }
gzfilebuf sb
Definition: zfstream.h:401
void open(const char *name, std::ios_base::openmode mode=std::ios_base::out)
Open gzipped file.
Definition: zfstream.cc:453
#define NULL
Definition: cris-opc.c:27
const char int mode
Definition: ioapi.h:137
bool init
Definition: core.c:77

References init, open(), and sb.

◆ gzofstream() [6/6]

gzofstream::gzofstream ( int  fd,
std::ios_base::openmode  mode = std::ios_base::out 
)
explicit

Construct stream on already open gzipped file.

Parameters
fdFile descriptor.
modeOpen mode flags (forced to contain ios::out).

Definition at line 443 of file zfstream.cc.

445 : std::ostream(NULL), sb()
446 {
447  this->init(&sb);
448  this->attach(fd, mode);
449 }
void attach(int fd, std::ios_base::openmode mode=std::ios_base::out)
Attach to already open gzipped file.
Definition: zfstream.cc:464

References attach(), init, and sb.

Member Function Documentation

◆ attach()

void gzofstream::attach ( int  fd,
std::ios_base::openmode  mode = std::ios_base::out 
)

Attach to already open gzipped file.

Parameters
fdFile descriptor.
modeOpen mode flags (forced to contain ios::out).

Stream will be in state good() if attach succeeded; otherwise in state fail().

Definition at line 464 of file zfstream.cc.

466 {
468  this->setstate(std::ios_base::failbit);
469  else
470  this->clear();
471 }
const lzma_allocator const uint8_t size_t uint8_t * out
Definition: block.h:528
gzfilebuf * attach(int file_descriptor, int io_mode)
Definition: zfstream.cpp:60

References gzfilebuf::attach(), fd, out, and sb.

Referenced by gzofstream().

◆ close()

void gzofstream::close ( )

Close gzipped file.

Stream will be in state fail() if close failed.

Definition at line 475 of file zfstream.cc.

476 {
477  if (!sb.close())
478  this->setstate(std::ios_base::failbit);
479 }
gzfilebuf * close()
Definition: zfstream.cpp:102

References gzfilebuf::close(), and sb.

Referenced by main().

◆ is_open()

bool gzofstream::is_open ( )
inline

Check if file is open.

Returns
True if file is open.

Definition at line 359 of file zfstream.h.

359 { return sb.is_open(); }
int is_open() const
Definition: zfstream.h:22

References gzfilebuf::is_open(), and sb.

◆ open()

void gzofstream::open ( const char *  name,
std::ios_base::openmode  mode = std::ios_base::out 
)

Open gzipped file.

Parameters
nameFile name.
modeOpen mode flags (forced to contain ios::out).

Stream will be in state good() if file opens successfully; otherwise in state fail(). This differs from the behavior of ofstream, which never sets the state to good() and therefore won't allow you to reuse the stream for a second file unless you manually clear() the state. The choice is a matter of convenience.

Definition at line 453 of file zfstream.cc.

455 {
457  this->setstate(std::ios_base::failbit);
458  else
459  this->clear();
460 }
gzfilebuf * open(const char *name, int io_mode)
Definition: zfstream.cpp:18

References gzfilebuf::open(), out, and sb.

Referenced by gzofstream().

◆ rdbuf()

gzfilebuf* gzofstream::rdbuf ( ) const
inline

Obtain underlying stream buffer.

Definition at line 351 of file zfstream.h.

352  { return const_cast<gzfilebuf*>(&sb); }
Gzipped file stream buffer class.
Definition: zfstream.h:8

References sb.

Referenced by setcompression().

Member Data Documentation

◆ sb

gzfilebuf gzofstream::sb
private

Underlying stream buffer.

Definition at line 401 of file zfstream.h.

Referenced by attach(), close(), gzofstream(), is_open(), open(), and rdbuf().


The documentation for this class was generated from the following files: