DART  6.7.3
dart::common::LocalResource Class Reference

#include <LocalResource.hpp>

Inheritance diagram for dart::common::LocalResource:
dart::common::Resource

Public Types

enum  SeekType { SEEKTYPE_CUR , SEEKTYPE_END , SEEKTYPE_SET }
 Position to seek relative to. More...
 

Public Member Functions

 LocalResource (const std::string &_path)
 
virtual ~LocalResource ()
 
 LocalResource (const LocalResource &_other)=delete
 
LocalResourceoperator= (const LocalResource &_other)=delete
 
bool isGood () const
 Returns true if the resource is open and in a valid state. More...
 
std::size_t getSize () override
 Return the size of the resource, in bytes. More...
 
std::size_t tell () override
 Return the current value of the position indicator. More...
 
bool seek (ptrdiff_t _origin, SeekType _mode) override
 Set the position indicator to a new position. More...
 
std::size_t read (void *_buffer, std::size_t _size, std::size_t _count) override
 Read _count element, each of size _size, into _buffer. More...
 
virtual std::string readAll ()
 Reads all data from this resource, and returns it as a string. More...
 

Private Attributes

std::FILE * mFile
 

Member Enumeration Documentation

◆ SeekType

Position to seek relative to.

Enumerator
SEEKTYPE_CUR 

Current position.

SEEKTYPE_END 

End of file.

SEEKTYPE_SET 

Begining of file.

Constructor & Destructor Documentation

◆ LocalResource() [1/2]

dart::common::LocalResource::LocalResource ( const std::string &  _path)
explicit

◆ ~LocalResource()

dart::common::LocalResource::~LocalResource ( )
virtual

◆ LocalResource() [2/2]

dart::common::LocalResource::LocalResource ( const LocalResource _other)
delete

Member Function Documentation

◆ getSize()

std::size_t dart::common::LocalResource::getSize ( )
overridevirtual

Return the size of the resource, in bytes.

Implements dart::common::Resource.

◆ isGood()

bool dart::common::LocalResource::isGood ( ) const

Returns true if the resource is open and in a valid state.

◆ operator=()

LocalResource& dart::common::LocalResource::operator= ( const LocalResource _other)
delete

◆ read()

std::size_t dart::common::LocalResource::read ( void *  _buffer,
std::size_t  _size,
std::size_t  _count 
)
overridevirtual

Read _count element, each of size _size, into _buffer.

Parameters
[out]_bufferPointer to a block of memory with a size of at least (_size * _count) bytes.
[in]_sizeSize, in bytes, of each element.
[in]_countNumber of elements, each of _size bytes.
Note
This method has the same API as the standard fread function.

Implements dart::common::Resource.

◆ readAll()

std::string dart::common::Resource::readAll ( )
virtualinherited

Reads all data from this resource, and returns it as a string.

Returns
The string retrieved from the resource.
Exceptions
std::runtime_errorwhen failed to read sucessfully.

◆ seek()

bool dart::common::LocalResource::seek ( ptrdiff_t  _offset,
SeekType  _origin 
)
overridevirtual

Set the position indicator to a new position.

Parameters
[in]_offsetOffset, in bytes, relative to _origin.
[in]_originPosition used as the reference of _offset.
Note
This method has the same API as the standard fseek function.

Implements dart::common::Resource.

◆ tell()

std::size_t dart::common::LocalResource::tell ( )
overridevirtual

Return the current value of the position indicator.

Note
This method has the same API as the standard ftell function.

Implements dart::common::Resource.

Member Data Documentation

◆ mFile

std::FILE* dart::common::LocalResource::mFile
private