MRPT  1.9.9
iointerfacefile.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | https://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2019, Individual contributors, see AUTHORS file |
6  | See: https://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See: https://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:
58  ~IoInterfaceFile() override;
59 
60  // Function overrides
61  XsResultValue close(void) override;
63  XsResultValue flushData(void) override;
64  bool isOpen(void) const override;
65  XsResultValue getLastResult(void) const override;
67  const XsByteArray& data, XsSize* written = nullptr) override;
70  XsSize maxLength, unsigned char terminator, XsByteArray& bdata);
71 
72  // Other functions
73  XsResultValue appendData(const XsByteArray& bdata) override;
74  XsResultValue closeAndDelete(void) override;
75  XsResultValue create(const XsString& filename) override;
77  XsResultValue find(const XsByteArray& data, XsFilePos& pos) override;
78  XsFilePos getFileSize(void) const override;
79  XsTimeStamp getFileDate(void) const;
80  XsResultValue getName(XsString& filename) const override;
81  XsFilePos getReadPosition(void) const override;
82  XsFilePos getWritePosition(void) const override;
84  bool isReadOnly(void) const override;
86  const XsString& filename, bool createNew, bool readOnly) override;
88  XsResultValue setWritePosition(XsFilePos pos = -1) override;
89 };
90 
91 #endif // file guard
The low-level file communication class.
XsResultValue setWritePosition(XsFilePos pos=-1) override
Set the new absolute write position.
XsResultValue m_lastResult
The last result of an operation.
XsFilePos getFileSize(void) const override
Return the size of the file.
~IoInterfaceFile() override
XsResultValue readData(XsSize maxLength, XsByteArray &data) override
Read at most maxLength bytes from the device into data.
XsTimeStamp getFileDate(void) const
Return the creation date of the file.
XsString m_filename
Contains the name of the file that was last successfully opened.
struct XsByteArray XsByteArray
Definition: xsbytearray.h:26
XsResultValue closeFile(void)
Close the file.
XsFilePos m_writePos
The last write position in the file.
size_t XsSize
XsSize must be unsigned number!
Definition: xstypedefs.h:19
XsResultValue getLastResult(void) const override
Return the result code of the last operation.
XsResultValue appendData(const XsByteArray &bdata) override
Write data to the end of the file.
XsFilePos m_fileSize
Contains the size of the file.
bool m_reading
Indicates whether the last operation was a read or write operation.
XsResultValue
Xsens result values.
Definition: xsresultvalue.h:28
void gotoRead(void)
Change from writing to reading mode.
XsFilePos getReadPosition(void) const override
Return the current read position.
__int64 XsFilePos
The type that is used for positioning inside a file.
Definition: xsfilepos.h:34
XsResultValue insertData(XsFilePos start, const XsByteArray &data) override
Insert the given data into the file.
XsResultValue writeData(const XsByteArray &data, XsSize *written=nullptr) override
Write the data contained in data to the device.
XsResultValue close(void) override
Close the file, overrides IoInterface::close().
XsResultValue flushData(void) override
Flush all data in the buffers to and from the device.
Class for managing timestamps in a unified way.
Definition: xstimestamp.h:56
XsResultValue find(const XsByteArray &data, XsFilePos &pos) override
Find a string of bytes in the file.
XsResultValue closeAndDelete(void) override
Close the file and delete it.
#define XSENS_DISABLE_COPY(className)
Add this macro to the start of a class definition to prevent automatic creation of copy functions...
XsResultValue open(const XsString &filename, bool createNew, bool readOnly) override
Open a file.
XsResultValue getName(XsString &filename) const override
Retrieve the filename that was last successfully opened.
void gotoWrite(void)
Change from reading to writing mode.
XsFileHandle * m_handle
The file handlem, also indicates if the file is open or not.
An abstract IO interface.
Definition: iointerface.h:42
XsResultValue create(const XsString &filename) override
Create an empty file.
GLuint GLsizei GLsizei * length
Definition: glext.h:4079
bool isReadOnly(void) const override
Return whether the file is readonly or not.
FILE XsFileHandle
Definition: xsfilepos.h:51
XsResultValue readTerminatedData(XsSize maxLength, unsigned char terminator, XsByteArray &bdata)
Read data from the file and put it into the data buffer.
XsResultValue setReadPosition(XsFilePos pos) override
Set the new absolute read position.
GLsizei maxLength
Definition: glext.h:4991
GLuint start
Definition: glext.h:3532
struct XsString XsString
Definition: xsstring.h:35
GLsizei GLsizei GLenum GLenum const GLvoid * data
Definition: glext.h:3550
bool m_readOnly
Indicates if the file was opened in read-only mode.
XsResultValue deleteData(XsFilePos start, XsSize length) override
Delete the given data from the file.
bool isOpen(void) const override
Return whether the file is open or not.
XsFilePos getWritePosition(void) const override
Return the current write position.
XsFilePos m_readPos
The last read position in the file.



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