Database
Functions
void |
|
void |
|
uint32_t |
|
bool |
|
char const * |
|
bool |
|
bool |
|
size_t |
Detailed Description
-
class Database
This class is used to create a Cache object or decompress a .scz file.
In general invalid usage will throw exceptions. Using try catch blocks around your code is advised.
Public Static Functions
-
static void SetLicense(const char *encoded_license)
Sets the license. A valid license must be provided or an exception will be thrown.
- Parameters
encoded_license – A valid encoded license string.
-
static Cache Open(Logger const &logger)
Opens a Cache object with default file system.
- Parameters
logger – A Logger object for status and error reporting.
-
static Cache Open(Logger const &logger, MemoryDevice *memory_device)
Opens a Cache object.
- Parameters
logger – A Logger object for status and error reporting.
memory_device – An optional MemoryDevice used to sandbox IO.
-
static Cache Open(Logger const &logger, SC::IO::AbstractFilesystem *file_system)
Opens a Cache object.
-
static void Close(Cache &cache)
Closes a Cache object. The Cache object will be invalid after this call. This has the same effect as deleting the cache object.
- Parameters
cache – A Cache object.
-
static bool DecompressSCZ(char const *utf8_path_to_scz_file, char const *utf8_output_model_path, Logger const &logger, MemoryDevice *memory_device = nullptr)
Utility to decompress a .scz file.
- Parameters
utf8_path_to_scz_file – An absolute path to a .scz file to decompress.
utf8_output_model_path – An absolute path to output the uncompressed model.
logger – A Logger object for status and error reporting.
memory_device – An optional MemoryDevice used to sandbox IO.
- Returns
True if the file decompressed.
-
static char const *QuerySCZ(char const *utf8_path_to_scz_file, Logger const &logger, MemoryDevice *memory_device = nullptr)
Utility to query information about a .scz file. Returned pointer is only valid until the next call. The returned string will contain “Compressed” if it is a compressed .scz or “Invalid” if the file is not a scz. A bundled .scz will contain “Bundled” with “Editable” and “Streamable” depending on it’s contents.
- Parameters
utf8_path_to_scz_file – An absolute path to a .scz file to query.
logger – A Logger object for status and error reporting.
memory_device – An optional MemoryDevice used to sandbox IO.
- Returns
A pointer to a ‘C’ string with informations about the .scz file.
-
static bool CreateMemoryDevice(char const *memory_device_name)
Creates an in-memory virtual file device used to sandbox file IO.
If a device is successfully created (this function returns true),
DestroyMemoryDevice
must later be called to free its memory.- Parameters
memory_device_name – The name of the memory device to create.
- Returns
True if the device is newly created or false if it already existed.
-
static bool DestroyMemoryDevice(char const *memory_device_name)
Destroys an in-memory virtual file device created by
CreateMemoryDevice
.- Parameters
memory_device_name – The name of the memory device to destroy.
- Returns
True if the device existed or false if no such device existed to prior to this call.
-
static MemoryDevice *GetMemoryDevice(char const *memory_device_name)
Returns the memory device created for the input name. If no device exists for that name then null is returned.
Pointers returned by this function become dangling after any call to
DestroyMemoryDevice
for the given input name. A dangling pointer must never be used again. (It should not be dereferenced or passed to any of our APIs.) Doing otherwise has the same risks of using any dangling pointer in C++.- Returns
The memory device if it exists or null if it does not.
-
static size_t GetMemoryDeviceNames(char const **memory_device_name_buffer, size_t capacity)
Returns the names of existing memory devices. The returned name pointers are only valid until after
CreateMemoryDevice
orDestroyMemoryDevice
are called.- Parameters
memory_device_name_buffer – The buffer to be populated with memory device names.
capacity – The max capacity of the input buffer.
- Returns
The number of devices in existence.
-
static void SetLicense(const char *encoded_license)