#include <sc_store.h>

Static Public Member Functions

static void Close (Cache &cache)
 
static bool CreateMemoryDevice (char const *memory_device_name)
 
static bool DecompressSCZ (char const *utf8_path_to_scz_file, char const *utf8_output_model_path, Logger const &logger, MemoryDevice *memory_device=nullptr)
 
static bool DestroyMemoryDevice (char const *memory_device_name)
 
static MemoryDeviceGetMemoryDevice (char const *memory_device_name)
 
static size_t GetMemoryDeviceNames (char const **memory_device_name_buffer, size_t capacity)
 
static Cache Open (Logger const &logger, MemoryDevice *memory_device=nullptr)
 
static char const * QuerySCZ (char const *utf8_path_to_scz_file, Logger const &logger, MemoryDevice *memory_device=nullptr)
 
static void SetLicense (const char *encoded_license)
 
static uint32_t Version ()
 

Detailed Description

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.

Member Function Documentation

◆ Close()

static void SC::Store::Database::Close ( Cache cache)
static

Closes a Cache object. The Cache object will be invalid after this call. This has the same effect as deleting the cache object.

Parameters
cacheA Cache object.

◆ CreateMemoryDevice()

static bool SC::Store::Database::CreateMemoryDevice ( char const *  memory_device_name)
static

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_nameThe name of the memory device to create.
Returns
True if the device is newly created or false if it already existed.

◆ DecompressSCZ()

static bool SC::Store::Database::DecompressSCZ ( char const *  utf8_path_to_scz_file,
char const *  utf8_output_model_path,
Logger const &  logger,
MemoryDevice memory_device = nullptr 
)
static

Utility to decompress a .scz file.

Parameters
utf8_path_to_scz_fileAn absolute path to a .scz file to decompress.
utf8_output_model_pathAn absolute path to output the uncompressed model.
loggerA Logger object for status and error reporting.
memory_deviceAn optional MemoryDevice used to sandbox IO.
Returns
True if the file decompressed.

◆ DestroyMemoryDevice()

static bool SC::Store::Database::DestroyMemoryDevice ( char const *  memory_device_name)
static

Destroys an in-memory virtual file device created by CreateMemoryDevice.

Parameters
memory_device_nameThe 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.

◆ GetMemoryDevice()

static MemoryDevice* SC::Store::Database::GetMemoryDevice ( char const *  memory_device_name)
static

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.

◆ GetMemoryDeviceNames()

static size_t SC::Store::Database::GetMemoryDeviceNames ( char const **  memory_device_name_buffer,
size_t  capacity 
)
static

Returns the names of existing memory devices. The returned name pointers are only valid until after CreateMemoryDevice or DestroyMemoryDevice are called.

Parameters
memory_device_name_bufferThe buffer to be populated with memory device names.
capacityThe max capacity of the input buffer.
Returns
The number of devices in existence.

◆ Open()

static Cache SC::Store::Database::Open ( Logger const &  logger,
MemoryDevice memory_device = nullptr 
)
static

Opens a Cache object.

Parameters
loggerA Logger object for status and error reporting.
memory_deviceAn optional MemoryDevice used to sandbox IO.

◆ QuerySCZ()

static char const* SC::Store::Database::QuerySCZ ( char const *  utf8_path_to_scz_file,
Logger const &  logger,
MemoryDevice memory_device = nullptr 
)
static

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_fileAn absolute path to a .scz file to query.
loggerA Logger object for status and error reporting.
memory_deviceAn optional MemoryDevice used to sandbox IO.
Returns
A pointer to a 'C' string with informations about the .scz file.

◆ SetLicense()

static void SC::Store::Database::SetLicense ( const char *  encoded_license)
static

Sets the license. A valid license must be provided or an exception will be thrown.

Parameters
encoded_licenseA valid encoded license string.

◆ Version()

static uint32_t SC::Store::Database::Version ( )
static

Query the version of the SC::Store

Returns
The SC::Store version.