File buffer using the the memory mapped mechanism.
More...
#include <btkBinaryFileStream_mmfstream.h>
|
mmfilebuf * | close () |
|
const char * | data () const |
|
bool | is_eob () const |
|
bool | is_open () const |
|
| mmfilebuf () |
|
mmfilebuf * | open (const char *s, std::ios_base::openmode mode) |
|
std::streampos | pubseekoff (std::streamoff off, std::ios_base::seekdir way, std::ios_base::openmode which=std::ios_base::in|std::ios_base::out) |
|
std::streampos | pubseekpos (std::streampos pos, std::ios_base::openmode which=std::ios_base::in|std::ios_base::out) |
|
std::streamsize | sgetn (char *s, std::streamsize n) |
|
std::streamsize | size () const |
|
std::streamsize | sputn (const char *s, std::streamsize n) |
|
bool | writemode () const |
|
| ~mmfilebuf () |
|
|
mmfilebuf * | mapfile () |
|
mmfilebuf * | resizemap () |
|
std::streampos | seekoff (std::streamoff off, std::ios_base::seekdir way, std::ios_base::openmode which=std::ios_base::in|std::ios_base::out) |
|
std::streampos | seekpos (std::streampos pos, std::ios_base::openmode which=std::ios_base::in|std::ios_base::out) |
|
File buffer using the the memory mapped mechanism.
This class is a low level class used by the class BinaryFileStream when possible (if the OS supports it). It is not advised to use this class directly even if the direct access to the buffer can speed the reading of a file (compared to the use of the class BinaryFileStream).
btk::mmfilebuf::mmfilebuf |
( |
| ) |
|
|
inline |
btk::mmfilebuf::~mmfilebuf |
( |
| ) |
|
|
inline |
Destructor. Try to close the file if opened.
Close the file.
- Returns
- Return 0 is an error happened during the closing.
const char * btk::mmfilebuf::data |
( |
| ) |
const |
|
inline |
Returns directly the content of the buffer.
int btk::mmfilebuf::granularity |
( |
| ) |
|
|
staticprotected |
Return the size of block of memory.
bool btk::mmfilebuf::is_eob |
( |
| ) |
const |
|
inline |
Check if the position of the pointer on the data is at the end of the buffer.
bool btk::mmfilebuf::is_open |
( |
| ) |
const |
|
inline |
Return true if the file is opened.
Try to map the file into the memory.
- Returns
- Returns 0 if an error occured.
mmfilebuf * btk::mmfilebuf::open |
( |
const char * |
s, |
|
|
std::ios_base::openmode |
mode |
|
) |
| |
Open the file with the given filename s and the options mode. From the given options, the option binary is everytime append as this buffer is only for binary file.
std::streampos btk::mmfilebuf::pubseekoff |
( |
std::streamoff |
off, |
|
|
std::ios_base::seekdir |
way, |
|
|
std::ios_base::openmode |
which = std::ios_base::in | std::ios_base::out |
|
) |
| |
|
inline |
Sets internal position pointer to relative position.
- Returns
- The new position value of the modified position pointer.
std::streampos btk::mmfilebuf::pubseekpos |
( |
std::streampos |
pos, |
|
|
std::ios_base::openmode |
which = std::ios_base::in | std::ios_base::out |
|
) |
| |
|
inline |
Sets internal position pointer to absolute position
- Returns
- The new position value of the modified position pointer.
Try to resize the map to be able to extract more data from the file.
- Returns
- Returns 0 if an error occured.
std::streampos btk::mmfilebuf::seekoff |
( |
std::streamoff |
off, |
|
|
std::ios_base::seekdir |
way, |
|
|
std::ios_base::openmode |
which = std::ios_base::in | std::ios_base::out |
|
) |
| |
|
protected |
Sets internal position pointer to relative position.
- Returns
- The new position value of the modified position pointer. Errors are expected to be signaled by an invalid position value, like -1.
std::streampos btk::mmfilebuf::seekpos |
( |
std::streampos |
pos, |
|
|
std::ios_base::openmode |
which = std::ios_base::in | std::ios_base::out |
|
) |
| |
|
protected |
Sets internal position pointer to absolute position
- Returns
- The new position value of the modified position pointer. In case of error, the value returned shall be an invalid position, like -1.
std::streamsize btk::mmfilebuf::sgetn |
( |
char * |
s, |
|
|
std::streamsize |
n |
|
) |
| |
Get sequence of characters
- Returns
- The number of characters gotten, returned as a value of type streamsize.
std::streamsize btk::mmfilebuf::size |
( |
| ) |
const |
|
inline |
Returns the size of the buffer.
std::streamsize btk::mmfilebuf::sputn |
( |
const char * |
s, |
|
|
std::streamsize |
n |
|
) |
| |
Write a sequence of characters
- Returns
- The number of characters written, returned as a value of type streamsize.
bool btk::mmfilebuf::writemode |
( |
| ) |
const |
|
inline |
Check if this file buffer is in write mode or not.