Visualization Library v1.0.3

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

vl::VirtualFile Class Reference

An abstract class representing a file. More...

#include <VirtualFile.hpp>

Inheritance diagram for vl::VirtualFile:
vl::Object vl::DiskFile vl::GZipCodec vl::MemoryFile vl::ZippedFile

List of all members.

Public Member Functions

 VirtualFile ()
 Constructor.
unsigned int crc32 ()
 Computes the crc32 of the entire file.
MD5CheckSum md5 ()
 Computes the md5 of the entire file.
virtual bool open (EOpenMode mode)=0
 Opens the file in the specified mode.
virtual bool isOpen () const =0
 Returns true if the file has been opened.
virtual bool exists () const =0
 Returns true if the file exists.
virtual void close ()=0
 Closes the file.
virtual long long size () const =0
 Returns the size of the file in bytes.
virtual ref< VirtualFileclone () const =0
 Creates a clone of this class instance.
VirtualFileoperator= (const VirtualFile &other)
const Stringpath () const
 Returns the path of the file.
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.
long long peek (void *buffer, long long byte_count)
 Reads byte_count bytes and returns to the original position.
long long read (void *buffer, long long byte_count)
 Reads byte_count bytes from a file. Returns the number of bytes actually read.
long long write (const void *buffer, long long byte_count)
 Writes byte_count bytes to a file. Returns the number of bytes actually written.
long long position () const
 Returns the current position in the file.
bool seekSet (long long offset)
 Changes the current read/write position of a file.
bool seekCur (long long offset)
 Changes the current read/write position of a file.
bool seekEnd (long long offset)
 Changes the current read/write position of a file.
bool endOfFile () const
 Returns true if position() >= size()
long long load (std::vector< char > &data)
 Loads the entire file in the specified vector.
long long load (void *buffer, long long max=-1)
 Loads the entire file in the specified buffer.
double readDouble (bool little_endian_data=true)
 Reads single entry.
float readFloat (bool little_endian_data=true)
 Reads single entry.
unsigned long long readUInt64 (bool little_endian_data=true)
 Reads single entry.
long long readSInt64 (bool little_endian_data=true)
 Reads single entry.
unsigned int readUInt32 (bool little_endian_data=true)
 Reads single entry.
int readSInt32 (bool little_endian_data=true)
 Reads single entry.
unsigned short readUInt16 (bool little_endian_data=true)
 Reads single entry.
short readSInt16 (bool little_endian_data=true)
 Reads single entry.
unsigned char readUInt8 ()
 Reads single entry.
char readSInt8 ()
 Reads single entry.
long long readDouble (double *buffer, long long count, bool little_endian_data=true)
 Reads multiple entries. Returns the number of bytes read.
long long readFloat (float *buffer, long long count, bool little_endian_data=true)
 Reads multiple entries. Returns the number of bytes read.
long long readUInt64 (unsigned long long *buffer, long long count, bool little_endian_data=true)
 Reads multiple entries. Returns the number of bytes read.
long long readSInt64 (long long *buffer, long long count, bool little_endian_data=true)
 Reads multiple entries. Returns the number of bytes read.
long long readUInt32 (unsigned int *buffer, long long count, bool little_endian_data=true)
 Reads multiple entries. Returns the number of bytes read.
long long readSInt32 (int *buffer, long long count, bool little_endian_data=true)
 Reads multiple entries. Returns the number of bytes read.
long long readUInt16 (unsigned short *buffer, long long count, bool little_endian_data=true)
 Reads multiple entries. Returns the number of bytes read.
long long readSInt16 (short *buffer, long long count, bool little_endian_data=true)
 Reads multiple entries. Returns the number of bytes read.
long long readUInt8 (unsigned char *buffer, long long count)
 Reads multiple entries. Returns the number of bytes read.
long long readSInt8 (char *buffer, long long count)
 Reads multiple entries. Returns the number of bytes read.
long long writeDouble (double data, bool little_endian_data=true)
 Writes a single entry. Returns the number of bytes written.
