Class AssetPack
Defined in File libcacaoasset.hpp
Class Documentation
-
class AssetPack
Interface for lazy access to an asset pack file.
Public Functions
-
Resource GetResource(const std::string &address)
Access a resource.
- Parameters:
address – The resource’s address
- Throws:
std::runtime_error – If the resource address provided is invalid
std::runtime_error – If the resource does not exist in the pack
- Returns:
The resource object
-
void DeleteResource(const std::string &address)
Remove a resource from the pack.
- Parameters:
address – The resource’s address
- Throws:
std::runtime_error – If the resource address provided is invalid
std::runtime_error – If the resource does not exist in the pack
-
std::vector<std::string> ListResources()
Get a list of resources in the pack.
- Returns:
A list of all resource addresses
-
std::vector<std::string> ListResourcesOfType(Resource::Type type)
Get a list of resources of a certain type in the pack.
- Throws:
std::runtime_error – If the provided type is a type of resource that cannot be embedded in a pack
- Returns:
A list of all matchingresource addresses
-
bool HasResource(const std::string &address)
Check if the pack contains a specific resource.
- Parameters:
address – The resource’s address
- Returns:
If the pack contains the resource
Public Static Functions
-
static AssetPack OpenFromFile(const std::string &filePath)
Open an asset pack file from on disk.
- Parameters:
filePath – The relative path (from the working directory) to the file to open
- Throws:
std::runtime_error – If the file does not exist or is not an asset pack
std::runtime_error – If the pack is of an incompatible revision
std::runtime_error – If decoding fails
- Returns:
The opened pack
-
static AssetPack OpenFromStream(std::istream *stream)
Open an asset pack file from an input stream.
Warning
The new asset pack will control the stream exclusively, and it is not recoverable from the object. Do not perform further operations on the stream after calling this!
- Parameters:
stream – The stream from which to load the pack
- Throws:
std::runtime_error – If the stream pointer is invalid
std::runtime_error – If the stream is not an asset pack
std::runtime_error – If decoding fails
- Returns:
The opened pack
-
Resource GetResource(const std::string &address)