libgpac
Documentation of the core library of GPAC
Loading...
Searching...
No Matches
Configuration File

Configuration File object. More...

Functions

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

Detailed Description

Configuration File object.

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

Function Documentation

◆ gf_cfg_new()

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

configuration file constructor

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 
)

alternative configuration file constructor

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)

configuration file destructor

Destroys the configuration file and saves it if needed.

Parameters
cfgFilethe target configuration file

◆ gf_cfg_remove()

void gf_cfg_remove ( GF_Config *  cfgFile)

configuration file destructor

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)

configuration saving

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 
)

key value query

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 
)

key value update

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)

section count query

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 
)

section name query

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 
)

key count query

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 
)

key count query

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 
)

section destrouction

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