long long writeFloat (float data, bool little_endian_data=true)
 Writes a single entry. Returns the number of bytes written.
long long writeUInt64 (unsigned long long data, bool little_endian_data=true)
 Writes a single entry. Returns the number of bytes written.
long long writeSInt64 (long long data, bool little_endian_data=true)
 Writes a single entry. Returns the number of bytes written.
long long writeUInt32 (unsigned int data, bool little_endian_data=true)
 Writes a single entry. Returns the number of bytes written.
long long writeSInt32 (int data, bool little_endian_data=true)
 Writes a single entry. Returns the number of bytes written.
long long writeUInt16 (unsigned short data, bool little_endian_data=true)
 Writes a single entry. Returns the number of bytes written.
long long writeSInt16 (short data, bool little_endian_data=true)
 Writes a single entry. Returns the number of bytes written.
long long writeUInt8 (unsigned char data)
 Writes a single entry. Returns the number of bytes written.
long long writeSInt8 (char data)
 Writes a single entry. Returns the number of bytes written.
long long writeDouble (const double *buffer, long long count, bool little_endian_data=true)
 Writes multiple entries. Returns the number of bytes written.
long long writeFloat (const float *buffer, long long count, bool little_endian_data=true)
 Writes multiple entries. Returns the number of bytes written.
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.
long long writeSInt64 (const long long *buffer, long long count, bool little_endian_data=true)
 Writes multiple entries. Returns the number of bytes written.
long long writeUInt32 (const unsigned int *buffer, long long count, bool little_endian_data=true)
 Writes multiple entries. Returns the number of bytes written.
long long writeSInt32 (const int *buffer, long long count, bool little_endian_data=true)
 Writes multiple entries. Returns the number of bytes written.
long long writeUInt16 (const unsigned short *buffer, long long count, bool little_endian_data=true)
 Writes multiple entries. Returns the number of bytes written.
long long writeSInt16 (const short *buffer, long long count, bool little_endian_data=true)
 Writes multiple entries. Returns the number of bytes written.
long long writeUInt8 (const unsigned char *buffer, long long count)
 Writes multiple entries. Returns the number of bytes written.
long long writeSInt8 (const char *buffer, long long count)
 Writes multiple entries. Returns the number of bytes written.

Protected Member Functions

 VirtualFile (const VirtualFile &other)
virtual long long read_Implementation (void *buffer, long long byte_count)=0
virtual long long write_Implementation (const void *buffer, long long byte_count)=0
virtual long long position_Implementation () const =0
virtual bool seekSet_Implementation (long long offset)=0
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 Attributes

String mPath

Detailed Description

An abstract class representing a file.

See also:

Definition at line 60 of file VirtualFile.hpp.


Constructor & Destructor Documentation

vl::VirtualFile::VirtualFile ( const VirtualFile other ) [inline, protected]

Definition at line 65 of file VirtualFile.hpp.

vl::VirtualFile::VirtualFile (  ) [inline]

Constructor.

Definition at line 69 of file VirtualFile.hpp.


Member Function Documentation

unsigned int VirtualFile::crc32 (  )

Computes the crc32 of the entire file.

Definition at line 43 of file VirtualFile.cpp.

References close(), vl::CRC32CheckSum::compute(), vl::OM_ReadOnly, and open().

MD5CheckSum VirtualFile::md5 (  )

Computes the md5 of the entire file.

Definition at line 57 of file VirtualFile.cpp.

References close(), vl::MD5CheckSum::compute(), vl::OM_ReadOnly, and open().

virtual bool vl::VirtualFile::open ( EOpenMode  mode ) [pure virtual]
virtual bool vl::VirtualFile::isOpen (  ) const [pure virtual]

Returns true if the file has been opened.

Implemented in vl::DiskFile, vl::GZipCodec, vl::MemoryFile, and vl::ZippedFile.

Referenced by vl::MemoryFile::copy(), vl::loadImage(), vl::loadRAW(), and peek().

