Liblinphone
5.3.0
|
This object is used to manipulate a configuration file. More...
#include <config.hh>
Public Member Functions | |
LINPHONECXX_PUBLIC | Config (void *ptr, bool takeRef=true) |
LINPHONECXX_PUBLIC _LinphoneConfig * | cPtr () |
LINPHONECXX_PUBLIC bool | isReadonly () const |
Indicates whether the LinphoneConfig object is readonly, in other words it has no file backend or file is opened without write permission. More... | |
LINPHONECXX_PUBLIC std::list< std::string > | getSectionsNamesList () |
Returns the list of sections' names in the LinphoneConfig. More... | |
LINPHONECXX_PUBLIC void | cleanEntry (const std::string §ion, const std::string &key) |
Removes entries for key,value in a section. More... | |
LINPHONECXX_PUBLIC void | cleanSection (const std::string §ion) |
Removes every pair of key,value in a section and remove the section. More... | |
LINPHONECXX_PUBLIC std::string | dump () const |
Dumps the Config as INI into a buffer. More... | |
LINPHONECXX_PUBLIC std::string | dumpAsXml () const |
Dumps the Config as XML into a buffer. More... | |
LINPHONECXX_PUBLIC bool | getBool (const std::string §ion, const std::string &key, bool defaultValue) const |
Retrieves a configuration item as a boolean, given its section, key, and default value. More... | |
LINPHONECXX_PUBLIC float | getDefaultFloat (const std::string §ion, const std::string &key, float defaultValue) const |
Retrieves a default configuration item as a float, given its section, key, and default value. More... | |
LINPHONECXX_PUBLIC int | getDefaultInt (const std::string §ion, const std::string &key, int defaultValue) const |
Retrieves a default configuration item as an integer, given its section, key, and default value. More... | |
LINPHONECXX_PUBLIC int64_t | getDefaultInt64 (const std::string §ion, const std::string &key, int64_t defaultValue) const |
Retrieves a default configuration item as a 64 bit integer, given its section, key, and default value. More... | |
LINPHONECXX_PUBLIC std::string | getDefaultString (const std::string §ion, const std::string &key, const std::string &defaultValue) const |
Retrieves a default configuration item as a string, given its section, key, and default value. More... | |
LINPHONECXX_PUBLIC float | getFloat (const std::string §ion, const std::string &key, float defaultValue) const |
Retrieves a configuration item as a float, given its section, key, and default value. More... | |
LINPHONECXX_PUBLIC int | getInt (const std::string §ion, const std::string &key, int defaultValue) const |
Retrieves a configuration item as an integer, given its section, key, and default value. More... | |
LINPHONECXX_PUBLIC int64_t | getInt64 (const std::string §ion, const std::string &key, int64_t defaultValue) const |
Retrieves a configuration item as a 64 bit integer, given its section, key, and default value. More... | |
LINPHONECXX_PUBLIC std::list< std::string > | getKeysNamesList (const std::string §ion) |
Returns the list of keys' names for a section in the LinphoneConfig. More... | |
LINPHONECXX_PUBLIC bool | getOverwriteFlagForEntry (const std::string §ion, const std::string &key) const |
Retrieves the overwrite flag for a config item. More... | |
LINPHONECXX_PUBLIC bool | getOverwriteFlagForSection (const std::string §ion) const |
Retrieves the overwrite flag for a config section. More... | |
LINPHONECXX_PUBLIC bool | getRange (const std::string §ion, const std::string &key, int *min, int *max, int defaultMin, int defaultMax) const |
Retrieves a configuration item as a range, given its section, key, and default min and max values. More... | |
LINPHONECXX_PUBLIC std::string | getSectionParamString (const std::string §ion, const std::string &key, const std::string &defaultValue) const |
Retrieves a section parameter item as a string, given its section and key. More... | |
LINPHONECXX_PUBLIC bool | getSkipFlagForEntry (const std::string §ion, const std::string &key) const |
Retrieves the skip flag for a config item. More... | |
LINPHONECXX_PUBLIC bool | getSkipFlagForSection (const std::string §ion) const |
Retrieves the skip flag for a config section. More... | |
LINPHONECXX_PUBLIC std::string | getString (const std::string §ion, const std::string &key, const std::string &defaultString) const |
Retrieves a configuration item as a string, given its section, key, and default value. More... | |
LINPHONECXX_PUBLIC std::list< std::string > | getStringList (const std::string §ion, const std::string &key, const std::list< std::string > &defaultList) const |
Retrieves a configuration item as a list of strings, given its section, key, and default value. More... | |
LINPHONECXX_PUBLIC int | hasEntry (const std::string §ion, const std::string &key) const |
Returns if a given section with a given key is present in the configuration. More... | |
LINPHONECXX_PUBLIC int | hasSection (const std::string §ion) const |
Returns if a given section is present in the configuration. More... | |
LINPHONECXX_PUBLIC std::string | loadFromXmlFile (const std::string &filename) |
Reads a xml config file and fill the Config with the read config dynamic values. More... | |
LINPHONECXX_PUBLIC linphone::Status | loadFromXmlString (const std::string &buffer) |
Reads a xml config string and fill the Config with the read config dynamic values. More... | |
LINPHONECXX_PUBLIC linphone::Status | readFile (const std::string &filename) |
Reads a user config file and fill the Config with the read config values. More... | |
LINPHONECXX_PUBLIC bool | relativeFileExists (const std::string &filename) const |
Check if given file name exists relatively to the current location. More... | |
LINPHONECXX_PUBLIC void | reload () |
Reload the config from the file. | |
LINPHONECXX_PUBLIC void | setBool (const std::string §ion, const std::string &key, bool value) |
Sets a boolean config item. More... | |
LINPHONECXX_PUBLIC void | setFloat (const std::string §ion, const std::string &key, float value) |
Sets a float config item. More... | |
LINPHONECXX_PUBLIC void | setInt (const std::string §ion, const std::string &key, int value) |
Sets an integer config item. More... | |
LINPHONECXX_PUBLIC void | setInt64 (const std::string §ion, const std::string &key, int64_t value) |
Sets a 64 bits integer config item. More... | |
LINPHONECXX_PUBLIC void | setIntHex (const std::string §ion, const std::string &key, int value) |
Sets an integer config item, but store it as hexadecimal. More... | |
LINPHONECXX_PUBLIC void | setOverwriteFlagForEntry (const std::string §ion, const std::string &key, bool value) |
Sets the overwrite flag for a config item (used when dumping config as xml) More... | |
LINPHONECXX_PUBLIC void | setOverwriteFlagForSection (const std::string §ion, bool value) |
Sets the overwrite flag for a config section (used when dumping config as xml) More... | |
LINPHONECXX_PUBLIC void | setRange (const std::string §ion, const std::string &key, int minValue, int maxValue) |
Sets a range config item. More... | |
LINPHONECXX_PUBLIC void | setSkipFlagForEntry (const std::string §ion, const std::string &key, bool value) |
Sets the skip flag for a config item (used when dumping config as xml) More... | |
LINPHONECXX_PUBLIC void | setSkipFlagForSection (const std::string §ion, bool value) |
Sets the skip flag for a config section (used when dumping config as xml) More... | |
LINPHONECXX_PUBLIC void | setString (const std::string §ion, const std::string &key, const std::string &value) |
Sets a string config item. More... | |
LINPHONECXX_PUBLIC void | setStringList (const std::string §ion, const std::string &key, const std::list< std::string > &value) |
Sets a string list config item. More... | |
LINPHONECXX_PUBLIC linphone::Status | sync () |
Writes the config file to disk. More... | |
LINPHONECXX_PUBLIC void | writeRelativeFile (const std::string &filename, const std::string &data) const |
Write a string in a file placed relatively with the Linphone configuration file. More... | |
Static Public Member Functions | |
static LINPHONECXX_PUBLIC std::shared_ptr< linphone::Config > | newFromBuffer (const std::string &buffer) |
Instantiates a Config object from a user provided buffer. More... | |
static LINPHONECXX_PUBLIC std::shared_ptr< linphone::Config > | newWithFactory (const std::string &configFilename, const std::string &factoryConfigFilename) |
Instantiates a Config object from a user config file and a factory config file. More... | |
This object is used to manipulate a configuration file.
The format of the configuration file is a .ini like format: Various types can be used: strings and lists of strings, integers, floats, booleans (written as 0 or 1) and range of integers. Usually a Core is initialized using two Config, one default (where configuration changes through API calls will be saved) and one named 'factory' which is read-only and overwrites any setting that may exists in the default one. It is also possible to use only one (either default or factory) or even none.
LINPHONECXX_PUBLIC void linphone::Config::cleanEntry | ( | const std::string & | section, |
const std::string & | key | ||
) |
Removes entries for key,value in a section.
section | the section for which to clean the key entry |
key | the key to clean |
LINPHONECXX_PUBLIC void linphone::Config::cleanSection | ( | const std::string & | section | ) |
Removes every pair of key,value in a section and remove the section.
section | the section to clean |
LINPHONECXX_PUBLIC std::string linphone::Config::dump | ( | ) | const |
Dumps the Config as INI into a buffer.
LINPHONECXX_PUBLIC std::string linphone::Config::dumpAsXml | ( | ) | const |
Dumps the Config as XML into a buffer.
LINPHONECXX_PUBLIC bool linphone::Config::getBool | ( | const std::string & | section, |
const std::string & | key, | ||
bool | defaultValue | ||
) | const |
Retrieves a configuration item as a boolean, given its section, key, and default value.
The default boolean value is returned if the config item isn't found.
section | The section from which to retrieve a configuration item |
key | The name of the configuration item to retrieve |
defaultValue | The default value to return if not found |
LINPHONECXX_PUBLIC float linphone::Config::getDefaultFloat | ( | const std::string & | section, |
const std::string & | key, | ||
float | defaultValue | ||
) | const |
Retrieves a default configuration item as a float, given its section, key, and default value.
The default float value is returned if the config item isn't found.
section | The section from which to retrieve the default value |
key | The name of the configuration item to retrieve |
defaultValue | The default value to return if not found |
LINPHONECXX_PUBLIC int linphone::Config::getDefaultInt | ( | const std::string & | section, |
const std::string & | key, | ||
int | defaultValue | ||
) | const |
Retrieves a default configuration item as an integer, given its section, key, and default value.
The default integer value is returned if the config item isn't found.
section | The section from which to retrieve the default value |
key | The name of the configuration item to retrieve |
defaultValue | The default value to return if not found |
LINPHONECXX_PUBLIC int64_t linphone::Config::getDefaultInt64 | ( | const std::string & | section, |
const std::string & | key, | ||
int64_t | defaultValue | ||
) | const |
Retrieves a default configuration item as a 64 bit integer, given its section, key, and default value.
The default integer value is returned if the config item isn't found.
section | The section from which to retrieve the default value |
key | The name of the configuration item to retrieve |
defaultValue | The default value to return if not found |
LINPHONECXX_PUBLIC std::string linphone::Config::getDefaultString | ( | const std::string & | section, |
const std::string & | key, | ||
const std::string & | defaultValue | ||
) | const |
Retrieves a default configuration item as a string, given its section, key, and default value.
The default value string is returned if the config item isn't found.
section | The section from which to retrieve the default value |
key | The name of the configuration item to retrieve |
defaultValue | The default value to return if not found |
LINPHONECXX_PUBLIC float linphone::Config::getFloat | ( | const std::string & | section, |
const std::string & | key, | ||
float | defaultValue | ||
) | const |
Retrieves a configuration item as a float, given its section, key, and default value.
The default float value is returned if the config item isn't found.
section | The section from which to retrieve a configuration item |
key | The name of the configuration item to retrieve |
defaultValue | The default value to return if not found |
LINPHONECXX_PUBLIC int linphone::Config::getInt | ( | const std::string & | section, |
const std::string & | key, | ||
int | defaultValue | ||
) | const |
Retrieves a configuration item as an integer, given its section, key, and default value.
The default integer value is returned if the config item isn't found.
section | The section from which to retrieve a configuration item |
key | The name of the configuration item to retrieve |
defaultValue | The default value to return if not found |
LINPHONECXX_PUBLIC int64_t linphone::Config::getInt64 | ( | const std::string & | section, |
const std::string & | key, | ||
int64_t | defaultValue | ||
) | const |
Retrieves a configuration item as a 64 bit integer, given its section, key, and default value.
The default integer value is returned if the config item isn't found.
section | The section from which to retrieve a configuration item |
key | The name of the configuration item to retrieve |
defaultValue | The default value to return if not found |
LINPHONECXX_PUBLIC std::list<std::string> linphone::Config::getKeysNamesList | ( | const std::string & | section | ) |
Returns the list of keys' names for a section in the LinphoneConfig.
section | The section name |
LINPHONECXX_PUBLIC bool linphone::Config::getOverwriteFlagForEntry | ( | const std::string & | section, |
const std::string & | key | ||
) | const |
Retrieves the overwrite flag for a config item.
section | The section from which to retrieve the overwrite flag |
key | The name of the configuration item to retrieve the overwrite flag from. |
LINPHONECXX_PUBLIC bool linphone::Config::getOverwriteFlagForSection | ( | const std::string & | section | ) | const |
Retrieves the overwrite flag for a config section.
section | The section from which to retrieve the overwrite flag |
LINPHONECXX_PUBLIC bool linphone::Config::getRange | ( | const std::string & | section, |
const std::string & | key, | ||
int * | min, | ||
int * | max, | ||
int | defaultMin, | ||
int | defaultMax | ||
) | const |
Retrieves a configuration item as a range, given its section, key, and default min and max values.
section | The section from which to retrieve a configuration item |
key | The name of the configuration item to retrieve |
min | The min value found or default_min |
max | The max value found or default_max |
defaultMin | the default min value to return if not found |
defaultMax | the default max value to return if not found. |
LINPHONECXX_PUBLIC std::string linphone::Config::getSectionParamString | ( | const std::string & | section, |
const std::string & | key, | ||
const std::string & | defaultValue | ||
) | const |
Retrieves a section parameter item as a string, given its section and key.
The default value string is returned if the config item isn't found.
section | The section from which to retrieve the default value |
key | The name of the configuration item to retrieve |
defaultValue | The default value to return if not found. |
LINPHONECXX_PUBLIC std::list<std::string> linphone::Config::getSectionsNamesList | ( | ) |
Returns the list of sections' names in the LinphoneConfig.
LINPHONECXX_PUBLIC bool linphone::Config::getSkipFlagForEntry | ( | const std::string & | section, |
const std::string & | key | ||
) | const |
Retrieves the skip flag for a config item.
section | The section from which to retrieve the skip flag |
key | The name of the configuration item to retrieve the skip flag from |
LINPHONECXX_PUBLIC bool linphone::Config::getSkipFlagForSection | ( | const std::string & | section | ) | const |
Retrieves the skip flag for a config section.
section | The section from which to retrieve the skip flag |
LINPHONECXX_PUBLIC std::string linphone::Config::getString | ( | const std::string & | section, |
const std::string & | key, | ||
const std::string & | defaultString | ||
) | const |
Retrieves a configuration item as a string, given its section, key, and default value.
The default value string is returned if the config item isn't found.
section | The section from which to retrieve a configuration item |
key | The name of the configuration item to retrieve |
defaultString | The default value to return if not found. |
LINPHONECXX_PUBLIC std::list<std::string> linphone::Config::getStringList | ( | const std::string & | section, |
const std::string & | key, | ||
const std::list< std::string > & | defaultList | ||
) | const |
Retrieves a configuration item as a list of strings, given its section, key, and default value.
The default value is returned if the config item is not found.
section | The section from which to retrieve a configuration item |
key | The name of the configuration item to retrieve |
defaultList | The list to return when the key doesn't exist. |
LINPHONECXX_PUBLIC int linphone::Config::hasEntry | ( | const std::string & | section, |
const std::string & | key | ||
) | const |
Returns if a given section with a given key is present in the configuration.
section | to check if the given entry exists |
key | to check if it exists |
LINPHONECXX_PUBLIC int linphone::Config::hasSection | ( | const std::string & | section | ) | const |
Returns if a given section is present in the configuration.
section | the section to check if exists |
LINPHONECXX_PUBLIC bool linphone::Config::isReadonly | ( | ) | const |
Indicates whether the LinphoneConfig object is readonly, in other words it has no file backend or file is opened without write permission.
LINPHONECXX_PUBLIC std::string linphone::Config::loadFromXmlFile | ( | const std::string & | filename | ) |
LINPHONECXX_PUBLIC linphone::Status linphone::Config::loadFromXmlString | ( | const std::string & | buffer | ) |
|
static |
Instantiates a Config object from a user provided buffer.
The caller of this constructor owns a reference. linphone_config_unref must be called when this object is no longer needed.
buffer | the buffer from which the Config will be retrieved. We expect the buffer to be null-terminated. |
|
static |
Instantiates a Config object from a user config file and a factory config file.
The caller of this constructor owns a reference. linphone_config_unref must be called when this object is no longer needed.
configFilename | the filename of the user config file to read to fill the instantiated Config |
factoryConfigFilename | the filename of the factory config file to read to fill the instantiated Config |
LINPHONECXX_PUBLIC linphone::Status linphone::Config::readFile | ( | const std::string & | filename | ) |
LINPHONECXX_PUBLIC bool linphone::Config::relativeFileExists | ( | const std::string & | filename | ) | const |
Check if given file name exists relatively to the current location.
filename | The file name to check if exists |
LINPHONECXX_PUBLIC void linphone::Config::setBool | ( | const std::string & | section, |
const std::string & | key, | ||
bool | value | ||
) |
Sets a boolean config item.
section | The section from which to retrieve a configuration item |
key | The name of the configuration item to retrieve |
value | the value to set |
LINPHONECXX_PUBLIC void linphone::Config::setFloat | ( | const std::string & | section, |
const std::string & | key, | ||
float | value | ||
) |
Sets a float config item.
section | The section from which to retrieve a configuration item |
key | The name of the configuration item to retrieve |
value | the value to set |
LINPHONECXX_PUBLIC void linphone::Config::setInt | ( | const std::string & | section, |
const std::string & | key, | ||
int | value | ||
) |
Sets an integer config item.
section | The section from which to retrieve a configuration item |
key | The name of the configuration item to retrieve |
value | the value to set |
LINPHONECXX_PUBLIC void linphone::Config::setInt64 | ( | const std::string & | section, |
const std::string & | key, | ||
int64_t | value | ||
) |
Sets a 64 bits integer config item.
section | The section from which to retrieve a configuration item |
key | The name of the configuration item to retrieve |
value | the value to set |
LINPHONECXX_PUBLIC void linphone::Config::setIntHex | ( | const std::string & | section, |
const std::string & | key, | ||
int | value | ||
) |
Sets an integer config item, but store it as hexadecimal.
section | The section from which to retrieve a configuration item |
key | The name of the configuration item to retrieve |
value | the value to set |
LINPHONECXX_PUBLIC void linphone::Config::setOverwriteFlagForEntry | ( | const std::string & | section, |
const std::string & | key, | ||
bool | value | ||
) |
Sets the overwrite flag for a config item (used when dumping config as xml)
section | The section from which to set the overwrite flag |
key | The name of the configuration item to set the overwrite flag from |
value | The overwrite flag value to set |
LINPHONECXX_PUBLIC void linphone::Config::setOverwriteFlagForSection | ( | const std::string & | section, |
bool | value | ||
) |
Sets the overwrite flag for a config section (used when dumping config as xml)
section | The section from which to set the overwrite flag |
value | The overwrite flag value to set |
LINPHONECXX_PUBLIC void linphone::Config::setRange | ( | const std::string & | section, |
const std::string & | key, | ||
int | minValue, | ||
int | maxValue | ||
) |
Sets a range config item.
section | The section from which to retrieve a configuration item |
key | The name of the configuration item to retrieve |
minValue | the min value to set |
maxValue | the max value to set |
LINPHONECXX_PUBLIC void linphone::Config::setSkipFlagForEntry | ( | const std::string & | section, |
const std::string & | key, | ||
bool | value | ||
) |
Sets the skip flag for a config item (used when dumping config as xml)
section | The section from which to set the skip flag |
key | The name of the configuration item to set the skip flag from |
value | The skip flag value to set |
LINPHONECXX_PUBLIC void linphone::Config::setSkipFlagForSection | ( | const std::string & | section, |
bool | value | ||
) |
Sets the skip flag for a config section (used when dumping config as xml)
section | The section from which to set the skip flag |
value | The skip flag value to set |
LINPHONECXX_PUBLIC void linphone::Config::setString | ( | const std::string & | section, |
const std::string & | key, | ||
const std::string & | value | ||
) |
Sets a string config item.
section | The section from which to retrieve a configuration item |
key | The name of the configuration item to retrieve |
value | The value to set |
LINPHONECXX_PUBLIC void linphone::Config::setStringList | ( | const std::string & | section, |
const std::string & | key, | ||
const std::list< std::string > & | value | ||
) |
Sets a string list config item.
section | The name of the section to put the configuration item into |
key | The name of the configuration item to set |
value | The value to set. |
LINPHONECXX_PUBLIC linphone::Status linphone::Config::sync | ( | ) |
Writes the config file to disk.
LINPHONECXX_PUBLIC void linphone::Config::writeRelativeFile | ( | const std::string & | filename, |
const std::string & | data | ||
) | const |
Write a string in a file placed relatively with the Linphone configuration file.
filename | Name of the file where to write data. The name is relative to the place of the config file |
data | String to write |