const bool OTSettings::CheckSet_bool(const OTString & strSection, const OTString & strKey, const bool & bDefault, bool & out_bResult, bool & out_bIsNew, const OTString & strComment) { if (! strSection.Exists()) { OTLog::vError("%s: Error: %s is Empty!\n", __FUNCTION__, "strSection" ); OT_ASSERT(false); } if (! strKey.Exists()) { OTLog::vError("%s: Error: %s is Empty!\n", __FUNCTION__, "strKey" ); OT_ASSERT(false); } bool bKeyExist, bNewKeyCheck, bTempResult; if (! Check_bool(strSection,strKey,bTempResult,bKeyExist)) return false; if (bKeyExist) { // Already have a key, lets use it's value. out_bIsNew = false; out_bResult = bTempResult; return true; } else { if (! Set_bool(strSection,strKey,bDefault,bNewKeyCheck,strComment)) return false; if (bNewKeyCheck) { // Success out_bIsNew = true; out_bResult = bDefault; return true; } } // If we get here, error! OT_ASSERT(false); return false; }
bool Settings::CheckSet_bool(const String& strSection, const String& strKey, const bool& bDefault, bool& out_bResult, bool& out_bIsNew, const String& strComment) { if (!strSection.Exists()) { otErr << __FUNCTION__ << ": Error: " << "strSection" << " is Empty!\n"; OT_FAIL; } if (!strKey.Exists()) { otErr << __FUNCTION__ << ": Error: " << "strKey" << " is Empty!\n"; OT_FAIL; } bool bKeyExist, bTempResult; if (!Check_bool(strSection, strKey, bTempResult, bKeyExist)) return false; if (bKeyExist) { // Already have a key, lets use it's value. out_bIsNew = false; out_bResult = bTempResult; return true; } else { bool bNewKeyCheck; if (!Set_bool(strSection, strKey, bDefault, bNewKeyCheck, strComment)) return false; if (bNewKeyCheck) { // Success out_bIsNew = true; out_bResult = bDefault; return true; } } // If we get here, error! OT_FAIL; }