virtual bool vl::VirtualFile::exists (  ) const [pure virtual]

Returns true if the file exists.

Implemented in vl::DiskFile, vl::GZipCodec, vl::MemoryFile, and vl::ZippedFile.

virtual void vl::VirtualFile::close (  ) [pure virtual]
virtual long long vl::VirtualFile::size (  ) const [pure virtual]
virtual ref<VirtualFile> vl::VirtualFile::clone (  ) const [pure virtual]

Creates a clone of this class instance.

Implemented in vl::DiskFile, vl::GZipCodec, vl::MemoryFile, and vl::ZippedFile.

VirtualFile& vl::VirtualFile::operator= ( const VirtualFile other ) [inline]

Definition at line 95 of file VirtualFile.hpp.

References mPath.

const String& vl::VirtualFile::path (  ) const [inline]
void vl::VirtualFile::setPath ( const String name ) [inline]

Changes the path bound to a VirtualFile. Use carefully this function, you shouldn't rename a VirtualFile managed by a VirtualDirectory.

Definition at line 101 of file VirtualFile.hpp.

References vl::String::normalizeSlashes().

Referenced by vl::MemoryDirectory::addFile(), vl::DiskFile::DiskFile(), vl::GZipCodec::GZipCodec(), vl::DiskFile::open(), and vl::GZipCodec::setStream().

long long VirtualFile::peek ( void *  buffer,
long long  byte_count 
)

Reads byte_count bytes and returns to the original position.

Returns the number of bytes read.

Definition at line 68 of file VirtualFile.cpp.

References vl::Log::error(), isOpen(), position(), read(), and seekSet().

long long VirtualFile::read ( void *  buffer,
long long  byte_count 
)
long long VirtualFile::write ( const void *  buffer,
long long  byte_count 
)

Writes byte_count bytes to a file. Returns the number of bytes actually written.

Definition at line 90 of file VirtualFile.cpp.

References write_Implementation().

Referenced by vl::GZipCodec::close(), vl::saveDICOM(), vl::saveTGA(), vl::saveTIFF(), vl::VLXSerializer::saveVLT(), write16(), write32(), write64(), vl::GZipCodec::write_Implementation(), writeSInt8(), and writeUInt8().

long long VirtualFile::position (  ) const
bool VirtualFile::seekSet ( long long  offset )
bool VirtualFile::seekCur ( long long  offset )

Changes the current read/write position of a file.

Definition at line 121 of file VirtualFile.cpp.

References position(), and seekSet().

Referenced by vl::A3DSLoader::skipChunk().

bool VirtualFile::seekEnd ( long long  offset )

Changes the current read/write position of a file.

Definition at line 126 of file VirtualFile.cpp.

References seekSet(), and size().

Referenced by vl::isTGA(), and vl::GZipCodec::uncompressedSize().

bool vl::VirtualFile::endOfFile (  ) const [inline]

Returns true if position() >= size()

Definition at line 126 of file VirtualFile.hpp.

Referenced by vl::A3DSLoader::parse3DS().

long long VirtualFile::load ( std::vector< char > &  data )

Loads the entire file in the specified vector.

Returns the number of bytes read. The file must be closed before calling this function.

Definition at line 131 of file VirtualFile.cpp.

References size().

Referenced by vl::DaeLoader::load(), and vl::String::loadText().

long long VirtualFile::load ( void *  buffer,
long long  max = -1 
)

Loads the entire file in the specified buffer.

Returns the number of bytes read. The file must be closed before calling this function.

Definition at line 140 of file VirtualFile.cpp.

References close(), vl::Log::error(), vl::OM_ReadOnly, open(), path(), read(), and size().

double VirtualFile::readDouble ( bool  little_endian_data = true )

Reads single entry.

Definition at line 159 of file VirtualFile.cpp.

References read64().

Referenced by vl::PlyLoader::PlyScalar::read(), and vl::VLXParserVLB::readValue().

float VirtualFile::readFloat ( bool  little_endian_data = true )
unsigned long long VirtualFile::readUInt64 ( bool  little_endian_data = true )

