From b2f77f5fcb99f636b8d1bb597f2e7e434da61a6e Mon Sep 17 00:00:00 2001 From: JustinAJ Date: Wed, 22 Oct 2014 05:24:01 -0400 Subject: [PATCH] added optional parameter "defaultValue" to INIFile::Section::getValue(). --- Jupiter/INIFile.cpp | 4 ++-- Jupiter/INIFile.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Jupiter/INIFile.cpp b/Jupiter/INIFile.cpp index a3e18f9..e48aea5 100644 --- a/Jupiter/INIFile.cpp +++ b/Jupiter/INIFile.cpp @@ -127,7 +127,7 @@ const Jupiter::ReadableString &Jupiter::INIFile::Section::getValue(size_t index) return Jupiter::INIFile::Section::data_->data.get(index)->data_->value; } -const Jupiter::ReadableString &Jupiter::INIFile::Section::getValue(const Jupiter::ReadableString &key) const +const Jupiter::ReadableString &Jupiter::INIFile::Section::getValue(const Jupiter::ReadableString &key, const Jupiter::ReadableString &defaultValue) const { Jupiter::INIFile::Section::KeyValuePair *pair; const unsigned int keySum = key.calcChecksumi(); @@ -138,7 +138,7 @@ const Jupiter::ReadableString &Jupiter::INIFile::Section::getValue(const Jupiter if (keySum == pair->getKeyChecksum() && pair->getKey().equalsi(key)) return pair->getValue(); } - return Jupiter::ReferenceString::empty; + return defaultValue; } Jupiter::INIFile::Section::KeyValuePair *Jupiter::INIFile::Section::getPair(size_t index) const diff --git a/Jupiter/INIFile.h b/Jupiter/INIFile.h index 9c73d33..684c7d6 100644 --- a/Jupiter/INIFile.h +++ b/Jupiter/INIFile.h @@ -126,7 +126,7 @@ namespace Jupiter * @param key Key of the key-value pair. * @return Value of a key-value pair, or an empty string if none is found. */ - const Jupiter::ReadableString &getValue(const Jupiter::ReadableString &key) const; + const Jupiter::ReadableString &getValue(const Jupiter::ReadableString &key, const Jupiter::ReadableString &defaultValue = Jupiter::ReferenceString::empty) const; /** * @brief Fetches a key-value pair at a specified index.