Main Page   Class Hierarchy   Alphabetical List   Compound List   Compound Members  

util::io::GeneralFile Class Reference

#include <GeneralFile.h>

Inheritance diagram for util::io::GeneralFile:

util::io::RS232 List of all members.

Detailed Description

GeneralFile is a common base class for all types of files.

As just about everything in unix is a file, this class can be used as a front-end for device and socket communications.


Public Methods

 GeneralFile (void)
 Construct a new GeneralFile object.

virtual ~GeneralFile ()
 Destroy the file object.

void write (const char *msg) throw (IOException&)
 Write a null-terminated character array to a file.

void write (const std::string &msg) throw (IOException&)
 Write a string to a file.

virtual void write (const void *msg, int len) throw (IOException&)
 Write data to a file.

void write (int msg) throw (IOException&)
void write (float msg) throw (IOException&)
std::string readLine (void) throw (IOException&)
 Read a line from a file.

virtual void * read (void *buf, int len) throw (IOException&)
 Read data from a file.

virtual void open (void) throw (IOException&)
 Open a file.

virtual void close (void) throw (IOException&)
 Close a file.


Protected Attributes

int fd
 The file descriptor.


Constructor & Destructor Documentation

util::io::GeneralFile::GeneralFile void    [inline]
 

Construct a new GeneralFile object.

By default, the file descriptor of the file will be set to 0 (stdin).


Member Function Documentation

void util::io::GeneralFile::close void    throw (IOException&) [virtual]
 

Close a file.

Exceptions:
IOException  if the file cannot be closed

Reimplemented in Socket.

virtual void util::io::GeneralFile::open void    throw (IOException&) [inline, virtual]
 

Open a file.

Exceptions:
IOException  if the file cannot be opened

Reimplemented in Socket, and util::io::RS232.

void * util::io::GeneralFile::read void *    buf,
int    len
throw (IOException&) [virtual]
 

Read data from a file.

The other read methods call this method to implement the actual read operation. It can be overridden by subclasses if needed.

Parameters:
buf  a place for the read data
len  the number of bytes to read
Returns:
buf
Exceptions:
IOException  if the read does not succeed

Reimplemented in Socket.

string util::io::GeneralFile::readLine void    throw (IOException&)
 

Read a line from a file.

This method will read bytes from a file until a newline is encountered. If the last character before the newline is carriage return (\r), it will be stripped off.

Returns:
a line read from a file
Exceptions:
IOException  if the read does not succeed

void util::io::GeneralFile::write const void *    msg,
int    len
throw (IOException&) [virtual]
 

Write data to a file.

The other write methods call this method to implement the actual write operation. It can be overridden by subclasses if needed.

Parameters:
msg  the data to be written
len  the number of bytes to write
Exceptions:
IOException  if the write does not succeed

Reimplemented in Socket.

void util::io::GeneralFile::write const std::string &    msg throw (IOException&) [inline]
 

Write a string to a file.

Exceptions:
IOException  if the write does not succeed

void util::io::GeneralFile::write const char *    msg throw (IOException&) [inline]
 

Write a null-terminated character array to a file.

The null character will not be written.

Exceptions:
IOException  if the write does not succeed


The documentation for this class was generated from the following files:
Documentation generated on 11.09.2003 with Doxygen.
The documentation is copyrighted material.
Copyright © Topi Mäenpää 2003. All rights reserved.