diff options
author | Gianlluca <gianllucaalves@gmail.com> | 2019-09-28 21:27:09 -0300 |
---|---|---|
committer | gianllucah <gianllucaalves@gmail.com> | 2019-10-07 18:11:19 -0300 |
commit | 54cba54a45fd3d9fbe30f3c8100d7890d7586b82 (patch) | |
tree | dd537a6a4503bbfdd79fb4d8a4ac5781d2f223a1 /core | |
parent | c9e1aced53929159f3deaba21df258c991e7ef7f (diff) |
Added a method to erase section key in ConfigFile
Diffstat (limited to 'core')
-rw-r--r-- | core/io/config_file.cpp | 8 | ||||
-rw-r--r-- | core/io/config_file.h | 1 |
2 files changed, 9 insertions, 0 deletions
diff --git a/core/io/config_file.cpp b/core/io/config_file.cpp index 271e5c5a0b..5684c82d1c 100644 --- a/core/io/config_file.cpp +++ b/core/io/config_file.cpp @@ -123,6 +123,13 @@ void ConfigFile::erase_section(const String &p_section) { values.erase(p_section); } +void ConfigFile::erase_section_key(const String &p_section, const String &p_key) { + + ERR_FAIL_COND_MSG(!values.has(p_section), "Cannot erase key from nonexistent section '" + p_section + "'."); + + values[p_section].erase(p_key); +} + Error ConfigFile::save(const String &p_path) { Error err; @@ -293,6 +300,7 @@ void ConfigFile::_bind_methods() { ClassDB::bind_method(D_METHOD("get_section_keys", "section"), &ConfigFile::_get_section_keys); ClassDB::bind_method(D_METHOD("erase_section", "section"), &ConfigFile::erase_section); + ClassDB::bind_method(D_METHOD("erase_section_key", "section", "key"), &ConfigFile::erase_section_key); ClassDB::bind_method(D_METHOD("load", "path"), &ConfigFile::load); ClassDB::bind_method(D_METHOD("save", "path"), &ConfigFile::save); diff --git a/core/io/config_file.h b/core/io/config_file.h index 3ab6fef868..d927779f9c 100644 --- a/core/io/config_file.h +++ b/core/io/config_file.h @@ -60,6 +60,7 @@ public: void get_section_keys(const String &p_section, List<String> *r_keys) const; void erase_section(const String &p_section); + void erase_section_key(const String &p_section, const String &p_key); Error save(const String &p_path); Error load(const String &p_path); |