Main MRPT website > C++ reference for MRPT 1.5.7
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-2017, 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 /*! \brief The low-level file communication class.
22 */
23 class IoInterfaceFile : public IoInterface {
24 private:
26 
27 protected:
28  //! The file handlem, also indicates if the file is open or not.
30  //! Contains the size of the file
32  //! The last read position in the file
34  //! The last write position in the file
36  //! The last result of an operation
38  //! Contains the name of the file that was last successfully opened.
40  /*! \brief Indicates whether the last operation was a read or write operation.
41 
42  This value is used to check whether or not a seek is required to perform a
43  requested read or write operation.
44  */
45  bool m_reading;
46  //! Indicates if the file was opened in read-only mode
47  bool m_readOnly;
48 
49  void gotoRead(void);
50  void gotoWrite(void);
51 public:
54 
55  // Function overrides
56  XsResultValue close(void);
59  bool isOpen(void) const;
60  XsResultValue getLastResult(void) const;
61  XsResultValue writeData(const XsByteArray& data, XsSize *written = NULL);
63  XsResultValue readTerminatedData(XsSize maxLength, unsigned char terminator, XsByteArray& bdata);
64 
65  // Other functions
66  XsResultValue appendData(const XsByteArray& bdata);
68  XsResultValue create(const XsString& filename);
71  XsFilePos getFileSize(void) const;
72  XsTimeStamp getFileDate(void) const;
73  XsResultValue getName(XsString& filename) const;
74  XsFilePos getReadPosition(void) const;
75  XsFilePos getWritePosition(void) const;
77  bool isReadOnly(void) const;
78  XsResultValue open(const XsString& filename, bool createNew, bool readOnly);
81 };
82 
83 #endif // file guard
The low-level file communication class.
XsResultValue appendData(const XsByteArray &bdata)
Write data to the end of the file.
XsResultValue getLastResult(void) const
Return the result code of the last operation.
XsResultValue getName(XsString &filename) const
Retrieve the filename that was last successfully opened.
void gotoRead(void)
Change from writing to reading mode.
XsResultValue deleteData(XsFilePos start, XsSize length)
Delete the given data from the file.
XsFileHandle * m_handle
The file handlem, also indicates if the file is open or not.
XsResultValue open(const XsString &filename, bool createNew, bool readOnly)
Open a file.
XsString m_filename
Contains the name of the file that was last successfully opened.
bool m_reading
Indicates whether the last operation was a read or write operation.
XsResultValue writeData(const XsByteArray &data, XsSize *written=NULL)
Write the data contained in data to the device.
bool isOpen(void) const
Return whether the file is open or not.
XsTimeStamp getFileDate(void) const
Return the creation date of the file.
XsResultValue insertData(XsFilePos start, const XsByteArray &data)
Insert the given data into the file.
XsResultValue closeFile(void)
Close the file.
XsFilePos getReadPosition(void) const
Return the current read position.
XsResultValue closeAndDelete(void)
Close the file and delete it.
XsResultValue close(void)
Close the file, overrides IoInterface::close().
XsResultValue readData(XsSize maxLength, XsByteArray &data)
Read at most maxLength bytes from the device into data.
XsResultValue setReadPosition(XsFilePos pos)
Set the new absolute read position.
XsResultValue create(const XsString &filename)
Create an empty file.
XsResultValue flushData(void)
Flush all data in the buffers to and from the device.
XsResultValue setWritePosition(XsFilePos pos=-1)
Set the new absolute write position.
XsFilePos getFileSize(void) const
Return the size of the file.
bool isReadOnly(void) const
Return whether the file is readonly or not.
XsFilePos m_writePos
The last write position in the file.
XsResultValue m_lastResult
The last result of an operation.
XsFilePos m_fileSize
Contains the size of the file.
XsFilePos m_readPos
The last read position in the file.
XsResultValue find(const XsByteArray &data, XsFilePos &pos)
Find a string of bytes in the file.
void gotoWrite(void)
Change from reading to writing mode.
bool m_readOnly
Indicates if the file was opened in read-only mode.
XsResultValue readTerminatedData(XsSize maxLength, unsigned char terminator, XsByteArray &bdata)
Read data from the file and put it into the data buffer.
XsFilePos getWritePosition(void) const
Return the current write position.
GLuint start
Definition: glext.h:3512
GLsizei GLsizei GLenum GLenum const GLvoid * data
Definition: glext.h:3520
GLuint GLsizei GLsizei * length
Definition: glext.h:3900
GLsizei maxLength
Definition: glext.h:4504
__int64 XsFilePos
The type that is used for positioning inside a file.
Definition: xsfilepos.h:33
XsResultValue
Xsens result values.
Definition: xsresultvalue.h:26
An abstract IO interface.
Definition: iointerface.h:42
Class for managing timestamps in a unified way.
Definition: xstimestamp.h:43
#define XSENS_DISABLE_COPY(className)
Add this macro to the start of a class definition to prevent automatic creation of copy functions.
struct XsByteArray XsByteArray
Definition: xsbytearray.h:25
FILE XsFileHandle
Definition: xsfilepos.h:50
struct XsString XsString
Definition: xsstring.h:34
size_t XsSize
XsSize must be unsigned number!
Definition: xstypedefs.h:17



Page generated by Doxygen 1.9.1 for MRPT 1.5.7 Git: 5902e14cc Wed Apr 24 15:04:01 2019 +0200 at mar 26 may 2026 13:12:03 CEST