IO is the base class for binary input and output.
More...
#include <IO.h>
The IO class was designed to thread safe for reading and writing. The reading and writing functions do not have a internal file position, the offset is passed into pread() and pwrite(). This is based off the POSIX pread() and pwrite() interfaces. Unlike the libc's FILE structure the buffering is not part of the IO object. Buffering is handled by the StreamReader and the StreamWriter classes.
Definition at line 29 of file IO.h.
§ offset_type
Definition at line 36 of file IO.h.
§ close()
virtual void IO::close |
( |
void |
| ) |
|
|
pure virtual |
This method closes the IO object. open() and close() are reference counted so you must call close() the some number of times as open().
When subclassing IO, open() and close() must implement the reference counting and be thread safe because they can be called from multiple threads. close() should look something like the following:
{
m_openCount -= 1;
if (m_openCount == 0)
{
}
}
§ open()
virtual void IO::open |
( |
void |
| ) |
|
|
pure virtual |
This method opens the IO object. open() and close() are reference counted so you must call close() the some number of times as open().
When subclassing IO, open() and close() must implement the reference counting and be thread safe because they can be called from multiple threads. open() should look something like the following:
{
if (m_openCount == 0)
{
}
m_openCount += 1;
}
§ pread()
virtual size_t IO::pread |
( |
offset_type |
offset, |
|
|
void * |
buffer, |
|
|
size_t |
nbytes |
|
) |
| const |
|
pure virtual |
This method tries to read nbytes bytes at the given offset.
- Parameters
-
offset | the file offset to read from |
buffer | the destination memory location |
nbytes | the number of bytes to read |
- Returns
- the number of bytes read
§ pwrite()
virtual size_t IO::pwrite |
( |
offset_type |
offset, |
|
|
const void * |
buffer, |
|
|
size_t |
nbytes |
|
) |
| const |
|
pure virtual |
This method tries to write nbytes bytes at the given offset.
- Parameters
-
offset | the file offset to write to |
buffer | the source memory location |
nbytes | the number of bytes to write |
- Returns
- the number of bytes written
§ size()
This method returns the size of the resource.
§ truncate()
This method sets the size of the resource. If the new size is smaller the data is lost. If the new size is larger the resource padded with zeros.
- Note
- The object must be open.
§ unlink()
virtual void IO::unlink |
( |
void |
| ) |
|
|
pure virtual |
This method marks the resource for deletion when the object goes away.
Implemented in FileIO.
The documentation for this class was generated from the following file: