Public Member Functions | Static Public Attributes | Protected Member Functions | List of all members
qi::File Class Referenceabstract

#include <file.hpp>

Inheritance diagram for qi::File:
Inheritance graph
[legend]

Public Member Functions

virtual void close ()=0
 
virtual bool isOpen () const =0
 
virtual bool isRemote () const =0
 
virtual ProgressNotifierPtr operationProgress () const =0
 
virtual Buffer read (std::streamoff beginOffset, std::streamsize countBytesToRead)=0
 
virtual Buffer read (std::streamsize countBytesToRead)=0
 
virtual bool seek (std::streamoff offsetFromBegin)=0
 
virtual std::streamsize size () const =0
 
virtual ~File ()=default
 

Static Public Attributes

static const std::streamsize MAX_READ_SIZE = 1000000
 Maximum count of bytes that you can read by reading functions call. More...
 

Protected Member Functions

 File ()=default
 

Detailed Description

Provide access to the content of a local or remote file. @includename{qicore/file.hpp}

Remarks
Should be obtained using openLocalFile() or through a service API if the file is potentially remote.

Definition at line 127 of file file.hpp.

Constructor & Destructor Documentation

◆ File()

qi::File::File ( )
protecteddefault

◆ ~File()

virtual qi::File::~File ( )
virtualdefault

Member Function Documentation

◆ close()

virtual void qi::File::close ( )
pure virtual

Close the file. Once this function is called, calling most other operation will throw a std::runtime_error. The size(), isOpen() and isRemote() calls will return work as expected.

Implemented in qi::FileImpl, and qi::FileProxy.

◆ isOpen()

virtual bool qi::File::isOpen ( ) const
pure virtual
Returns
true if the file is currently open for reading, false otherwise.

Implemented in qi::FileImpl, and qi::FileProxy.

◆ isRemote()

virtual bool qi::File::isRemote ( ) const
pure virtual
Returns
true if the file is located on a remote filesystem, false otherwise.

Implemented in qi::FileImpl, and qi::FileProxy.

◆ operationProgress()

virtual ProgressNotifierPtr qi::File::operationProgress ( ) const
pure virtual

Provide the progress notifier used by the operations manipulating this file. The notifier is associated with this file. Therefore, no concurrent operation should be used by this notifier object, as it is not safe to have concurrent operations running on the same file.

Implemented in qi::FileImpl, and qi::FileProxy.

◆ read() [1/2]

virtual Buffer qi::File::read ( std::streamoff  beginOffset,
std::streamsize  countBytesToRead 
)
pure virtual

Read a specified count of bytes starting from a specified byte position in the file.

Warning
If you try to read more than _MAX_READ_SIZE bytes, this call will throw a std::runtime_error.
Parameters
beginOffsetPosition in the file to start reading from.
countBytesToReadCount of bytes to read from the file starting at the current position of the file cursor.
Returns
A buffer of data read from the file, empty if:
  • there is no data in the specified byte range to read
  • if the file have been closed;
  • if the start position is outside the available range of data in the file. If there is less data to read in the file than the required count, if we try reading past the end of the file for example, then the buffer will only contain the available data, nothing more

Implemented in qi::FileImpl, and qi::FileProxy.

◆ read() [2/2]

virtual Buffer qi::File::read ( std::streamsize  countBytesToRead)
pure virtual

Read a specified count of bytes starting from the current cursor position.

Warning
If you try to read more than _MAX_READ_SIZE bytes, this call will throw a std::runtime_error.
Parameters
countBytesToReadCount of bytes to read from the file, starting from the current position of the file cursor.
Returns
A buffer of data read from the file, empty if there is no data in the specified byte range to read or if the file have been closed. If there is less data to read in the file than the required count, if we try reading past the end of the file for example, then the buffer will only contain the available data, nothing more.

Implemented in qi::FileImpl, and qi::FileProxy.

◆ seek()

virtual bool qi::File::seek ( std::streamoff  offsetFromBegin)
pure virtual

Move the read cursor to the specified position in the file.

Parameters
offsetFromBeginNew position of the read cursor in the file. If it is out of the range of data in the file, the cursor will not be changed at all.
Returns
true if the position is in the range of data available in the file, false otherwise, in which case the cursor have not been changed.

Implemented in qi::FileImpl, and qi::FileProxy.

◆ size()

virtual std::streamsize qi::File::size ( ) const
pure virtual
Returns
Total count of bytes contained in the file or 0 if the file is closed.

Implemented in qi::FileImpl, and qi::FileProxy.

Member Data Documentation

◆ MAX_READ_SIZE

const std::streamsize qi::File::MAX_READ_SIZE = 1000000
static

Maximum count of bytes that you can read by reading functions call.

Definition at line 156 of file file.hpp.


The documentation for this class was generated from the following file:


naoqi_libqicore
Author(s): Aldebaran
autogenerated on Wed Sep 14 2022 02:22:41