libqicore-api  2.8.7.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Public Member Functions | Static Public Attributes | Protected Member Functions | List of all members
qi::File Class Referenceabstract

#include <file.hpp>

Public Member Functions

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

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.

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

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

Member Function Documentation

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.

virtual bool qi::File::isOpen ( ) const
pure virtual
Returns
true if the file is currently open for reading, false otherwise.
virtual bool qi::File::isRemote ( ) const
pure virtual
Returns
true if the file is located on a remote filesystem, false otherwise.
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.

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.
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
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.
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.

Member Data Documentation

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: