Visualization Library 2.1.0

A lightweight C++ OpenGL middleware for 2D/3D graphics

VL     Star     Watch     Fork     Issue

[Download] [Tutorials] [All Classes] [Grouped Classes]
Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
vl::QtFile Class Reference

A VirtualFile that uses Qt's QFile. More...

#include <QtFile.hpp>

+ Inheritance diagram for vl::QtFile:

Public Member Functions

 QtFile (const String &path=String())
 
 ~QtFile ()
 
bool open (const String &path, EOpenMode mode)
 The specified path is relative to the parent directory. See setPhysicalPath(). More...
 
virtual bool open (EOpenMode mode)
 Opens the file in the specified mode. More...
 
virtual bool isOpen () const
 Returns true if the file has been opened. More...
 
virtual void close ()
 Closes the file. More...
 
virtual long long size () const
 Returns the file size in bytes or -1 on error. More...
 
virtual bool exists () const
 Returns true if the file exists. More...
 
QtFileoperator= (const QtFile &other)
 
virtual ref< VirtualFileclone () const
 Creates a clone of this class instance. More...
 
 QtFile (const String &path=String())
 
 ~QtFile ()
 
bool open (const String &path, EOpenMode mode)
 The specified path is relative to the parent directory. See setPhysicalPath(). More...
 
virtual bool open (EOpenMode mode)
 Opens the file in the specified mode. More...
 
virtual bool isOpen () const
 Returns true if the file has been opened. More...
 
virtual void close ()
 Closes the file. More...
 
virtual long long size () const
 Returns the file size in bytes or -1 on error. More...
 
virtual bool exists () const
 Returns true if the file exists. More...
 
QtFileoperator= (const QtFile &other)
 
virtual ref< VirtualFileclone () const
 Creates a clone of this class instance. More...
 
 QtFile (const String &path=String())
 
 ~QtFile ()
 
bool open (const String &path, EOpenMode mode)
 The specified path is relative to the parent directory. See setPhysicalPath(). More...
 
virtual bool open (EOpenMode mode)
 Opens the file in the specified mode. More...
 
virtual bool isOpen () const
 Returns true if the file has been opened. More...
 
virtual void close ()
 Closes the file. More...
 
virtual long long size () const
 Returns the file size in bytes or -1 on error. More...
 
virtual bool exists () const
 Returns true if the file exists. More...
 
QtFileoperator= (const QtFile &other)
 
virtual ref< VirtualFileclone () const
 Creates a clone of this class instance. More...
 
- Public Member Functions inherited from vl::VirtualFile
 VirtualFile ()
 Constructor. More...
 
unsigned int crc32 ()
 Computes the crc32 of the entire file. More...
 
MD5CheckSum md5 ()
 Computes the md5 of the entire file. More...
 
VirtualFileoperator= (const VirtualFile &other)
 
const Stringpath () const
 Returns the path of the file. More...
 
void setPath (const String &name)
 Changes the path bound to a VirtualFile. Use carefully this function, you shouldn't rename a VirtualFile managed by a VirtualDirectory. More...
 
long long peek (void *buffer, long long byte_count)
 Reads byte_count bytes and returns to the original position. More...
 
long long read (void *buffer, long long byte_count)
 Reads byte_count bytes from a file. Returns the number of bytes actually read. More...
 
long long write (const void *buffer, long long byte_count)
 Writes byte_count bytes to a file. Returns the number of bytes actually written. More...
 
long long position () const
 Returns the current position in the file. More...
 
bool seekSet (long long offset)
 Changes the current read/write position of a file. More...
 
bool seekCur (long long offset)
 Changes the current read/write position of a file. More...
 
bool seekEnd (long long offset)
 Changes the current read/write position of a file. More...
 
bool endOfFile () const
 Returns true if position() >= size() More...
 
long long load (std::vector< char > &data)
 Loads the entire file in the specified vector. More...
 
long long load (void *buffer, long long max=-1)
 Loads the entire file in the specified buffer. More...
 
double readDouble (bool little_endian_data=true)
 Reads single entry. More...
 
float readFloat (bool little_endian_data=true)
 Reads single entry. More...
 
unsigned long long readUInt64 (bool little_endian_data=true)
 Reads single entry. More...
 
long long readSInt64 (bool little_endian_data=true)
 Reads single entry. More...
 
unsigned int readUInt32 (bool little_endian_data=true)
 Reads single entry. More...
 
int readSInt32 (bool little_endian_data=true)
 Reads single entry. More...
 
unsigned short readUInt16 (bool little_endian_data=true)
 Reads single entry. More...
 
short readSInt16 (bool little_endian_data=true)
 Reads single entry. More...
 
unsigned char readUInt8 ()
 Reads single entry. More...
 
char readSInt8 ()
 Reads single entry. More...
 
long long readDouble (double *buffer, long long count, bool little_endian_data=true)
 Reads multiple entries. Returns the number of bytes read. More...
 
long long readFloat (float *buffer, long long count, bool little_endian_data=true)
 Reads multiple entries. Returns the number of bytes read. More...
 
long long readUInt64 (unsigned long long *buffer, long long count, bool little_endian_data=true)
 Reads multiple entries. Returns the number of bytes read. More...
 
long long readSInt64 (long long *buffer, long long count, bool little_endian_data=true)
 Reads multiple entries. Returns the number of bytes read. More...
 
long long readUInt32 (unsigned int *buffer, long long count, bool little_endian_data=true)
 Reads multiple entries. Returns the number of bytes read. More...
 
long long readSInt32 (int *buffer, long long count, bool little_endian_data=true)
 Reads multiple entries. Returns the number of bytes read. More...
 
long long readUInt16 (unsigned short *buffer, long long count, bool little_endian_data=true)
 Reads multiple entries. Returns the number of bytes read. More...
 
long long readSInt16 (short *buffer, long long count, bool little_endian_data=true)
 Reads multiple entries. Returns the number of bytes read. More...
 
long long readUInt8 (unsigned char *buffer, long long count)
 Reads multiple entries. Returns the number of bytes read. More...
 
long long readSInt8 (char *buffer, long long count)
 Reads multiple entries. Returns the number of bytes read. More...
 
long long writeDouble (double data, bool little_endian_data=true)
 Writes a single entry. Returns the number of bytes written. More...
 
long long writeFloat (float data, bool little_endian_data=true)
 Writes a single entry. Returns the number of bytes written. More...
 
long long writeUInt64 (unsigned long long data, bool little_endian_data=true)
 Writes a single entry. Returns the number of bytes written. More...
 
long long writeSInt64 (long long data, bool little_endian_data=true)
 Writes a single entry. Returns the number of bytes written. More...
 
long long writeUInt32 (unsigned int data, bool little_endian_data=true)
 Writes a single entry. Returns the number of bytes written. More...
 
long long writeSInt32 (int data, bool little_endian_data=true)
 Writes a single entry. Returns the number of bytes written. More...
 
long long writeUInt16 (unsigned short data, bool little_endian_data=true)
 Writes a single entry. Returns the number of bytes written. More...
 
long long writeSInt16 (short data, bool little_endian_data=true)
 Writes a single entry. Returns the number of bytes written. More...
 
long long writeUInt8 (unsigned char data)
 Writes a single entry. Returns the number of bytes written. More...
 
long long writeSInt8 (char data)
 Writes a single entry. Returns the number of bytes written. More...
 
long long writeDouble (const double *buffer, long long count, bool little_endian_data=true)
 Writes multiple entries. Returns the number of bytes written. More...
 
long long writeFloat (const float *buffer, long long count, bool little_endian_data=true)
 Writes multiple entries. Returns the number of bytes written. More...
 
long long writeUInt64 (const unsigned long long *buffer, long long count, bool little_endian_data=true)
 Writes multiple entries. Returns the number of bytes written. More...
 
long long writeSInt64 (const long long *buffer, long long count, bool little_endian_data=true)
 Writes multiple entries. Returns the number of bytes written. More...
 
long long writeUInt32 (const unsigned int *buffer, long long count, bool little_endian_data=true)
 Writes multiple entries. Returns the number of bytes written. More...
 
long long writeSInt32 (const int *buffer, long long count, bool little_endian_data=true)
 Writes multiple entries. Returns the number of bytes written. More...
 
long long writeUInt16 (const unsigned short *buffer, long long count, bool little_endian_data=true)
 Writes multiple entries. Returns the number of bytes written. More...
 
long long writeSInt16 (const short *buffer, long long count, bool little_endian_data=true)
 Writes multiple entries. Returns the number of bytes written. More...
 
long long writeUInt8 (const unsigned char *buffer, long long count)
 Writes multiple entries. Returns the number of bytes written. More...
 
long long writeSInt8 (const char *buffer, long long count)
 Writes multiple entries. Returns the number of bytes written. More...
 
- Public Member Functions inherited from vl::Object
 Object ()
 Constructor. More...
 
 Object (const Object &other)
 Copy constructor: copies the name, ref count mutex and user data. More...
 
Objectoperator= (const Object &other)
 Copy operator: copies the object's name, ref count mutex and user data. More...
 
const std::string & objectName () const
 The name of the object, by default set to the object's class name. More...
 
void setObjectName (const char *name)
 The name of the object, by default set to the object's class name in debug builds. More...
 
void setObjectName (const std::string &name)
 The name of the object, by default set to the object's class name in debug builds. More...
 
void setRefCountMutex (IMutex *mutex)
 The mutex used to protect the reference counting of an Object across multiple threads. More...
 
IMutexrefCountMutex ()
 The mutex used to protect the reference counting of an Object across multiple threads. More...
 
const IMutexrefCountMutex () const
 The mutex used to protect the reference counting of an Object across multiple threads. More...
 
int referenceCount () const
 Returns the number of references of an object. More...
 
void incReference () const
 Increments the reference count of an object. More...
 
void decReference ()
 Decrements the reference count of an object and deletes it if both automaticDelete() is true the count reaches 0. More...
 
void setAutomaticDelete (bool autodel_on)
 If set to true the Object is deleted when its reference count reaches 0. More...
 
bool automaticDelete () const
 If set to true the Object is deleted when its reference count reaches 0. More...
 
template<class T >
T * as ()
 Casts an Object to the specified class. More...
 
template<class T >
const T * as () const
 Casts an Object to the specified class. More...
 

Protected Member Functions

 QtFile (const QtFile &other)
 
virtual long long read_Implementation (void *buffer, long long byte_count)
 
virtual long long write_Implementation (const void *buffer, long long byte_count)
 
virtual long long position_Implementation () const
 
virtual bool seekSet_Implementation (long long offset)
 
 QtFile (const QtFile &other)
 
virtual long long read_Implementation (void *buffer, long long byte_count)
 
virtual long long write_Implementation (const void *buffer, long long byte_count)
 
virtual long long position_Implementation () const
 
virtual bool seekSet_Implementation (long long offset)
 
 QtFile (const QtFile &other)
 
virtual long long read_Implementation (void *buffer, long long byte_count)
 
virtual long long write_Implementation (const void *buffer, long long byte_count)
 
virtual long long position_Implementation () const
 
virtual bool seekSet_Implementation (long long offset)
 
- Protected Member Functions inherited from vl::VirtualFile
 VirtualFile (const VirtualFile &other)
 
long long write64 (const void *buffer, long long count, bool little_endian_data=true)
 
long long write32 (const void *buffer, long long count, bool little_endian_data=true)
 
long long write16 (const void *buffer, long long count, bool little_endian_data=true)
 
long long read64 (void *buffer, long long count, bool little_endian_data=true)
 
long long read32 (void *buffer, long long count, bool little_endian_data=true)
 
long long read16 (void *buffer, long long count, bool little_endian_data=true)
 
long long write64 (const void *buffer, bool little_endian_data=true)
 
long long write32 (const void *buffer, bool little_endian_data=true)
 
long long write16 (const void *buffer, bool little_endian_data=true)
 
long long read64 (void *buffer, bool little_endian_data=true)
 
long long read32 (void *buffer, bool little_endian_data=true)
 
long long read16 (void *buffer, bool little_endian_data=true)
 
- Protected Member Functions inherited from vl::Object
virtual ~Object ()
 

Protected Attributes

QFile mQFile
 
- Protected Attributes inherited from vl::VirtualFile
String mPath
 
- Protected Attributes inherited from vl::Object
std::string mObjectName
 
IMutexmRefCountMutex
 
int mReferenceCount
 
bool mAutomaticDelete
 

Friends

class QtDirectory
 

Detailed Description

A VirtualFile that uses Qt's QFile.

See also

Definition at line 61 of file QtFile.hpp.

Constructor & Destructor Documentation

◆ QtFile() [1/6]

vl::QtFile::QtFile ( const QtFile other)
inlineprotected

Definition at line 67 of file QtFile.hpp.

Referenced by clone().

◆ QtFile() [2/6]

QtFile::QtFile ( const String path = String())

Definition at line 39 of file QtFile.cpp.

References vl::VirtualFile::setPath().

◆ ~QtFile() [1/3]

QtFile::~QtFile ( )

Definition at line 44 of file QtFile.cpp.

References close().

◆ QtFile() [3/6]

vl::QtFile::QtFile ( const QtFile other)
inlineprotected

Definition at line 67 of file QtFile.hpp.

◆ QtFile() [4/6]

vl::QtFile::QtFile ( const String path = String())

◆ ~QtFile() [2/3]

vl::QtFile::~QtFile ( )

◆ QtFile() [5/6]

vl::QtFile::QtFile ( const QtFile other)
inlineprotected

Definition at line 68 of file QtFile.hpp.

◆ QtFile() [6/6]

vl::QtFile::QtFile ( const String path = String())

◆ ~QtFile() [3/3]

vl::QtFile::~QtFile ( )

Member Function Documentation

◆ clone() [1/3]

ref< VirtualFile > QtFile::clone ( ) const
virtual

Creates a clone of this class instance.

Implements vl::VirtualFile.

Definition at line 142 of file QtFile.cpp.

References QtFile().

◆ clone() [2/3]

virtual ref<VirtualFile> vl::QtFile::clone ( ) const
virtual

Creates a clone of this class instance.

Implements vl::VirtualFile.

◆ clone() [3/3]

virtual ref<VirtualFile> vl::QtFile::clone ( ) const
virtual

Creates a clone of this class instance.

Implements vl::VirtualFile.

◆ close() [1/3]

virtual void vl::QtFile::close ( )
virtual

Closes the file.

Implements vl::VirtualFile.

◆ close() [2/3]

void QtFile::close ( )
virtual

Closes the file.

Implements vl::VirtualFile.

Definition at line 86 of file QtFile.cpp.

References mQFile.

Referenced by ~QtFile().

◆ close() [3/3]

virtual void vl::QtFile::close ( )
virtual

Closes the file.

Implements vl::VirtualFile.

◆ exists() [1/3]

virtual bool vl::QtFile::exists ( ) const
virtual

Returns true if the file exists.

Implements vl::VirtualFile.

◆ exists() [2/3]

bool QtFile::exists ( ) const
virtual

Returns true if the file exists.

Implements vl::VirtualFile.

Definition at line 96 of file QtFile.cpp.

References vl::String::empty(), and vl::VirtualFile::path().

Referenced by vl::QtDirectory::listFiles(), and vl::QtDirectory::qtFile().

◆ exists() [3/3]

virtual bool vl::QtFile::exists ( ) const
virtual

Returns true if the file exists.

Implements vl::VirtualFile.

◆ isOpen() [1/3]

bool QtFile::isOpen ( ) const
virtual

Returns true if the file has been opened.

Implements vl::VirtualFile.

Definition at line 81 of file QtFile.cpp.

References mQFile.

Referenced by open().

◆ isOpen() [2/3]

virtual bool vl::QtFile::isOpen ( ) const
virtual

Returns true if the file has been opened.

Implements vl::VirtualFile.

◆ isOpen() [3/3]

virtual bool vl::QtFile::isOpen ( ) const
virtual

Returns true if the file has been opened.

Implements vl::VirtualFile.

◆ open() [1/6]

bool vl::QtFile::open ( const String path,
EOpenMode  mode 
)

The specified path is relative to the parent directory. See setPhysicalPath().

◆ open() [2/6]

bool QtFile::open ( const String path,
EOpenMode  mode 
)

The specified path is relative to the parent directory. See setPhysicalPath().

Definition at line 49 of file QtFile.cpp.

References vl::VirtualFile::setPath().

◆ open() [3/6]

bool vl::QtFile::open ( const String path,
EOpenMode  mode 
)

The specified path is relative to the parent directory. See setPhysicalPath().

◆ open() [4/6]

bool QtFile::open ( EOpenMode  mode)
virtual

Opens the file in the specified mode.

Implements vl::VirtualFile.

Definition at line 55 of file QtFile.cpp.

References vl::Log::error(), isOpen(), mQFile, vl::OM_ReadOnly, and vl::VirtualFile::path().

◆ open() [5/6]

virtual bool vl::QtFile::open ( EOpenMode  mode)
virtual

Opens the file in the specified mode.

Implements vl::VirtualFile.

◆ open() [6/6]

virtual bool vl::QtFile::open ( EOpenMode  mode)
virtual

Opens the file in the specified mode.

Implements vl::VirtualFile.

◆ operator=() [1/3]

QtFile& vl::QtFile::operator= ( const QtFile other)
inline

Definition at line 88 of file QtFile.hpp.

◆ operator=() [2/3]

QtFile& vl::QtFile::operator= ( const QtFile other)
inline

Definition at line 88 of file QtFile.hpp.

◆ operator=() [3/3]

QtFile& vl::QtFile::operator= ( const QtFile other)
inline

Definition at line 89 of file QtFile.hpp.

◆ position_Implementation() [1/3]

long long QtFile::position_Implementation ( ) const
protectedvirtual

Implements vl::VirtualFile.

Definition at line 121 of file QtFile.cpp.

References vl::Log::error(), and mQFile.

◆ position_Implementation() [2/3]

virtual long long vl::QtFile::position_Implementation ( ) const
protectedvirtual

Implements vl::VirtualFile.

◆ position_Implementation() [3/3]

virtual long long vl::QtFile::position_Implementation ( ) const
protectedvirtual

Implements vl::VirtualFile.

◆ read_Implementation() [1/3]

long long QtFile::read_Implementation ( void *  buffer,
long long  byte_count 
)
protectedvirtual

Implements vl::VirtualFile.

Definition at line 101 of file QtFile.cpp.

References vl::Log::error(), and mQFile.

◆ read_Implementation() [2/3]

virtual long long vl::QtFile::read_Implementation ( void *  buffer,
long long  byte_count 
)
protectedvirtual

Implements vl::VirtualFile.

◆ read_Implementation() [3/3]

virtual long long vl::QtFile::read_Implementation ( void *  buffer,
long long  byte_count 
)
protectedvirtual

Implements vl::VirtualFile.

◆ seekSet_Implementation() [1/3]

bool QtFile::seekSet_Implementation ( long long  offset)
protectedvirtual

Implements vl::VirtualFile.

Definition at line 131 of file QtFile.cpp.

References vl::Log::error(), and mQFile.

◆ seekSet_Implementation() [2/3]

virtual bool vl::QtFile::seekSet_Implementation ( long long  offset)
protectedvirtual

Implements vl::VirtualFile.

◆ seekSet_Implementation() [3/3]

virtual bool vl::QtFile::seekSet_Implementation ( long long  offset)
protectedvirtual

Implements vl::VirtualFile.

◆ size() [1/3]

virtual long long vl::QtFile::size ( ) const
virtual

Returns the file size in bytes or -1 on error.

Implements vl::VirtualFile.

◆ size() [2/3]

long long QtFile::size ( ) const
virtual

Returns the file size in bytes or -1 on error.

Implements vl::VirtualFile.

Definition at line 91 of file QtFile.cpp.

References vl::VirtualFile::path().

◆ size() [3/3]

virtual long long vl::QtFile::size ( ) const
virtual

Returns the file size in bytes or -1 on error.

Implements vl::VirtualFile.

◆ write_Implementation() [1/3]

long long QtFile::write_Implementation ( const void *  buffer,
long long  byte_count 
)
protectedvirtual

Implements vl::VirtualFile.

Definition at line 111 of file QtFile.cpp.

References vl::Log::error(), and mQFile.

◆ write_Implementation() [2/3]

virtual long long vl::QtFile::write_Implementation ( const void *  buffer,
long long  byte_count 
)
protectedvirtual

Implements vl::VirtualFile.

◆ write_Implementation() [3/3]

virtual long long vl::QtFile::write_Implementation ( const void *  buffer,
long long  byte_count 
)
protectedvirtual

Implements vl::VirtualFile.

Friends And Related Function Documentation

◆ QtDirectory

QtDirectory
friend

Definition at line 65 of file QtFile.hpp.

Member Data Documentation

◆ mQFile

QFile vl::QtFile::mQFile
protected

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