blip  0.1
Asset Class Reference

An application asset file. More...

#include <Asset.hpp>

Public Member Functions

 ~Asset ()
 Destructor. More...
 
size_t read (byte_t *buf, size_t count)
 Read raw data from the asset file. More...
 
off_t seek (off_t offset, ccxx::SeekMode mode)
 Seek to a goven offset in the asset file. More...
 
const byte_t * getBuffer ()
 If the asset has been read into an in-memory buffer, get a pointer to that buffer. More...
 
off_t getLength ()
 Get the length of the asset file, in bytes. More...
 
off_t getBytesRemaining ()
 Get the number of bytes remaining to be read from the asset. More...
 
bool isAllocated () const
 Determine if the asset's internal buffer is allocated in ordinary RAM (as opposed to being memory-mapped). More...
 

Detailed Description

An application asset file.

See AssetManager for details about enumerating an application's assets.

This class provides a low-level interface for reading raw asset data. For a higher-level interface, use in conjunction with an AssetDataReader, which may also be passed to resource decoder classes such as PNGImageDecoder and WAVAudioDecoder.

Constructor & Destructor Documentation

◆ ~Asset()

~Asset ( )

Destructor.

Closes the asset file and/or deallocates the buffer.

Member Function Documentation

◆ getBuffer()

const byte_t * getBuffer ( )

If the asset has been read into an in-memory buffer, get a pointer to that buffer.

Returns
The pointer to the buffer, or NULL if the asset was not read into an in-memory buffer.
Exceptions
IOExceptionIf an I/O error occurs.

◆ getBytesRemaining()

off_t getBytesRemaining ( )

Get the number of bytes remaining to be read from the asset.

◆ getLength()

off_t getLength ( )

Get the length of the asset file, in bytes.

◆ isAllocated()

bool isAllocated ( ) const

Determine if the asset's internal buffer is allocated in ordinary RAM (as opposed to being memory-mapped).

◆ read()

size_t read ( byte_t *  buf,
size_t  count 
)

Read raw data from the asset file.

Parameters
bufThe buffer to read into.
countThe number of bytes to read.
Returns
The number of bytes actually read.
Exceptions
EOFExceptionIf the end of file is reached.
IOExceptionIf an I/O error occurs.

◆ seek()

off_t seek ( off_t  offset,
ccxx::SeekMode  mode 
)

Seek to a goven offset in the asset file.

Parameters
offsetThe offset.
modeThe seek mode.
Returns
The new offset.
Exceptions
IOExceptionIf an I/O error occurs.

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