|
Beatmup
|
A key-value pair set storing pieces of arbitrary data (chunks) under string keys. More...
#include <chunkfile.h>
Public Member Functions | |
| virtual void | open ()=0 |
| Opens the collection to read chunks from it. More... | |
| virtual void | close ()=0 |
| Closes the collection after a reading session. More... | |
| virtual size_t | size () const =0 |
| Returns the number of chunks available in the collection after it is opened. More... | |
| virtual bool | chunkExists (const std::string &id) const =0 |
| Check if a specific chunk exists. More... | |
| virtual chunksize_t | chunkSize (const std::string &id) const =0 |
| Retrieves size of a specific chunk. More... | |
| virtual chunksize_t | fetch (const std::string &id, void *data, const chunksize_t limit)=0 |
| Reads a chunk. More... | |
| virtual void | save (const std::string &filename, bool append=false)=0 |
| Saves the collection to a file. More... | |
| template<typename datatype > | |
| datatype | read (const std::string &id) |
| Reads a chunk and casts it into a given type. More... | |
| template<typename datatype > | |
| std::vector< datatype > | readVector (const std::string &id) |
| Reads a chunk into a vector of a specific type. More... | |
| template<> | |
| std::string | read (const std::string &id) |
Public Member Functions inherited from Beatmup::Object | |
| virtual | ~Object () |
A key-value pair set storing pieces of arbitrary data (chunks) under string keys.
A chunk is a header and a piece of data packed in memory like this: (idLength[4], id[idLength], size[sizeof(chunksize_t)], data[size]) ChunkCollection defines an interface to retrieve chunks by their ids.
Definition at line 36 of file chunkfile.h.
|
pure virtual |
Opens the collection to read chunks from it.
Implemented in Beatmup::Python::WritableChunkCollection, Beatmup::ChunkFile, and Beatmup::Android::ChunkAsset.
|
pure virtual |
Closes the collection after a reading session.
Implemented in Beatmup::Python::WritableChunkCollection, Beatmup::ChunkFile, and Beatmup::Android::ChunkAsset.
|
pure virtual |
Returns the number of chunks available in the collection after it is opened.
Implemented in Beatmup::Python::WritableChunkCollection, and Beatmup::ChunkStream.
|
pure virtual |
Check if a specific chunk exists.
| [in] | id | The chunk id |
true if the chunk exists in the collection. Implemented in Beatmup::Python::WritableChunkCollection, and Beatmup::ChunkStream.
|
pure virtual |
Retrieves size of a specific chunk.
| [in] | id | The chunk id |
Implemented in Beatmup::Python::WritableChunkCollection, and Beatmup::ChunkStream.
|
pure virtual |
Reads a chunk.
The collection is expected to be opened.
| [in] | id | Wanted chunk id. |
| [out] | data | A buffer to write out the wanted chunk content. |
| [in] | limit | The buffer capacity in bytes. |
limit is returned (number of bytes actually written); if no chunk found, 0 is returned. Implemented in Beatmup::Python::WritableChunkCollection, and Beatmup::ChunkStream.
|
pure virtual |
Saves the collection to a file.
| [in] | filename | The name of the file to write chunks to |
| [in] | append | If true, writing to the end of the file (keeping the existing content). Rewriting the file otherwise. |
Implemented in Beatmup::Python::WritableChunkCollection, and Beatmup::ChunkStream.
|
inline |
Reads a chunk and casts it into a given type.
| [in] | id | The searched chunk id. |
Definition at line 91 of file chunkfile.h.
|
inline |
Reads a chunk into a vector of a specific type.
| [in] | id | The searched chunk id. |
Definition at line 106 of file chunkfile.h.
|
inline |