|
Beatmup
|
Stream of chunks. More...
#include <chunkfile.h>
Classes | |
| struct | ChunkDesc |
Public Member Functions | |
| size_t | size () const |
| Returns the number of chunks available in the collection after it is opened. More... | |
| bool | chunkExists (const std::string &id) const |
| Check if a specific chunk exists. More... | |
| chunksize_t | chunkSize (const std::string &id) const |
| Retrieves size of a specific chunk. More... | |
| chunksize_t | fetch (const std::string &id, void *data, const chunksize_t limit) |
| Reads a chunk. More... | |
| void | save (const std::string &filename, bool append=false) |
| Saves the collection to a file. More... | |
Public Member Functions inherited from Beatmup::ChunkCollection | |
| 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... | |
| 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 () |
Protected Member Functions | |
| ChunkStream (InputStream &stream) | |
| bool | parse () |
| Goes through the input stream to build the list of existing chunks. More... | |
Private Attributes | |
| std::map< std::string, ChunkDesc > | map |
| InputStream & | stream |
Stream of chunks.
Implements ChunkCollection from a streamed source.
Definition at line 132 of file chunkfile.h.
|
inlineprotected |
Definition at line 143 of file chunkfile.h.
|
protected |
Goes through the input stream to build the list of existing chunks.
Does not read the chunks content, only headers.
Definition at line 39 of file chunkfile.cpp.
|
inlinevirtual |
Returns the number of chunks available in the collection after it is opened.
Implements Beatmup::ChunkCollection.
Definition at line 152 of file chunkfile.h.
|
inlinevirtual |
Check if a specific chunk exists.
| [in] | id | The chunk id |
true if the chunk exists in the collection. Implements Beatmup::ChunkCollection.
Definition at line 154 of file chunkfile.h.
|
virtual |
Retrieves size of a specific chunk.
| [in] | id | The chunk id |
Implements Beatmup::ChunkCollection.
Definition at line 70 of file chunkfile.cpp.
|
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. Implements Beatmup::ChunkCollection.
Definition at line 76 of file chunkfile.cpp.
|
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. |
Implements Beatmup::ChunkCollection.
Definition at line 96 of file chunkfile.cpp.
|
private |
Definition at line 139 of file chunkfile.h.
|
private |
Definition at line 140 of file chunkfile.h.