Browse Source

added optional parameter "defaultValue" to INIFile::Section::getValue().

release/0.19
JustinAJ 10 years ago
parent
commit
b2f77f5fcb
  1. 4
      Jupiter/INIFile.cpp
  2. 2
      Jupiter/INIFile.h

4
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

2
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.

Loading…
Cancel
Save