These APIs support the ability to build resources (strings, binary objects, etc. More...
Functions | |
int | getResourceNamespaceCount (void) throw () |
retrieve the number of resource namespaces | |
const char * | getResourceNamespaceName (IN int index) throw () |
retrieve the indexed namespace name. Returns NULL on invalid input | |
int | getResourceCount (IN const char *nameSpace) throw () |
retrieve the number of resources in the specified resource namespace | |
const char * | getResourceName (IN const char *nameSpace, IN int index) throw () |
retrieve name of the indexed resource within the given resource namespace returns NULL if index is invalid. | |
int | getResourceSize (IN const char *nameSpace, IN const char *name) throw () |
retrieve information about a named resource in the given namespace returns 0 if name is not found | |
const byte_t * | getResourceData (IN const char *nameSpace, IN const char *name) throw () |
retrieve resource data by name (returns NULL if not found). | |
void | registerResource (IN const char *nameSpace, IN const char *name, IN const byte_t *value, IN int bytes) |
register a new resource. |
These APIs support the ability to build resources (strings, binary objects, etc.
) directly into the binary for later reference.
To use resources in your library or executable, you'll need to update the CMakeLists.txt file so that the resource files are built, compiled and linked.
A namespace is just a string identifier, which should be reasonably unique so you won't have collisions with other libraries that are declaring their own resources.
Notes on the resource
entry:
file
is a required tagtype
is supplied, string
is assumed.name
is supplied, it is assumed to be the same name as the file
.
This is a very low-level API to access resources. For a named-stream-based read-only interface, see restream
int getResourceNamespaceCount | ( | void | ) | throw () |
retrieve the number of resource namespaces
Definition at line 173 of file resources.cpp.
const char* getResourceNamespaceName | ( | IN int | index | ) | throw () |
retrieve the indexed namespace name. Returns NULL on invalid input
Definition at line 188 of file resources.cpp.
int getResourceCount | ( | IN const char * | nameSpace | ) | throw () |
retrieve the number of resources in the specified resource namespace
Definition at line 212 of file resources.cpp.
const char* getResourceName | ( | IN const char * | nameSpace, | |
IN int | index | |||
) | throw () |
retrieve name of the indexed resource within the given resource namespace returns NULL if index is invalid.
Definition at line 227 of file resources.cpp.
int getResourceSize | ( | IN const char * | nameSpace, | |
IN const char * | name | |||
) | throw () |
retrieve information about a named resource in the given namespace returns 0 if name is not found
Definition at line 254 of file resources.cpp.
const byte_t* getResourceData | ( | IN const char * | nameSpace, | |
IN const char * | name | |||
) | throw () |
retrieve resource data by name (returns NULL if not found).
Caller is responsible for knowing the resource size ahead of time (don't rely on null terminator, etc.).
Definition at line 281 of file resources.cpp.
void registerResource | ( | IN const char * | nameSpace, | |
IN const char * | name, | |||
IN const byte_t * | value, | |||
IN int | bytes | |||
) |
register a new resource.
Caller is responsible for ensuring that the resource value (raw byte buffer) is valid for the lifetime of the process. No copy is made. If there is a collision (a resource of the same name already exists), the old resource is quietly overwritten. Resources must be at least one byte.
Definition at line 307 of file resources.cpp.