Reads single entry.

Definition at line 173 of file VirtualFile.cpp.

References read64().

long long VirtualFile::readSInt64 ( bool  little_endian_data = true )

Reads single entry.

Definition at line 180 of file VirtualFile.cpp.

References read64().

unsigned int VirtualFile::readUInt32 ( bool  little_endian_data = true )
int VirtualFile::readSInt32 ( bool  little_endian_data = true )

Reads single entry.

Definition at line 194 of file VirtualFile.cpp.

References read32().

Referenced by vl::PlyLoader::PlyScalar::read().

unsigned short VirtualFile::readUInt16 ( bool  little_endian_data = true )
short VirtualFile::readSInt16 ( bool  little_endian_data = true )

Reads single entry.

Definition at line 208 of file VirtualFile.cpp.

References read16().

Referenced by vl::PlyLoader::PlyScalar::read().

unsigned char VirtualFile::readUInt8 (  )
char VirtualFile::readSInt8 (  )

Reads single entry.

Definition at line 222 of file VirtualFile.cpp.

References read().

Referenced by vl::PlyLoader::PlyScalar::read().

long long VirtualFile::readDouble ( double *  buffer,
long long  count,
bool  little_endian_data = true 
)

Reads multiple entries. Returns the number of bytes read.

Definition at line 231 of file VirtualFile.cpp.

References read64().

long long VirtualFile::readFloat ( float *  buffer,
long long  count,
bool  little_endian_data = true 
)

Reads multiple entries. Returns the number of bytes read.

Definition at line 236 of file VirtualFile.cpp.

References read32().

long long VirtualFile::readUInt64 ( unsigned long long *  buffer,
long long  count,
bool  little_endian_data = true 
)

Reads multiple entries. Returns the number of bytes read.

Definition at line 241 of file VirtualFile.cpp.

References read64().

long long VirtualFile::readSInt64 ( long long *  buffer,
long long  count,
bool  little_endian_data = true 
)

Reads multiple entries. Returns the number of bytes read.

Definition at line 246 of file VirtualFile.cpp.

References read64().

long long VirtualFile::readUInt32 ( unsigned int *  buffer,
long long  count,
bool  little_endian_data = true 
)

Reads multiple entries. Returns the number of bytes read.

Definition at line 251 of file VirtualFile.cpp.

References read32().

long long VirtualFile::readSInt32 ( int *  buffer,
long long  count,
bool  little_endian_data = true 
)

Reads multiple entries. Returns the number of bytes read.

Definition at line 256 of file VirtualFile.cpp.

References read32().

long long VirtualFile::readUInt16 ( unsigned short *  buffer,
long long  count,
bool  little_endian_data = true 
)

Reads multiple entries. Returns the number of bytes read.

Definition at line 261 of file VirtualFile.cpp.

References read16().

long long VirtualFile::readSInt16 ( short *  buffer,
long long  count,
bool  little_endian_data = true 
)

Reads multiple entries. Returns the number of bytes read.

Definition at line 266 of file VirtualFile.cpp.

References read16().

long long VirtualFile::readUInt8 ( unsigned char *  buffer,
long long  count 
)

Reads multiple entries. Returns the number of bytes read.

Definition at line 271 of file VirtualFile.cpp.

References read().

long long VirtualFile::readSInt8 ( char *  buffer,
long long  count 
)

Reads multiple entries. Returns the number of bytes read.

Definition at line 276 of file VirtualFile.cpp.

References read().

long long VirtualFile::writeDouble ( double  data,
bool  little_endian_data = true 
)

Writes a single entry. Returns the number of bytes written.

Definition at line 283 of file VirtualFile.cpp.

References write64().

long long VirtualFile::writeFloat ( float  data,
bool  little_endian_data = true 
)

Writes a single entry. Returns the number of bytes written.

Definition at line 288 of file VirtualFile.cpp.

References write32().

long long VirtualFile::writeUInt64 ( unsigned long long  data,
bool  little_endian_data = true 
)

Writes a single entry. Returns the number of bytes written.

Definition at line 293 of file VirtualFile.cpp.

References write64().

long long VirtualFile::writeSInt64 ( long long  data,
bool  little_endian_data = true 
)

Writes a single entry. Returns the number of bytes written.

Definition at line 298 of file VirtualFile.cpp.

References write64().

long long VirtualFile::writeUInt32 ( unsigned int  data,
bool  little_endian_data = true 
)

Writes a single entry. Returns the number of bytes written.

Definition at line 303 of file VirtualFile.cpp.

References write32().

Referenced by vl::saveTGA(), and vl::saveTIFF().

long long VirtualFile::writeSInt32 ( int  data,
bool  little_endian_data = true 
)

Writes a single entry. Returns the number of bytes written.

Definition at line 308 of file VirtualFile.cpp.

References write32().

long long VirtualFile::writeUInt16 ( unsigned short  data,
bool  little_endian_data = true 
)

Writes a single entry. Returns the number of bytes written.

Definition at line 313 of file VirtualFile.cpp.

References write16().

Referenced by vl::saveTIFF().

long long VirtualFile::writeSInt16 ( short  data,
bool  little_endian_data = true 
)

Writes a single entry. Returns the number of bytes written.

Definition at line 318 of file VirtualFile.cpp.

References write16().

long long VirtualFile::writeUInt8 ( unsigned char  data )

Writes a single entry. Returns the number of bytes written.

Definition at line 323 of file VirtualFile.cpp.

References write().

long long VirtualFile::writeSInt8 ( char  data )

Writes a single entry. Returns the number of bytes written.

Definition at line 328 of file VirtualFile.cpp.

References write().

long long VirtualFile::writeDouble ( const double *  buffer,
long long  count,
bool  little_endian_data = true 
)

Writes multiple entries. Returns the number of bytes written.

Definition at line 335 of file VirtualFile.cpp.

References write64().

long long VirtualFile::writeFloat ( const float *  buffer,
long long  count,
bool  little_endian_data = true 
)

Writes multiple entries. Returns the number of bytes written.

Definition at line 340 of file VirtualFile.cpp.

References write32().

long long VirtualFile::writeUInt64 ( const unsigned long long *  buffer,
long long  count,
bool  little_endian_data = true 
)

Writes multiple entries. Returns the number of bytes written.

Definition at line 345 of file VirtualFile.cpp.

References write64().

long long VirtualFile::writeSInt64 ( const long long *  buffer,
long long  count,
bool  little_endian_data = true 
)

Writes multiple entries. Returns the number of bytes written.

Definition at line 350 of file VirtualFile.cpp.

References write64().

long long VirtualFile::writeUInt32 ( const unsigned int *  buffer,
long long  count,
bool  little_endian_data = true 
)

Writes multiple entries. Returns the number of bytes written.

Definition at line 355 of file VirtualFile.cpp.

References write32().

long long VirtualFile::writeSInt32 ( const int *  buffer,
long long  count,
bool  little_endian_data = true 
)

Writes multiple entries. Returns the number of bytes written.

Definition at line 360 of file VirtualFile.cpp.

References write32().

long long VirtualFile::writeUInt16 ( const unsigned short *  buffer,
long long  count,
bool  little_endian_data = true 
)

Writes multiple entries. Returns the number of bytes written.

Definition at line 365 of file VirtualFile.cpp.

References write16().

long long VirtualFile::writeSInt16 ( const short *  buffer,
long long  count,
bool  little_endian_data = true 
)

Writes multiple entries. Returns the number of bytes written.

Definition at line 370 of file VirtualFile.cpp.

References write16().

long long VirtualFile::writeUInt8 ( const unsigned char *  buffer,
long long  count 
)

Writes multiple entries. Returns the number of bytes written.

Definition at line 375 of file VirtualFile.cpp.

References write().

long long VirtualFile::writeSInt8 ( const char *  buffer,
long long  count 
)

