Basic portable file type for collections of equal sized records with random access.
More...
#include <dataRecordFile.hpp>
|
| DataRecordFile () |
| Constructor. More...
|
|
| ~DataRecordFile () |
| Destructor. More...
|
|
bool | open (const std::string &filename, const Mode &mode_, unsigned int recordsize_, unsigned int headersize_=0, const void *headerstruct=0) |
| Open a file. More...
|
|
const void * | read (std::size_t fpos) |
| Read one record of the file. More...
|
|
const void * | read () |
| Read the record at the current file position of the file. More...
|
|
const void * | header () |
| Get a pointer to the header of of the file. More...
|
|
bool | append (const void *recbuf) |
| Append a record at the end of the file. More...
|
|
bool | close () |
| Close the file. More...
|
|
int | error () const |
| Get the error of the last operation to this file. More...
|
|
std::size_t | recordsize () const |
| Get the size of one record of this file. More...
|
|
std::size_t | size () |
| Get the number of records stored in the file. More...
|
|
Basic portable file type for collections of equal sized records with random access.
Implemented modes to access a data record file.
Enumerator |
---|
NoAccess |
|
SharedRead |
|
ExclusiveAppendWrite |
|
strus::DataRecordFile::DataRecordFile |
( |
| ) |
|
strus::DataRecordFile::~DataRecordFile |
( |
| ) |
|
bool strus::DataRecordFile::append |
( |
const void * |
recbuf | ) |
|
Append a record at the end of the file.
- Parameters
-
[in] | recbuf | buffer containing the record to write |
- Returns
- true, if success, false on failure (see error() for the system error code ~ errno)
bool strus::DataRecordFile::close |
( |
| ) |
|
Close the file.
- Returns
- true, if success, false on failure (see error() for the system error code ~ errno)
int strus::DataRecordFile::error |
( |
| ) |
const |
Get the error of the last operation to this file.
- Returns
- the error code (system errno)
const void* strus::DataRecordFile::header |
( |
| ) |
|
Get a pointer to the header of of the file.
- Returns
- pointer to the header, a structure of a size specified as last argument of DataRecordFile::open(..)
bool strus::DataRecordFile::open |
( |
const std::string & |
filename, |
|
|
const Mode & |
mode_, |
|
|
unsigned int |
recordsize_, |
|
|
unsigned int |
headersize_ = 0 , |
|
|
const void * |
headerstruct = 0 |
|
) |
| |
Open a file.
- Parameters
-
[in] | filename | name of the file o open |
[in] | mode_ | file mode describing the access to the file |
[in] | recordsize_ | size of one record in bytes |
[in] | headersize_ | size of the file header in bytes (0 for no header is default) |
[in] | headerstruct | header structure in case of open for write |
- Returns
- true, if success, false on failure (see error() for the system error code ~ errno)
const void* strus::DataRecordFile::read |
( |
std::size_t |
fpos | ) |
|
Read one record of the file.
- Parameters
-
[in] | fpos | index of the record to read (file position is the index multiplied with the record size) |
- Returns
- pointer to buffer read if success, (0) NULL on failure (see error() for the system error code ~ errno)
const void* strus::DataRecordFile::read |
( |
| ) |
|
Read the record at the current file position of the file.
- Returns
- pointer to buffer read if success, (0) NULL on failure (see error() for the system error code ~ errno)
std::size_t strus::DataRecordFile::recordsize |
( |
| ) |
const |
|
inline |
Get the size of one record of this file.
std::size_t strus::DataRecordFile::size |
( |
| ) |
|
Get the number of records stored in the file.
The documentation for this class was generated from the following file: