io::Stream Struct Reference

A general stream class. More...

#include <io.hh>

List of all members.

Public Member Functions

 Stream ()
 Create an empty stream.
 Stream (std::string file_name, std::string mode="r", bool allow_close=true)
 Create and open a stream (see open() for details).
 Stream (const Stream &stream)
 Copy constructor allowed only for closed streams.
 ~Stream ()
 Destroy the stream and close the possible open file if close_allowed is true.
void open (std::string file_name, std::string mode="r", bool allow_close=true)
 Open a stream.
void close ()
 Close the file, but only if close_allowed is true.
 operator FILE * ()
 Automatic typecast to FILE* structure.
bool is_open ()
 Check if stream is opened.

Public Attributes

FILE * file
 The handle for the file or pipe.
bool is_pipe
 Is the opened file pipe that must be closed with pclose.
bool close_allowed
 Should the close() function close the file.

Private Member Functions

const Streamoperator= (const Stream &stream)


Detailed Description

A general stream class.

A stream can be a file or a pipe.


Constructor & Destructor Documentation

io::Stream::Stream  ) 
 

Create an empty stream.

io::Stream::Stream std::string  file_name,
std::string  mode = "r",
bool  allow_close = true
 

Create and open a stream (see open() for details).

io::Stream::Stream const Stream stream  )  [inline]
 

Copy constructor allowed only for closed streams.

io::Stream::~Stream  ) 
 

Destroy the stream and close the possible open file if close_allowed is true.


Member Function Documentation

void io::Stream::close  ) 
 

Close the file, but only if close_allowed is true.

bool io::Stream::is_open  )  [inline]
 

Check if stream is opened.

void io::Stream::open std::string  file_name,
std::string  mode = "r",
bool  allow_close = true
 

Open a stream.

If the file name ends with ".gz" a pipe through gzip is created. If the file name ends with "|", an input pipe is created. In that case, the mode must be "r". If the file name starts with "|", an output pipe is created. If the stream was open already, close the previous stream before opening a new one.

Parameters:
file_name = the file or pipe to open
mode = the mode for the file. See the man page of fopen() for more details. Possible values are "r", "r+", "w", "w+", "a", "a+", but only "r" and "w" are supported for pipes and gzipped files.
allow_close = should the close() actually close the file

io::Stream::operator FILE *  )  [inline]
 

Automatic typecast to FILE* structure.

const Stream& io::Stream::operator= const Stream stream  )  [inline, private]
 


Member Data Documentation

bool io::Stream::close_allowed
 

Should the close() function close the file.

FILE* io::Stream::file
 

The handle for the file or pipe.

bool io::Stream::is_pipe
 

Is the opened file pipe that must be closed with pclose.


The documentation for this struct was generated from the following files:
Generated on Mon Jan 8 15:51:04 2007 for bit by  doxygen 1.4.6