device
|
 |
The os_device
class is an abstract definition of a universal device interface. This class
provides a portable, consistent interface for common I/O operations, return
codes, and error states. Although Streaming<ToolKit> relies on the
universal device interface, this <ToolKit>'s general purpose design allows
it to be used in a wide variety of situations.
Declaration
#include <ospace/io/device.h>
class os_device
Enums
enum os_device::seek_t
{
begin,
current,
end
};
Interface
Destructor
~os_device
()
Destroys this device
interface.
bad
/*
virtual */ bool bad () const
Returns true
if this device is in a bad state.
clear
/*
virtual */ void clear ()
Resets the state of this
device.
close
/*
virtual */ bool close()
Returns true
if this device successfully shuts down for all I/O operations.
eof
/*
virtual */ bool eof () const
Returns true
if this device is at EOF.
fail
/*
virtual */ bool fail () const
Returns true
if this device is in a bad state or at EOF.
good
/*
virtual */ bool good() const
Returns true
if this device is in a good state.
read
/*
virtual */ ssize_t read( const void* buffer
, size_t bytes
)
Reads the specified
number of bytes into buffer
from this device. Returns the number of bytes actually read or returns -1
if a failure occurs.
read_exactly
/*
virtual */ ssize_t read_exactly( const void* buffer
, size_t bytes
)
Reads the exact number of
bytes into buffer from
this device by performing multiple read operations if necessary. Returns the
number of bytes actually read or returns -1 if
a failure occurs.
seek
/*
virtual */ long seek( long offset ,
int seekdir )
Positions this device to offset
bytes from the position specified by seekdir
(default os_device::begin ). Returns the offset
of the new position or returns -1 if the
operation fails.
sync
/*
virtual */ bool sync()
Flushes the internal I/O
buffers of this device and returns true if
successful.
write
/*
virtual */ ssize_t write( const void* buffer
, size_t bytes
)
Writes the specified
number of bytes from buffer
to this device. Returns the number of bytes actually written or returns -1
if a failure occurs.
write_exactly
/*
virtual */ ssize_t write_exactly( const void* buffer
, size_t bytes
)
Writes the exact number
of bytes from buffer to
this device, performing multiple write operations if required by the device.
Returns the number of bytes actually written or returns -1
if a failure occurs.
Copyright©1994-2026 Recursion
Software LLC
All Rights Reserved - For use by licensed users only.