Instance Methodmigueldeicaza.swiftgodot 0.45.0SwiftGodot
getSections
Returns an array of all defined section identifiers.
ConfigFile.swift:196final func getSections() -> PackedStringArray
Other members in extension
Type members
Instance members
func clear(
) Removes the entire contents of the config.
func encodeToText(
) -> String Obtain the text version of this config file (the same text that would be written to a file).
func eraseSection(String
) Deletes the specified section along with all the key-value pairs inside. Raises an error if the section does not exist.
func eraseSectionKey(section: String, key: String
) Deletes the specified key in a section. Raises an error if either the section or the key do not exist.
func getSectionKeys(section: String
) -> PackedStringArray Returns an array of all defined key identifiers in the specified section. Raises an error and returns an empty array if the section does not exist.
func getValue(section: String, key: String, default: Variant
) -> Variant Returns the current value for the specified section and key. If either the section or the key do not exist, the method returns the fallback
default
value. Ifdefault
is not specified or set tonull
, an error is also raised.func hasSection(String
) -> Bool Returns
true
if the specified section exists.func hasSectionKey(section: String, key: String
) -> Bool Returns
true
if the specified section-key pair exists.func load(path: String
) -> GodotError Loads the config file specified as a parameter. The file’s contents are parsed and loaded in the
ConfigFile
object which the method was called on.func loadEncrypted(path: String, key: PackedByteArray
) -> GodotError Loads the encrypted config file specified as a parameter, using the provided
key
to decrypt it. The file’s contents are parsed and loaded in theConfigFile
object which the method was called on.func loadEncryptedPass(path: String, password: String
) -> GodotError Loads the encrypted config file specified as a parameter, using the provided
password
to decrypt it. The file’s contents are parsed and loaded in theConfigFile
object which the method was called on.func parse(data: String
) -> GodotError Parses the passed string as the contents of a config file. The string is parsed and loaded in the ConfigFile object which the method was called on.
func save(path: String
) -> GodotError Saves the contents of the
ConfigFile
object to the file specified as a parameter. The output file uses an INI-style structure.func saveEncrypted(path: String, key: PackedByteArray
) -> GodotError Saves the contents of the
ConfigFile
object to the AES-256 encrypted file specified as a parameter, using the providedkey
to encrypt it. The output file uses an INI-style structure.func saveEncryptedPass(path: String, password: String
) -> GodotError Saves the contents of the
ConfigFile
object to the AES-256 encrypted file specified as a parameter, using the providedpassword
to encrypt it. The output file uses an INI-style structure.func setValue(section: String, key: String, value: Variant
) Assigns a value to the specified key of the specified section. If either the section or the key do not exist, they are created. Passing a
null
value deletes the specified key if it exists, and deletes the section if it ends up empty once the key has been removed.