diff options
author | Ignacio Etcheverry <ignalfonsore@gmail.com> | 2016-01-01 21:12:54 +0100 |
---|---|---|
committer | Ignacio Etcheverry <ignalfonsore@gmail.com> | 2016-01-01 21:12:54 +0100 |
commit | 3de30bf01d8224f8ce6be725abbb1c6ca9891b88 (patch) | |
tree | 845b8d9a82b65454ef4c68fd1d36484c30ae5784 /core/io/config_file.cpp | |
parent | 0ed864d876347841d60797773a37c0b2f235c85c (diff) | |
download | redot-engine-3de30bf01d8224f8ce6be725abbb1c6ca9891b88.tar.gz |
Added default value param to ConfigFile.get_value()
Diffstat (limited to 'core/io/config_file.cpp')
-rw-r--r-- | core/io/config_file.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/core/io/config_file.cpp b/core/io/config_file.cpp index 03fdcf7c6c..f32d006cba 100644 --- a/core/io/config_file.cpp +++ b/core/io/config_file.cpp @@ -84,10 +84,10 @@ void ConfigFile::set_value(const String& p_section, const String& p_key, const V } } -Variant ConfigFile::get_value(const String& p_section, const String& p_key) const{ +Variant ConfigFile::get_value(const String& p_section, const String& p_key, Variant p_default) const { - ERR_FAIL_COND_V(!values.has(p_section),Variant()); - ERR_FAIL_COND_V(!values[p_section].has(p_key),Variant()); + ERR_FAIL_COND_V(!values.has(p_section),p_default); + ERR_FAIL_COND_V(!values[p_section].has(p_key),p_default); return values[p_section][p_key]; } @@ -199,7 +199,7 @@ Error ConfigFile::load(const String& p_path) { void ConfigFile::_bind_methods(){ ObjectTypeDB::bind_method(_MD("set_value","section","key","value"),&ConfigFile::set_value); - ObjectTypeDB::bind_method(_MD("get_value","section","key"),&ConfigFile::get_value); + ObjectTypeDB::bind_method(_MD("get_value","section","key","default"),&ConfigFile::get_value,DEFVAL(Variant())); ObjectTypeDB::bind_method(_MD("has_section","section"),&ConfigFile::has_section); ObjectTypeDB::bind_method(_MD("has_section_key","section","key"),&ConfigFile::has_section_key); |