|
xsens_imu
|
The low-level file communication class. More...
#include <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 XsensFilePos start, const uint32_t length) |
| Delete the given data from the file. More... | |
| XsensResultValue | find (const void *needle, const uint32_t needleLength, XsensFilePos &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... | |
| XsensFilePos | 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... | |
| XsensFilePos | getReadPos (void) const |
| Return the current read position. More... | |
| XsensFilePos | getWritePos (void) const |
| Return the current write position. More... | |
| XsensResultValue | insertData (const XsensFilePos start, const uint32_t length, const void *data) |
| Insert the given data into the file. 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 XsensFilePos pos) |
| Set the new absolute read position. More... | |
| XsensResultValue | setWritePos (const XsensFilePos 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... | |
| XsensFilePos | m_fileSize |
| Contains the size of the file. More... | |
| XsensFilePos | m_readPos |
| The last read position in the file. More... | |
| XsensFilePos | 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. More... | |
| bool | m_readOnly |
| Indicates if the file was opened in read-only mode. More... | |
The low-level file communication class.
| xsens::Cmt1f::Cmt1f | ( | ) |
Default constructor, initializes all members to their default values.
| xsens::Cmt1f::~Cmt1f | ( | ) |
Destructor.
| 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.
| XsensResultValue xsens::Cmt1f::close | ( | void | ) |
Close the file.
| XsensResultValue xsens::Cmt1f::closeAndDelete | ( | void | ) |
Close the file and delete it.
| XsensResultValue xsens::Cmt1f::create | ( | const char * | filename | ) |
Open an empty file.
| XsensResultValue xsens::Cmt1f::create | ( | const wchar_t * | filename | ) |
Open an empty file using a unicode path + filename.
| XsensResultValue xsens::Cmt1f::deleteData | ( | const XsensFilePos | 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.
| XsensResultValue xsens::Cmt1f::find | ( | const void * | needle, |
| const uint32_t | needleLength, | ||
| XsensFilePos & | 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. |
| 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.
|
inline |
Return the size of the file.
|
inline |
Return the result code of the last operation.
| 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. |
| 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. |
|
inline |
Return the current read position.
|
inline |
Return the current write position.
|
protected |
Change from writing to reading mode.
|
protected |
Change from reading to writing mode.
| XsensResultValue xsens::Cmt1f::insertData | ( | const XsensFilePos | 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.
|
inline |
Return whether the file is open or not.
|
inline |
Return whether the file is readonly or not.
| XsensResultValue xsens::Cmt1f::open | ( | const char * | filename, |
| const bool | create, | ||
| const bool | readOnly | ||
| ) |
Open a file.
| XsensResultValue xsens::Cmt1f::open | ( | const wchar_t * | filename, |
| const bool | create, | ||
| const bool | readOnly | ||
| ) |
Open a file using a unicode filename.
| 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. |
| 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. |
| XsensResultValue xsens::Cmt1f::setReadPos | ( | const XsensFilePos | pos | ) |
Set the new absolute read position.
The read position is checked against the filesize before committing.
| XsensResultValue xsens::Cmt1f::setWritePos | ( | const XsensFilePos | pos = -1 | ) |
Set the new absolute write position.
The write position is checked against the filesize before committing.
| 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.
|
protected |
Contains the name of the file that was last successfully opened.
|
protected |
Contains the name of the file that was last successfully opened using unicode.
|
protected |
Contains the size of the file.
|
protected |
The file handle.
|
protected |
Indicates if the file is open or not.
|
mutableprotected |
The last result of an operation.
|
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.
|
protected |
Indicates if the file was opened in read-only mode.
|
protected |
The last read position in the file.
|
protected |
Indicates if we're using the unicode filename or the regular filename.
|
protected |
The last write position in the file.
1.8.11