Config
public class Config : LinphoneObject
The Config object is used to manipulate a configuration file.
The format of the configuration file is a .ini like format:
Example:
-
Instantiates a
Configobject 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.See
See also: linphone_config_new_with_factory
See
See also: linphone_config_new
Declaration
Swift
public static func newFromBuffer(buffer: String) -> Config?Parameters
bufferthe buffer from which the
Configwill be retrieved. We expect the buffer to be null-terminated. -
Instantiates a
Configobject 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.See
See also: linphone_config_new
The user config file is read first to fill the
Configand then the factory config file is read. Therefore the configuration parameters defined in the user config file will be overwritten by the parameters defined in the factory config file.Declaration
Swift
public static func newWithFactory(configFilename: String, factoryConfigFilename: String) -> Config?Parameters
configFilenamethe filename of the user config file to read to fill the instantiated
ConfigfactoryConfigFilenamethe filename of the factory config file to read to fill the instantiated
Config -
Returns the list of sections’ names in the LinphoneConfig.
Declaration
Swift
public var sectionsNamesList: [String] { get }Return Value
A list of char * objects. char * a null terminated static array of strings
-
Removes entries for key,value in a section.
Declaration
Swift
public func cleanEntry(section: String, key: String)Parameters
sectionkey -
Removes every pair of key,value in a section and remove the section.
Declaration
Swift
public func cleanSection(section: String) -
Dumps the
Configas INI into a buffer.Declaration
Swift
public func dump() -> StringReturn Value
The buffer that contains the config dump
-
Dumps the
Configas XML into a buffer.Declaration
Swift
public func dumpAsXml() -> StringReturn Value
The buffer that contains the XML dump
-
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.
Declaration
Swift
public func getBool(section: String, key: String, defaultValue: Bool) -> Bool -
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.
Declaration
Swift
public func getDefaultFloat(section: String, key: String, defaultValue: Float) -> Float -
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.
Declaration
Swift
public func getDefaultInt(section: String, key: String, defaultValue: Int) -> Int -
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.
Declaration
Swift
public func getDefaultInt64(section: String, key: String, defaultValue: Int64) -> Int64 -
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.
Declaration
Swift
public func getDefaultString(section: String, key: String, defaultValue: String) -> String -
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.
Declaration
Swift
public func getFloat(section: String, key: String, defaultValue: Float) -> Float -
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.
Declaration
Swift
public func getInt(section: String, key: String, defaultValue: Int) -> Int -
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.
Declaration
Swift
public func getInt64(section: String, key: String, defaultValue: Int64) -> Int64 -
Retrieves the overwrite flag for a config item.
Declaration
Swift
public func getOverwriteFlagForEntry(section: String, key: String) -> Bool -
Retrieves the overwrite flag for a config section.
Declaration
Swift
public func getOverwriteFlagForSection(section: String) -> Bool -
Retrieves a configuration item as a range, given its section, key, and default min and max values.
Declaration
Swift
public func getRange(section: String, key: String, min: UnsafeMutablePointer<Int32>, max: UnsafeMutablePointer<Int32>, defaultMin: Int, defaultMax: Int) -> BoolReturn Value
if the value is successfully parsed as a range, true otherwise. If true is returned, min and max are filled respectively with default_min and default_max values.
-
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.
Declaration
Swift
public func getSectionParamString(section: String, key: String, defaultValue: String) -> String -
Retrieves the skip flag for a config item.
Declaration
Swift
public func getSkipFlagForEntry(section: String, key: String) -> Bool -
Retrieves the skip flag for a config section.
Declaration
Swift
public func getSkipFlagForSection(section: String) -> Bool -
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.
Declaration
Swift
public func getString(section: String, key: String, defaultString: String) -> String -
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.
Declaration
Swift
public func getStringList(section: String, key: String, defaultList: [String]) -> [String]Parameters
sectionThe section from which to retrieve a configuration item
keyThe name of the configuration item to retrieve
defaultListA list of const char * objects. const char *
Return Value
A list of const char * objects. const char *
-
Returns 1 if a given section with a given key is present in the configuration.
Declaration
Swift
public func hasEntry(section: String, key: String) -> IntParameters
sectionkey -
Returns 1 if a given section is present in the configuration.
Declaration
Swift
public func hasSection(section: String) -> Int -
Reads a xml config file and fill the
Configwith the read config dynamic values.Declaration
Swift
public func loadFromXmlFile(filename: String) -> StringParameters
filenameThe filename of the config file to read to fill the
Config -
Reads a xml config string and fill the
Configwith the read config dynamic values.Declaration
Swift
public func loadFromXmlString(buffer: String) throwsParameters
bufferThe string of the config file to fill the
ConfigReturn Value
0 in case of success
-
Reads a user config file and fill the
Configwith the read config values.Declaration
Swift
public func readFile(filename: String) throwsParameters
filenameThe filename of the config file to read to fill the
Config -
Declaration
Swift
public func relativeFileExists(filename: String) -> BoolReturn Value
if file exists relative to the to the current location
-
Sets a boolean config item.
Declaration
Swift
public func setBool(section: String, key: String, value: Bool) -
Sets a float config item.
Declaration
Swift
public func setFloat(section: String, key: String, value: Float) -
Sets an integer config item.
Declaration
Swift
public func setInt(section: String, key: String, value: Int) -
Sets a 64 bits integer config item.
Declaration
Swift
public func setInt64(section: String, key: String, value: Int64) -
Sets an integer config item, but store it as hexadecimal.
Declaration
Swift
public func setIntHex(section: String, key: String, value: Int) -
Sets the overwrite flag for a config item (used when dumping config as xml)
Declaration
Swift
public func setOverwriteFlagForEntry(section: String, key: String, value: Bool) -
Sets the overwrite flag for a config section (used when dumping config as xml)
Declaration
Swift
public func setOverwriteFlagForSection(section: String, value: Bool) -
Sets a range config item.
Declaration
Swift
public func setRange(section: String, key: String, minValue: Int, maxValue: Int) -
Sets the skip flag for a config item (used when dumping config as xml)
Declaration
Swift
public func setSkipFlagForEntry(section: String, key: String, value: Bool) -
Sets the skip flag for a config section (used when dumping config as xml)
Declaration
Swift
public func setSkipFlagForSection(section: String, value: Bool) -
Sets a string config item.
Declaration
Swift
public func setString(section: String, key: String, value: String) -
Sets a string list config item.
Declaration
Swift
public func setStringList(section: String, key: String, value: [String])Parameters
sectionThe name of the section to put the configuration item into
keyThe name of the configuration item to set
valueA list of const char * objects. const char * The value to set
-
Writes the config file to disk.
Declaration
Swift
public func sync() throws -
Write a string in a file placed relatively with the Linphone configuration file.
Declaration
Swift
public func writeRelativeFile(filename: String, data: String)Parameters
filenameName of the file where to write data. The name is relative to the place of the config file
dataString to write
Config Class Reference