Inheritance diagram for BPositionIO:

Public Member Functions | |
| BPositionIO () | |
| This constructor does nothing. | |
| virtual status_t | GetSize (off_t *size) const |
| Get the size of the object or data. | |
| virtual off_t | Position () const=0 |
| Pure virtual to return the current position of the cursor. | |
| virtual ssize_t | Read (void *buffer, size_t size) |
| Read data from current position. | |
| virtual ssize_t | ReadAt (off_t position, void *buffer, size_t size)=0 |
| Pure virtual to read data from a certain position. | |
| virtual off_t | Seek (off_t position, uint32 seekMode)=0 |
| Pure virtual to move the cursor to a certain position. | |
| virtual status_t | SetSize (off_t size) |
| Set the size of the object or data. | |
| virtual ssize_t | Write (const void *buffer, size_t size) |
| Write data to the current position. | |
| virtual ssize_t | WriteAt (off_t position, const void *buffer, size_t size)=0 |
| Pure virtual to write data to a certain position. | |
| virtual | ~BPositionIO () |
| This destructor does nothing. | |
The interface of this object applies to objects or data that allows position-aware reading and writing of data. Classes that derive from this class should at least reimplement ReadAt(), WriteAt(), Seek(), Position(), SetSize() and GetSize() methods.
A good example of a form of data that can derive from this object, are files. The BFile class derives from BPositionIO and provides this interface to files. If your object or data only supports linear reading and writing, consider deriving from the baseclass BDataIO.
A final note, from BDataIO this class inherits Read() and Write(). The default implementation is to read or write the data at the current position indicated by Position(). Reimplement the methods if you require a different behaviour.
| status_t BPositionIO::GetSize | ( | off_t * | size | ) | const [virtual] |
Get the size of the object or data.
The default implementation uses Seek() with the SEEK_END flag to determine the size of the buffer. If your data or object has a different way of determining size, reimplement this method.
Please check that NULL is not passed into size if you reimplement it in your class.
| [out] | size | The size of the object is put into this parameter. |
B_OK on success or an error code on error. | off_t BPositionIO::Position | ( | ) | const [pure virtual] |
| ssize_t BPositionIO::Read | ( | void * | buffer, | |
| size_t | size | |||
| ) | [virtual] |
Read data from current position.
This method is derived from BDataIO. The default implementation reads data from the current position of the cursor, pointed at by Position(). If you require different behaviour, please look at BDataIO::Read() for what is expected of this method.
Implements BDataIO.
| ssize_t BPositionIO::ReadAt | ( | off_t | position, | |
| void * | buffer, | |||
| size_t | size | |||
| ) | [pure virtual] |
| off_t BPositionIO::Seek | ( | off_t | position, | |
| uint32 | seekMode | |||
| ) | [pure virtual] |
Pure virtual to move the cursor to a certain position.
Your implementation should move the position of the cursor to the provided point. What this actually means, depends on your object or data.
| position | An integer that defines a position. | |
| seekMode | You will get one of the following values:
|
| status_t BPositionIO::SetSize | ( | off_t | size | ) | [virtual] |
| ssize_t BPositionIO::Write | ( | const void * | buffer, | |
| size_t | size | |||
| ) | [virtual] |
Write data to the current position.
This method is derived from BDataIO. The default implementation writes data to the current position of the cursor, pointed at by Position(). If you require different behaviour, please look at BDataIO::Write() for what is expected of this method.
Implements BDataIO.
| ssize_t BPositionIO::WriteAt | ( | off_t | position, | |
| const void * | buffer, | |||
| size_t | size | |||
| ) | [pure virtual] |