Sdk configfile api documentation

Configuration file access functions. The configuration file is compiled version of the game.project file.

Namespace: dmConfigFile
Include: #include <dmsdk/dlib/configfile.h>
FUNCTIONS
const char* dmConfigFile::GetString(dmConfigFile::HConfig config, const char* key, const char* default_value) get config value as string
int32_t dmConfigFile::GetInt(dmConfigFile::HConfig config, const char* key, int32_t default_value) get config value as int
float dmConfigFile::GetFloat(dmConfigFile::HConfig config, const char* key, float default_value) get config value as float

Functions

dmConfigFile::GetString

const char* dmConfigFile::GetString(dmConfigFile::HConfig config, const char* key, const char* default_value)

Get config value as string, returns default if the key isn't found

PARAMETERS

dmConfigFile::HConfig config Config file handle
const char* key Key in format section.key (.key for no section)
const char* default_value Default value to return if key isn't found

RETURNS

const char* found value or default value

EXAMPLES

static dmExtension::Result AppInitialize(dmExtension::AppParams* params)
{
    const char* projectTitle = dmConfigFile::GetString(params->m_ConfigFile, "project.title", "Untitled");
}

dmConfigFile::GetInt

int32_t dmConfigFile::GetInt(dmConfigFile::HConfig config, const char* key, int32_t default_value)

Get config value as int, returns default if the key isn't found Note: default_value is returned for invalid integer values

PARAMETERS

dmConfigFile::HConfig config Config file handle
const char* key Key in format section.key (.key for no section)
int32_t default_value Default value to return if key isn't found

RETURNS

int32_t found value or default value

EXAMPLES

static dmExtension::Result AppInitialize(dmExtension::AppParams* params)
{
    int32_t displayWidth = dmConfigFile::GetInt(params->m_ConfigFile, "display.width", 640);
}

dmConfigFile::GetFloat

float dmConfigFile::GetFloat(dmConfigFile::HConfig config, const char* key, float default_value)

Get config value as float, returns default if the key isn't found Note: default_value is returned for invalid float values

PARAMETERS

dmConfigFile::HConfig config Config file handle
const char* key Key in format section.key (.key for no section)
float default_value Default value to return if key isn't found

RETURNS

float found value or default value

EXAMPLES

static dmExtension::Result AppInitialize(dmExtension::AppParams* params)
{
    float gravity = dmConfigFile::GetFloat(params->m_ConfigFile, "physics.gravity_y", -9.8f);
}