MRPT
1.9.9
|
#include <xSens_MT3/cmt1.h>
Public Member Functions | |
Cmt1f () | |
Default constructor, initializes all members to their default values. More... | |
~Cmt1f () | |
Destructor. More... | |
XsensResultValue | appendData (const uint32_t length, const void *data) |
Write data to the end of the file. More... | |
XsensResultValue | close (void) |
Close the file. More... | |
XsensResultValue | closeAndDelete (void) |
Close the file and delete it. More... | |
XsensResultValue | create (const char *filename) |
Open an empty file. More... | |
XsensResultValue | create (const wchar_t *filename) |
Open an empty file using a unicode path + filename. More... | |
XsensResultValue | deleteData (const CmtFilePos start, const uint32_t length) |
Delete the given data from the file. The function erases the given data from the file at the given write position. This operation may take a while to complete, but is faster than insertData. More... | |
XsensResultValue | find (const void *needle, const uint32_t needleLength, CmtFilePos &pos) |
Find a string of bytes in the file. More... | |
XsensResultValue | flushData (void) |
Flush all data to be written. This function writes any remaining data immediately and does not return until this is done. More... | |
CmtFilePos | getFileSize (void) const |
Return the size of the file. More... | |
XsensResultValue | getLastResult (void) const |
Return the result code of the last operation. More... | |
XsensResultValue | getName (char *filename) const |
Retrieve the filename that was last successfully opened. More... | |
XsensResultValue | getName (wchar_t *filename) const |
Retrieve the filename that was last successfully opened in unicode. More... | |
CmtFilePos | getReadPos (void) const |
Return the current read position. More... | |
CmtFilePos | getWritePos (void) const |
Return the current write position. More... | |
XsensResultValue | insertData (const CmtFilePos start, const uint32_t length, const void *data) |
Insert the given data into the file. The function writes the given data to the file at the current write position. This operation may take a while to complete. More... | |
bool | isOpen (void) const |
Return whether the file is open or not. More... | |
bool | isReadOnly (void) const |
Return whether the file is readonly or not. More... | |
XsensResultValue | open (const char *filename, const bool create, const bool readOnly) |
Open a file. More... | |
XsensResultValue | open (const wchar_t *filename, const bool create, const bool readOnly) |
Open a file using a unicode filename. More... | |
XsensResultValue | readData (const uint32_t maxLength, void *data, uint32_t *length) |
Read data from the file and put it into the data buffer. More... | |
XsensResultValue | readData (const uint32_t maxLength, const char terminator, void *data, uint32_t *length) |
Read data from the file and put it into the data buffer. More... | |
XsensResultValue | setReadPos (const CmtFilePos pos) |
Set the new absolute read position. More... | |
XsensResultValue | setWritePos (const CmtFilePos pos=-1) |
Set the new absolute write position. More... | |
XsensResultValue | writeData (const uint32_t length, const void *data) |
Write data to the file. More... | |
Protected Member Functions | |
void | gotoRead (void) |
Change from writing to reading mode. More... | |
void | gotoWrite (void) |
Change from reading to writing mode. More... | |
Protected Attributes | |
FILE * | m_handle |
The file handle. More... | |
CmtFilePos | m_fileSize |
Contains the size of the file. More... | |
CmtFilePos | m_readPos |
The last read position in the file. More... | |
CmtFilePos | m_writePos |
The last write position in the file. More... | |
XsensResultValue | m_lastResult |
The last result of an operation. More... | |
char | m_filename [CMT_MAX_FILENAME_LENGTH] |
Contains the name of the file that was last successfully opened. More... | |
wchar_t | m_filename_w [CMT_MAX_FILENAME_LENGTH] |
Contains the name of the file that was last successfully opened using unicode. More... | |
bool | m_isOpen |
Indicates if the file is open or not. More... | |
bool | m_unicode |
Indicates if we're using the unicode filename or the regular filename. More... | |
bool | m_reading |
Indicates whether the last operation was a read or write operation. This value is used to check whether or not a seek is required to perform a requested read or write operation. More... | |
bool | m_readOnly |
Indicates if the file was opened in read-only mode. More... | |
Private Member Functions | |
Cmt1f (const Cmt1f &ref) | |
This object cannot be copied, so this function is not implemented. More... | |
|
private |
This object cannot be copied, so this function is not implemented.
xsens::Cmt1f::Cmt1f | ( | ) |
Default constructor, initializes all members to their default values.
Definition at line 676 of file cmt1.cpp.
References m_filename, m_fileSize, m_isOpen, m_lastResult, m_reading, m_readOnly, m_readPos, m_unicode, m_writePos, and XRV_OK.
xsens::Cmt1f::~Cmt1f | ( | ) |
XsensResultValue xsens::Cmt1f::appendData | ( | const uint32_t | length, |
const void * | data | ||
) |
Write data to the end of the file.
The function writes the given data to the file at the end. The current write position is also moved to the end of the file.
Definition at line 694 of file cmt1.cpp.
References FSEEK_R, FTELL, m_fileSize, m_handle, m_isOpen, m_lastResult, m_reading, m_readOnly, m_writePos, XRV_NOFILEOPEN, XRV_OK, and XRV_READONLY.
Referenced by xsens::Cmt2f::writeMessage().
XsensResultValue xsens::Cmt1f::close | ( | void | ) |
Close the file.
Definition at line 713 of file cmt1.cpp.
References mrpt::system::os::fclose(), m_fileSize, m_handle, m_isOpen, m_lastResult, m_reading, m_readOnly, m_readPos, m_writePos, and XRV_OK.
Referenced by xsens::Cmt2f::close(), xsens::Cmt2f::create(), and ~Cmt1f().
XsensResultValue xsens::Cmt1f::closeAndDelete | ( | void | ) |
Close the file and delete it.
Definition at line 737 of file cmt1.cpp.
References mrpt::system::os::fclose(), m_filename, m_filename_w, m_fileSize, m_handle, m_isOpen, m_lastResult, m_reading, m_readOnly, m_readPos, m_unicode, m_writePos, XRV_NOFILEOPEN, XRV_OK, and XRV_READONLY.
Referenced by xsens::Cmt2f::closeAndDelete().
XsensResultValue xsens::Cmt1f::create | ( | const char * | filename | ) |
Open an empty file.
Definition at line 789 of file cmt1.cpp.
References CMT_MAX_FILENAME_LENGTH, mrpt::system::os::fclose(), mrpt::system::os::fopen(), m_filename, m_filename_w, m_fileSize, m_handle, m_isOpen, m_lastResult, m_reading, m_readOnly, m_readPos, m_unicode, m_writePos, XRV_ALREADYOPEN, XRV_INVALIDPARAM, XRV_OK, and XRV_OUTPUTCANNOTBEOPENED.
Referenced by xsens::Cmt2f::create(), create(), and open().
XsensResultValue xsens::Cmt1f::create | ( | const wchar_t * | filename | ) |
Open an empty file using a unicode path + filename.
Definition at line 830 of file cmt1.cpp.
References CMT_MAX_FILENAME_LENGTH, create(), mrpt::system::os::fclose(), m_filename, m_filename_w, m_fileSize, m_handle, m_isOpen, m_lastResult, m_reading, m_readOnly, m_readPos, m_unicode, m_writePos, MRPT_UNUSED_PARAM, XRV_ALREADYOPEN, XRV_INVALIDPARAM, XRV_OK, and XRV_OUTPUTCANNOTBEOPENED.
XsensResultValue xsens::Cmt1f::deleteData | ( | const CmtFilePos | start, |
const uint32_t | length | ||
) |
Delete the given data from the file. The function erases the given data from the file at the given write position. This operation may take a while to complete, but is faster than insertData.
The write position is not changed and the read position is checked for validity.
Definition at line 867 of file cmt1.cpp.
References FSEEK, gotoWrite(), m_fileSize, m_handle, m_isOpen, m_lastResult, m_readOnly, m_writePos, XRV_BUSY, XRV_ERROR, XRV_INVALIDINSTANCE, XRV_INVALIDPARAM, XRV_NOFILEOPEN, XRV_OK, XRV_OUTOFMEMORY, and XRV_READONLY.
Referenced by xsens::Cmt2f::create().
XsensResultValue xsens::Cmt1f::find | ( | const void * | needle, |
const uint32_t | needleLength, | ||
CmtFilePos & | pos | ||
) |
Find a string of bytes in the file.
The function searches from the current read position until the given needle
is found. If the needle is not found, XsensResultValue::NOT_FOUND is returned. The function will update the seek position to the first character of the found needle.
needle | The byte string to find. |
needleLength | The length of the byte string. |
pos | Out: The position where the needle was found. This will point to the first character of the found needle. |
Definition at line 941 of file cmt1.cpp.
References FSEEK, gotoRead(), m_handle, m_isOpen, m_lastResult, m_readPos, XRV_ENDOFFILE, XRV_NOFILEOPEN, and XRV_OK.
Referenced by xsens::Cmt2f::readMessage().
XsensResultValue xsens::Cmt1f::flushData | ( | void | ) |
Flush all data to be written. This function writes any remaining data immediately and does not return until this is done.
Definition at line 1001 of file cmt1.cpp.
References m_handle, m_lastResult, and XRV_OK.
|
inline |
Return the size of the file.
Definition at line 329 of file cmt1.h.
References m_fileSize.
Referenced by xsens::Cmt2f::getFileSize().
|
inline |
Return the result code of the last operation.
Definition at line 331 of file cmt1.h.
References m_lastResult.
XsensResultValue xsens::Cmt1f::getName | ( | char * | filename | ) | const |
Retrieve the filename that was last successfully opened.
filename | A buffer for storing the filename. The buffer should be able to hold the filename. A safe size is to make it at least 256 bytes. |
Definition at line 1010 of file cmt1.cpp.
References m_filename, m_lastResult, mrpt::system::os::strcpy(), and XRV_OK.
Referenced by xsens::Cmt2f::getName().
XsensResultValue xsens::Cmt1f::getName | ( | wchar_t * | filename | ) | const |
Retrieve the filename that was last successfully opened in unicode.
filename | A buffer for storing the filename. The buffer should be able to hold the filename. A safe size is to make it at least 256 wide characters. |
Definition at line 1018 of file cmt1.cpp.
References CMT_MAX_FILENAME_LENGTH, m_filename, m_filename_w, m_lastResult, and XRV_OK.
|
inline |
Return the current read position.
Definition at line 350 of file cmt1.h.
References m_readPos.
Referenced by xsens::Cmt2f::getReadPosition().
|
inline |
Change from reading to writing mode.
Definition at line 1040 of file cmt1.cpp.
References FSEEK, m_reading, and m_writePos.
Referenced by deleteData(), insertData(), and writeData().
XsensResultValue xsens::Cmt1f::insertData | ( | const CmtFilePos | start, |
const uint32_t | length, | ||
const void * | data | ||
) |
Insert the given data into the file. The function writes the given data to the file at the current write position. This operation may take a while to complete.
The write position is placed at the end of the inserted data.
Definition at line 1050 of file cmt1.cpp.
References FSEEK, gotoWrite(), m_fileSize, m_handle, m_isOpen, m_lastResult, m_readOnly, m_writePos, XRV_NOFILEOPEN, XRV_OK, and XRV_READONLY.
|
inline |
Return whether the file is open or not.
Definition at line 363 of file cmt1.h.
References m_isOpen.
Referenced by xsens::Cmt2f::close(), xsens::Cmt2f::closeAndDelete(), xsens::Cmt2f::create(), xsens::Cmt2f::isOpen(), and xsens::Cmt2f::open().
|
inline |
Return whether the file is readonly or not.
Definition at line 365 of file cmt1.h.
References m_isOpen, and m_readOnly.
XsensResultValue xsens::Cmt1f::open | ( | const char * | filename, |
const bool | create, | ||
const bool | readOnly | ||
) |
Open a file.
Definition at line 1116 of file cmt1.cpp.
References CMT_MAX_FILENAME_LENGTH, create(), mrpt::system::os::fclose(), mrpt::system::os::fopen(), FSEEK, FSEEK_R, FTELL, m_filename, m_filename_w, m_fileSize, m_handle, m_isOpen, m_lastResult, m_reading, m_readOnly, m_readPos, m_unicode, m_writePos, XRV_ALREADYOPEN, XRV_INPUTCANNOTBEOPENED, XRV_INVALIDPARAM, and XRV_OK.
Referenced by xsens::Cmt2f::open(), and open().
XsensResultValue xsens::Cmt1f::open | ( | const wchar_t * | filename, |
const bool | create, | ||
const bool | readOnly | ||
) |
Open a file using a unicode filename.
Definition at line 1169 of file cmt1.cpp.
References CMT_MAX_FILENAME_LENGTH, create(), mrpt::system::os::fclose(), FSEEK, FSEEK_R, FTELL, m_filename, m_filename_w, m_fileSize, m_handle, m_isOpen, m_lastResult, m_reading, m_readOnly, m_readPos, m_unicode, m_writePos, open(), XRV_ALREADYOPEN, XRV_INPUTCANNOTBEOPENED, XRV_INVALIDPARAM, and XRV_OK.
XsensResultValue xsens::Cmt1f::readData | ( | const uint32_t | maxLength, |
void * | data, | ||
uint32_t * | length | ||
) |
Read data from the file and put it into the data buffer.
This function reads exactly the number of bytes as requested from the file.
maxLength | The amount of data that will be read. |
data | Pointer to a buffer that will store the read data. |
length | pointer to a variable that will store the number of bytes that were actually read. The parameter may be NULL. |
Definition at line 1220 of file cmt1.cpp.
References gotoRead(), m_handle, m_isOpen, m_lastResult, m_readPos, XRV_ENDOFFILE, XRV_NOFILEOPEN, and XRV_OK.
Referenced by xsens::Cmt2f::readMessage().
XsensResultValue xsens::Cmt1f::readData | ( | const uint32_t | maxLength, |
const char | terminator, | ||
void * | data, | ||
uint32_t * | length | ||
) |
Read data from the file and put it into the data buffer.
This function reads upp to the number of bytes as requested from the file. The function will also stop if the given terminator character is encountered. The terminator is included in the output buffer.
maxLength | The amount of data that will be read. |
data | Pointer to a buffer that will store the read data. |
terminator | A character that will end the read operation if encountered. |
length | The actual number of bytes read, including the terminator character, if encountered. |
Definition at line 1241 of file cmt1.cpp.
References gotoRead(), m_handle, m_isOpen, m_lastResult, m_readPos, XRV_ENDOFFILE, XRV_NOFILEOPEN, and XRV_OK.
XsensResultValue xsens::Cmt1f::setReadPos | ( | const CmtFilePos | pos | ) |
Set the new absolute read position.
The read position is checked against the filesize before committing.
Definition at line 1272 of file cmt1.cpp.
References FSEEK, m_isOpen, m_lastResult, m_reading, m_readPos, XRV_NOFILEOPEN, and XRV_OK.
Referenced by xsens::Cmt2f::readMessage(), and xsens::Cmt2f::setReadPosition().
XsensResultValue xsens::Cmt1f::setWritePos | ( | const CmtFilePos | pos = -1 | ) |
Set the new absolute write position.
The write position is checked against the filesize before committing.
Definition at line 1287 of file cmt1.cpp.
References FSEEK, FSEEK_R, FTELL, m_isOpen, m_lastResult, m_reading, m_readOnly, m_writePos, XRV_NOFILEOPEN, XRV_OK, and XRV_READONLY.
XsensResultValue xsens::Cmt1f::writeData | ( | const uint32_t | length, |
const void * | data | ||
) |
Write data to the file.
The function writes the given data to the file at the current write position.
Definition at line 1312 of file cmt1.cpp.
References gotoWrite(), m_fileSize, m_handle, m_isOpen, m_lastResult, m_readOnly, m_writePos, XRV_NOFILEOPEN, XRV_OK, and XRV_READONLY.
Referenced by xsens::Cmt2f::create().
|
protected |
|
protected |
|
protected |
Contains the size of the file.
Definition at line 250 of file cmt1.h.
Referenced by appendData(), close(), closeAndDelete(), Cmt1f(), create(), deleteData(), getFileSize(), insertData(), open(), and writeData().
|
protected |
The file handle.
Definition at line 248 of file cmt1.h.
Referenced by appendData(), close(), closeAndDelete(), create(), deleteData(), find(), flushData(), insertData(), open(), readData(), and writeData().
|
protected |
Indicates if the file is open or not.
Definition at line 263 of file cmt1.h.
Referenced by appendData(), close(), closeAndDelete(), Cmt1f(), create(), deleteData(), find(), insertData(), isOpen(), isReadOnly(), open(), readData(), setReadPos(), setWritePos(), and writeData().
|
mutableprotected |
The last result of an operation.
Definition at line 256 of file cmt1.h.
Referenced by appendData(), close(), closeAndDelete(), Cmt1f(), create(), deleteData(), find(), flushData(), getLastResult(), getName(), insertData(), open(), readData(), setReadPos(), setWritePos(), and writeData().
|
protected |
Indicates whether the last operation was a read or write operation. This value is used to check whether or not a seek is required to perform a requested read or write operation.
Definition at line 270 of file cmt1.h.
Referenced by appendData(), close(), closeAndDelete(), Cmt1f(), create(), gotoRead(), gotoWrite(), open(), setReadPos(), and setWritePos().
|
protected |
Indicates if the file was opened in read-only mode.
Definition at line 272 of file cmt1.h.
Referenced by appendData(), close(), closeAndDelete(), Cmt1f(), create(), deleteData(), insertData(), isReadOnly(), open(), setWritePos(), and writeData().
|
protected |
The last read position in the file.
Definition at line 252 of file cmt1.h.
Referenced by close(), closeAndDelete(), Cmt1f(), create(), find(), getReadPos(), gotoRead(), open(), readData(), and setReadPos().
|
protected |
|
protected |
The last write position in the file.
Definition at line 254 of file cmt1.h.
Referenced by appendData(), close(), closeAndDelete(), Cmt1f(), create(), deleteData(), getWritePos(), gotoWrite(), insertData(), open(), setWritePos(), and writeData().
Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 8fe78517f Sun Jul 14 19:43:28 2019 +0200 at lun oct 28 02:10:00 CET 2019 |