Main MRPT website > C++ reference for MRPT 1.9.9
iointerfacefile.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2018, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 #ifndef IOINTERFACEFILE_H
10 #define IOINTERFACEFILE_H
11 
12 #include <xsens/xsplatform.h>
13 #include "streaminterface.h"
14 
15 enum XsResultValue;
16 
17 //////////////////////////////////////////////////////////////////////////////////////////
18 ///////////////////////////////////////// IoInterfaceFile
19 ////////////////////////////////////////////
20 //////////////////////////////////////////////////////////////////////////////////////////
21 
22 /*! \brief The low-level file communication class.
23 */
25 {
26  private:
28 
29  protected:
30  //! The file handlem, also indicates if the file is open or not.
32  //! Contains the size of the file
34  //! The last read position in the file
36  //! The last write position in the file
38  //! The last result of an operation
40  //! Contains the name of the file that was last successfully opened.
42  /*! \brief Indicates whether the last operation was a read or write
43  operation.
44 
45  This value is used to check whether or not a seek is required to perform
46  a
47  requested read or write operation.
48  */
49  bool m_reading;
50  //! Indicates if the file was opened in read-only mode
51  bool m_readOnly;
52 
53  void gotoRead(void);
54  void gotoWrite(void);
55 
56  public:
59 
60  // Function overrides
61  XsResultValue close(void);
64  bool isOpen(void) const;
65  XsResultValue getLastResult(void) const;
66  XsResultValue writeData(const XsByteArray& data, XsSize* written = nullptr);
69  XsSize maxLength, unsigned char terminator, XsByteArray& bdata);
70 
71  // Other functions
72  XsResultValue appendData(const XsByteArray& bdata);
74  XsResultValue create(const XsString& filename);
77  XsFilePos getFileSize(void) const;
78  XsTimeStamp getFileDate(void) const;
79  XsResultValue getName(XsString& filename) const;
80  XsFilePos getReadPosition(void) const;
81  XsFilePos getWritePosition(void) const;
83  bool isReadOnly(void) const;
84  XsResultValue open(const XsString& filename, bool createNew, bool readOnly);
87 };
88 
89 #endif // file guard
XsString
struct XsString XsString
Definition: xsstring.h:34
IoInterfaceFile::find
XsResultValue find(const XsByteArray &data, XsFilePos &pos)
Find a string of bytes in the file.
Definition: iointerfacefile.cpp:329
maxLength
GLsizei maxLength
Definition: glext.h:4932
IoInterfaceFile::gotoWrite
void gotoWrite(void)
Change from reading to writing mode.
Definition: iointerfacefile.cpp:442
IoInterfaceFile::closeFile
XsResultValue closeFile(void)
Close the file.
Definition: iointerfacefile.cpp:118
IoInterfaceFile
The low-level file communication class.
Definition: iointerfacefile.h:24
IoInterfaceFile::m_fileSize
XsFilePos m_fileSize
Contains the size of the file.
Definition: iointerfacefile.h:33
XsByteArray
struct XsByteArray XsByteArray
Definition: xsbytearray.h:25
IoInterfaceFile::gotoRead
void gotoRead(void)
Change from writing to reading mode.
Definition: iointerfacefile.cpp:432
IoInterfaceFile::m_handle
XsFileHandle * m_handle
The file handlem, also indicates if the file is open or not.
Definition: iointerfacefile.h:31
start
GLuint start
Definition: glext.h:3528
IoInterfaceFile::flushData
XsResultValue flushData(void)
Flush all data in the buffers to and from the device.
Definition: iointerfacefile.cpp:413
IoInterfaceFile::close
XsResultValue close(void)
Close the file, overrides IoInterface::close().
Definition: iointerfacefile.cpp:114
XsFileHandle
FILE XsFileHandle
Definition: xsfilepos.h:51
IoInterfaceFile::~IoInterfaceFile
~IoInterfaceFile()
Definition: iointerfacefile.cpp:73
IoInterfaceFile::m_writePos
XsFilePos m_writePos
The last write position in the file.
Definition: iointerfacefile.h:37
xsplatform.h
IoInterfaceFile::isReadOnly
bool isReadOnly(void) const
Return whether the file is readonly or not.
Definition: iointerfacefile.cpp:805
IoInterfaceFile::getFileDate
XsTimeStamp getFileDate(void) const
Return the creation date of the file.
Definition: iointerfacefile.cpp:396
length
GLuint GLsizei GLsizei * length
Definition: glext.h:4064
XsResultValue
XsResultValue
Xsens result values.
Definition: xsresultvalue.h:27
IoInterfaceFile::writeData
XsResultValue writeData(const XsByteArray &data, XsSize *written=nullptr)
Write the data contained in data to the device.
Definition: iointerfacefile.cpp:748
streaminterface.h
IoInterfaceFile::m_reading
bool m_reading
Indicates whether the last operation was a read or write operation.
Definition: iointerfacefile.h:49
IoInterfaceFile::insertData
XsResultValue insertData(XsFilePos start, const XsByteArray &data)
Insert the given data into the file.
Definition: iointerfacefile.cpp:461
IoInterfaceFile::getFileSize
XsFilePos getFileSize(void) const
Return the size of the file.
Definition: iointerfacefile.cpp:392
IoInterfaceFile::deleteData
XsResultValue deleteData(XsFilePos start, XsSize length)
Delete the given data from the file.
Definition: iointerfacefile.cpp:246
data
GLsizei GLsizei GLenum GLenum const GLvoid * data
Definition: glext.h:3547
IoInterfaceFile::getLastResult
XsResultValue getLastResult(void) const
Return the result code of the last operation.
Definition: iointerfacefile.cpp:793
IoInterfaceFile::readData
XsResultValue readData(XsSize maxLength, XsByteArray &data)
Read at most maxLength bytes from the device into data.
Definition: iointerfacefile.cpp:620
IoInterfaceFile::m_filename
XsString m_filename
Contains the name of the file that was last successfully opened.
Definition: iointerfacefile.h:41
IoInterfaceFile::m_readPos
XsFilePos m_readPos
The last read position in the file.
Definition: iointerfacefile.h:35
IoInterfaceFile::IoInterfaceFile
IoInterfaceFile()
Definition: iointerfacefile.cpp:60
XsSize
size_t XsSize
XsSize must be unsigned number!
Definition: xstypedefs.h:19
IoInterfaceFile::create
XsResultValue create(const XsString &filename)
Create an empty file.
Definition: iointerfacefile.cpp:185
IoInterfaceFile::getName
XsResultValue getName(XsString &filename) const
Retrieve the filename that was last successfully opened.
Definition: iointerfacefile.cpp:425
XsTimeStamp
Class for managing timestamps in a unified way.
Definition: xstimestamp.h:53
XSENS_DISABLE_COPY
#define XSENS_DISABLE_COPY(className)
Add this macro to the start of a class definition to prevent automatic creation of copy functions.
Definition: xcommunicationconfig.h:149
IoInterface
An abstract IO interface.
Definition: iointerface.h:42
IoInterfaceFile::getReadPosition
XsFilePos getReadPosition(void) const
Return the current read position.
Definition: iointerfacefile.cpp:785
IoInterfaceFile::m_readOnly
bool m_readOnly
Indicates if the file was opened in read-only mode.
Definition: iointerfacefile.h:51
IoInterfaceFile::open
XsResultValue open(const XsString &filename, bool createNew, bool readOnly)
Open a file.
Definition: iointerfacefile.cpp:538
IoInterfaceFile::readTerminatedData
XsResultValue readTerminatedData(XsSize maxLength, unsigned char terminator, XsByteArray &bdata)
Read data from the file and put it into the data buffer.
Definition: iointerfacefile.cpp:659
IoInterfaceFile::setWritePosition
XsResultValue setWritePosition(XsFilePos pos=-1)
Set the new absolute write position.
Definition: iointerfacefile.cpp:721
IoInterfaceFile::isOpen
bool isOpen(void) const
Return whether the file is open or not.
Definition: iointerfacefile.cpp:801
IoInterfaceFile::closeAndDelete
XsResultValue closeAndDelete(void)
Close the file and delete it.
Definition: iointerfacefile.cpp:143
IoInterfaceFile::setReadPosition
XsResultValue setReadPosition(XsFilePos pos)
Set the new absolute read position.
Definition: iointerfacefile.cpp:703
IoInterfaceFile::getWritePosition
XsFilePos getWritePosition(void) const
Return the current write position.
Definition: iointerfacefile.cpp:789
IoInterfaceFile::m_lastResult
XsResultValue m_lastResult
The last result of an operation.
Definition: iointerfacefile.h:39
IoInterfaceFile::appendData
XsResultValue appendData(const XsByteArray &bdata)
Write data to the end of the file.
Definition: iointerfacefile.cpp:91
XsFilePos
__int64 XsFilePos
The type that is used for positioning inside a file.
Definition: xsfilepos.h:34



Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST