Inheritance diagram for BMemoryIO:

Public Member Functions | |
| BMemoryIO (const void *data, size_t length) | |
| Create a read-only object. | |
| BMemoryIO (void *data, size_t length) | |
| Create a read/write object. | |
| virtual status_t | GetSize (off_t *size) const |
| Get the size of the object or data. | |
| virtual off_t | Position () const |
| Return the current position. | |
| 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) |
| Read from a given position. | |
| virtual off_t | Seek (off_t position, uint32 seekMode) |
| Move the cursor to a given position. | |
| virtual status_t | SetSize (off_t size) |
| Resize the buffer. | |
| 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) |
| Write at a given position. | |
| virtual | ~BMemoryIO () |
| The destructor does nothing. | |
This class is used if you require access that confirms to the BPositionIO interface on memory buffers that you created. If you would like to use that interface on new buffers, have a look at BMallocIO.
This class is particularly useful if you would like to use a class or method that are written to make use of the BPositionIO interface. It might also be used for 'secure' reading and writing from buffers, since this class automatically checks the bounds of anything you might want to do.
This class reimplements the Read(), Write(), ReadAt(), Writeat(), Seek() and Position() interface from BPositionIO.
| BMemoryIO::BMemoryIO | ( | void * | data, | |
| size_t | length | |||
| ) |
Create a read/write object.
| data | A pointer to the buffer to adopt. | |
| length | The size of the buffer. |
| BMemoryIO::BMemoryIO | ( | const void * | buffer, | |
| size_t | length | |||
| ) |
Create a read-only object.
| buffer | A pointer to the const (read-only) buffer to adopt. | |
| length | The size of the buffer. |
| status_t BPositionIO::GetSize | ( | off_t * | size | ) | const [virtual, inherited] |
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. | ssize_t BPositionIO::Read | ( | void * | buffer, | |
| size_t | size | |||
| ) | [virtual, inherited] |
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 BMemoryIO::ReadAt | ( | off_t | pos, | |
| void * | buffer, | |||
| size_t | size | |||
| ) | [virtual] |
Read from a given position.
| [in] | pos | The offset where to start reading data. |
| [out] | buffer | The buffer to copy the read bytes into. |
| [in] | size | The size of the buffer. |
| B_BAD_VALUE | The position is less than zero or the buffer given on construction is invalid. |
Implements BPositionIO.
| off_t BMemoryIO::Seek | ( | off_t | position, | |
| uint32 | seek_mode | |||
| ) | [virtual] |
Move the cursor to a given position.
| position | The position to move the cursor to. | |
| seek_mode | The mode determines where the cursor is placed. Possibilities:
|
Implements BPositionIO.
| status_t BMemoryIO::SetSize | ( | off_t | size | ) | [virtual] |
Resize the buffer.
This method does not actually resize the buffer. If the new size is greater than the size of the buffer, resizing will fail. It will only succeed if the new size is less than the size of the buffer. The buffer itself will not be resized though.
This method might be useful in some cases. If the buffer is larger than the data it holds, changing the size will enable you to use the Seek() method with the flag SEEK_END and not get an error if you read or write from that position, since you actually have a buffer at the end.
| B_OK | The buffer is resized. | |
| B_NOT_ALLOWED | The buffer is read-only. | |
| B_ERROR | The size is larger than the size of the buffer. |
Reimplemented from BPositionIO.
| ssize_t BPositionIO::Write | ( | const void * | buffer, | |
| size_t | size | |||
| ) | [virtual, inherited] |
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 BMemoryIO::WriteAt | ( | off_t | pos, | |
| const void * | buffer, | |||
| size_t | size | |||
| ) | [virtual] |
Write at a given position.
| pos | The offset to write to. | |
| buffer | The buffer to copy the bytes from. | |
| size | The number of bytes to write. |
| B_NOT_ALLOWED | The object is constructed as a read-only object. | |
| B_BAD_VALUE | The position is less than zero or the buffer given on construction is invalid. |
Implements BPositionIO.