Main Page | Namespace List | Class List | File List | Namespace Members | Class Members | Related Pages

io::Stream Struct Reference

A general stream for files and pipes. More...

#include <io.hh>

List of all members.

Public Member Functions

 Stream ()
 Create an empty stream.

 Stream (std::string file_name, std::string mode, bool allow_close=true)
 Create and open a stream (see open() for details).

 ~Stream ()
 Destroy the stream and close the possible open file if close_allowed is true.

void open (std::string file_name, std::string mode, bool allow_close=true)
 Open a stream.

void close ()
 Close the file, but only if close_allowed is true.


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.


Detailed Description

A general stream for files and pipes.


Member Function Documentation

void io::Stream::open std::string  file_name,
std::string  mode,
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 suppoerted for pipes and gzipped files.
allow_close = should the close() actually close the file


The documentation for this struct was generated from the following files:
Generated on Sat Feb 26 21:58:02 2005 for GoCam by doxygen 1.3.4