MLIB
|
Class for storing asset files in Windows resource data. More...
#include <asset.h>
Public Member Functions | |
asset (int id_, const std::string &name_=std::string(), bool persist=false) | |
Constructor for an asset object. | |
~asset () | |
Destructor. Delete asset file if it exists. | |
const void * | data () |
Load asset data. | |
size_t | size () |
Return size of asset (in bytes) | |
bool | write (const std::string &path) |
Write the asset to a folder. | |
bool | remove () |
Data Fields | |
const std::string | name |
Class for storing asset files in Windows resource data.
This class provides a mechanism for 'hiding' the different assets needed by a HTTP server (pages, CSS files, images, etc.) inside the EXE file.
Each asset is stored as a user-defined resource of type RESFILE (defined as 256) and is identified by its ID. An asset can be written to a file. When the asset object goes out of scope the file is deleted.
The resource file (.rc) should contain some lines like these: IDR_INDEX_HTML RESFILE "index.html" IDR_MAIN_CSS RESFILE "main.css"
|
inline |
Constructor for an asset object.
name_ | asset file name |
id_ | resource ID |
persist | if true do not delete disk file when asset object is destructed |
const void * mlib::asset::data | ( | ) |
Load asset data.
bool mlib::asset::write | ( | const std::string & | path | ) |
Write the asset to a folder.
path | root path for asset file (with or without terminating backslash) |
true
if successful, false
otherwiseAsset filename is obtained by appending the asset name to the root path. For persistent assets, if file already exists, it is not overwritten.