Writes multiple entries. Returns the number of bytes written.

Definition at line 380 of file VirtualFile.cpp.

References write().

virtual long long vl::VirtualFile::read_Implementation ( void *  buffer,
long long  byte_count 
) [protected, pure virtual]

Implemented in vl::DiskFile, vl::GZipCodec, vl::MemoryFile, and vl::ZippedFile.

Referenced by read().

virtual long long vl::VirtualFile::write_Implementation ( const void *  buffer,
long long  byte_count 
) [protected, pure virtual]

Implemented in vl::DiskFile, vl::GZipCodec, vl::MemoryFile, and vl::ZippedFile.

Referenced by write().

virtual long long vl::VirtualFile::position_Implementation (  ) const [protected, pure virtual]

Implemented in vl::DiskFile, vl::GZipCodec, vl::MemoryFile, and vl::ZippedFile.

Referenced by position().

virtual bool vl::VirtualFile::seekSet_Implementation ( long long  offset ) [protected, pure virtual]

Implemented in vl::DiskFile, vl::GZipCodec, vl::MemoryFile, and vl::ZippedFile.

Referenced by seekSet().

long long VirtualFile::write64 ( const void *  buffer,
long long  count,
bool  little_endian_data = true 
) [protected]

Definition at line 387 of file VirtualFile.cpp.

References write().

Referenced by writeDouble(), writeSInt64(), and writeUInt64().

long long VirtualFile::write32 ( const void *  buffer,
long long  count,
bool  little_endian_data = true 
) [protected]

Definition at line 402 of file VirtualFile.cpp.

References write().

Referenced by writeFloat(), writeSInt32(), and writeUInt32().

long long VirtualFile::write16 ( const void *  buffer,
long long  count,
bool  little_endian_data = true 
) [protected]

Definition at line 417 of file VirtualFile.cpp.

References write().

Referenced by writeSInt16(), and writeUInt16().

long long VirtualFile::read64 ( void *  buffer,
long long  count,
bool  little_endian_data = true 
) [protected]

Definition at line 432 of file VirtualFile.cpp.

References read().

Referenced by readDouble(), readSInt64(), and readUInt64().

long long VirtualFile::read32 ( void *  buffer,
long long  count,
bool  little_endian_data = true 
) [protected]

Definition at line 452 of file VirtualFile.cpp.

References read().

Referenced by readFloat(), readSInt32(), and readUInt32().

long long VirtualFile::read16 ( void *  buffer,
long long  count,
bool  little_endian_data = true 
) [protected]

Definition at line 470 of file VirtualFile.cpp.

References read().

Referenced by readSInt16(), and readUInt16().

long long VirtualFile::write64 ( const void *  buffer,
bool  little_endian_data = true 
) [protected]

Definition at line 486 of file VirtualFile.cpp.

References write().

long long VirtualFile::write32 ( const void *  buffer,
bool  little_endian_data = true 
) [protected]

Definition at line 503 of file VirtualFile.cpp.

References write().

long long VirtualFile::write16 ( const void *  buffer,
bool  little_endian_data = true 
) [protected]

Definition at line 518 of file VirtualFile.cpp.

References write().

long long VirtualFile::read64 ( void *  buffer,
bool  little_endian_data = true 
) [protected]

Definition at line 531 of file VirtualFile.cpp.

References read().

long long VirtualFile::read32 ( void *  buffer,
bool  little_endian_data = true 
) [protected]

Definition at line 548 of file VirtualFile.cpp.

References read().

long long VirtualFile::read16 ( void *  buffer,
bool  little_endian_data = true 
) [protected]

Definition at line 563 of file VirtualFile.cpp.

References read().


Member Data Documentation

Definition at line 246 of file VirtualFile.hpp.

Referenced by operator=().


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

Visualization Library v1.0.3 Reference Documentation
Copyright Michele Bosi. All rights reserved.
Updated on Tue Feb 7 2017 00:55:08.
Permission is granted to use this page to write and publish articles regarding Visualization Library.