libgpac
Documentation of the core library of GPAC
Configuration File

Configuration File object. More...

+ Collaboration diagram for Configuration File:

Typedefs

typedef struct __tag_config GF_Config
 

Functions

GF_Configgf_cfg_new (const char *filePath, const char *fileName)
 configuration file constructor More...
 
GF_Configgf_cfg_force_new (const char *filePath, const char *fileName)
 alternative configuration file constructor More...
 
void gf_cfg_del (GF_Config *cfgFile)
 configuration file destructor More...
 
void gf_cfg_remove (GF_Config *cfgFile)
 configuration file destructor More...
 
GF_Err gf_cfg_save (GF_Config *cfgFile)
 configuration saving More...
 
const char * gf_cfg_get_key (GF_Config *cfgFile, const char *secName, const char *keyName)
 key value query More...
 
GF_Err gf_cfg_set_key (GF_Config *cfgFile, const char *secName, const char *keyName, const char *keyValue)
 key value update More...
 
u32 gf_cfg_get_section_count (GF_Config *cfgFile)
 section count query More...
 
const char * gf_cfg_get_section_name (GF_Config *cfgFile, u32 secIndex)
 section name query More...
 
u32 gf_cfg_get_key_count (GF_Config *cfgFile, const char *secName)
 key count query More...
 
const char * gf_cfg_get_key_name (GF_Config *cfgFile, const char *secName, u32 keyIndex)
 key count query More...
 
void gf_cfg_del_section (GF_Config *cfgFile, const char *secName)
 section destrouction More...
 
const char * gf_cfg_get_filename (GF_Config *iniFile)
 
GF_Err gf_cfg_discard_changes (GF_Config *iniFile)
 

Detailed Description

This section documents the configuration file objects of the GPAC framework. A specific global configuration file is used for libgpac, see Library configuration. Such objects may be used by third-party applications to store data, and are used by the player scripting API to store various GUI data. A configuration file is formatted as the INI file mode of WIN32 in sections and keys.

[Section1]
Key1=foo
Key2=bar
[Section2]
Key1=@multiline
for
some
reason@
Key3=2

Typedef Documentation

◆ GF_Config

typedef struct __tag_config GF_Config

configuration file object

Function Documentation

◆ gf_cfg_new()

GF_Config* gf_cfg_new ( const char *  filePath,
const char *  fileName 
)

Constructs a configuration file.

Parameters
filePathdirectory the file is located in
fileNamename of the configuration file
Returns
the configuration file object, NULL if the file does not exist

◆ gf_cfg_force_new()

GF_Config* gf_cfg_force_new ( const char *  filePath,
const char *  fileName 
)

Constructs a configuration file. If file does not exist, configuration will be still created

Parameters
filePathdirectory the file is located in
fileNamename of the configuration file
Returns
the configuration file object, never NULL, even if file does not exist

◆ gf_cfg_del()

void gf_cfg_del ( GF_Config cfgFile)

Destroys the configuration file and saves it if needed.

Parameters
cfgFilethe target configuration file

◆ gf_cfg_remove()

void gf_cfg_remove ( GF_Config cfgFile)

Destroys the configuration file and removes the file from disk.

Parameters
cfgFilethe target configuration file

◆ gf_cfg_save()

GF_Err gf_cfg_save ( GF_Config cfgFile)

Saves the configuration file if modified.

Parameters
cfgFilethe target configuration file
Returns
error if any

◆ gf_cfg_get_key()

const char* gf_cfg_get_key ( GF_Config cfgFile,
const char *  secName,
const char *  keyName 
)

Gets a key value from its section and name.

Parameters
cfgFilethe target configuration file
secNamethe desired key parent section name
keyNamethe desired key name
Returns
the desired key value if found, NULL otherwise.

◆ gf_cfg_set_key()

GF_Err gf_cfg_set_key ( GF_Config cfgFile,
const char *  secName,
const char *  keyName,
const char *  keyValue 
)

Sets a key value from its section and name.

Parameters
cfgFilethe target configuration file
secNamethe desired key parent section name
keyNamethe desired key name
keyValuethe desired key value
Note
this will also create both section and key if they are not found in the configuration file
Returns
error if any

◆ gf_cfg_get_section_count()

u32 gf_cfg_get_section_count ( GF_Config cfgFile)

Gets the number of sections in the configuration file

Parameters
cfgFilethe target configuration file
Returns
the number of sections

◆ gf_cfg_get_section_name()

const char* gf_cfg_get_section_name ( GF_Config cfgFile,
u32  secIndex 
)

Gets a section name based on its index

Parameters
cfgFilethe target configuration file
secIndex0-based index of the section to query
Returns
the section name if found, NULL otherwise

◆ gf_cfg_get_key_count()

u32 gf_cfg_get_key_count ( GF_Config cfgFile,
const char *  secName 
)

Gets the number of keys in a section of the configuration file

Parameters
cfgFilethe target configuration file
secNamethe target section
Returns
the number of keys in the section

◆ gf_cfg_get_key_name()

const char* gf_cfg_get_key_name ( GF_Config cfgFile,
const char *  secName,
u32  keyIndex 
)

Gets the number of keys in a section of the configuration file

Parameters
cfgFilethe target configuration file
secNamethe target section
keyIndex0-based index of the key in the section
Returns
the key name if found, NULL otherwise

◆ gf_cfg_del_section()

void gf_cfg_del_section ( GF_Config cfgFile,
const char *  secName 
)

Removes all entries in the given section

Parameters
cfgFilethe target configuration file
secNamethe target section

◆ gf_cfg_get_filename()

const char* gf_cfg_get_filename ( GF_Config iniFile)

Get the full filename associated with this config file

Parameters
iniFileThe Configuration
Returns
the associated filename

◆ gf_cfg_discard_changes()

GF_Err gf_cfg_discard_changes ( GF_Config iniFile)

Do not save results to file

Parameters
iniFileThe Configuration
Returns
error code