#include <DataIO.h>
Inheritance diagram for BMallocIO:

Write() or WriteAt(). On subsequent calls, BMallocIO makes sure enough memory is allocated to hold all the data you intend to write, reallocating it if necessary. Memory is allocated in multiples of a block size that you can set.
Public Member Functions | |
| BMallocIO () | |
| BMallocIO (const BMallocIO &) | |
| virtual | ~BMallocIO () |
| BMallocIO & | operator= (const BMallocIO &) |
| bool | operator< (const BMallocIO &) const |
| bool | operator<= (const BMallocIO &) const |
| bool | operator== (const BMallocIO &) const |
| bool | operator!= (const BMallocIO &) const |
| bool | operator>= (const BMallocIO &) const |
| bool | operator> (const BMallocIO &) const |
| virtual ssize_t | ReadAt (off_t pos, void *buffer, size_t size) |
| virtual ssize_t | WriteAt (off_t pos, const void *buffer, size_t size) |
| virtual off_t | Seek (off_t pos, uint32 seek_mode) |
| virtual off_t | Position () const |
| virtual status_t | SetSize (off_t size) |
| void | SetBlockSize (size_t blocksize) |
| const void * | Buffer () const |
| size_t | BufferLength () const |
| const char * | AsString () const |
| int | Compare (const BMallocIO &) const |
|
|
The BMallocIO constructor creates an empty object and sets the default block size to 256 bytes. The constructor doesn't allocate any memory; memory is allocated when you first write to the object or when you call SetSize() to set the amount of memory. |
|
|
Copy constructor. |
|
|
The BMallocIO destructor frees all memory that was allocated by the object. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Implements BPositionIO. |
|
||||||||||||||||
|
Reads up to size bytes of data from the object and copies it into the buffer. Returns the actual number of bytes placed in the buffer. The data is read beginning at the pos offset. This function doesn't read beyond the end of the data. If there are fewer than size of data available at the pos offset, it reads only through the last data byte and returns a smaller number than numBytes. If pos is out of range, it returns 0. Implements BPositionIO. |
|
||||||||||||
|
Sets the position in the data buffer where the Read() and Write() functions (inherited from BPositionIO) begin reading and writing. How the pos argument is understood depends on the seek_mode flag. There are three possible modes:
Attempts to seek beyond the end of allocated memory are legal: When Write() is subsequently called, the object updates its conception of where the data ends to bring the current position within range. If necessary, enough memory will be allocated to accommodate any data added at the current position.
Implements BPositionIO. |
|
|
Sets the size of the memory blocks that the BMallocIO object deals with. The object allocates memory in multiples of the block size. The default is 256 bytes. |
|
|
Sets the size of allocated memory to size (modulo the block size). Shrinking the buffer should always be successful ( Reimplemented from BPositionIO. |
|
||||||||||||||||
|
Copies size bytes of data from buffer into the object's data beginning at pos.
A successful WriteAt() always returns size - WriteAt() reallocates the buffer (in multiples of the block size) if it needs more room. If the reallocation fails, this function returns Implements BPositionIO. |