const bool OTPaths::Get( OTSettings * pConfig, const OTString & strSection, const OTString & strKey, OTString & out_strVar, bool & out_bIsRelative, bool & out_bKeyExist ) { if (!strSection.Exists()) { OTLog::sError("%s: Null: %s passed in!\n", __FUNCTION__, "strSection" ); OT_ASSERT(false); } if (!strKey.Exists()) { OTLog::sError("%s: Null: %s passed in!\n", __FUNCTION__, "strKey" ); OT_ASSERT(false); } out_strVar = ""; out_bIsRelative = false; out_bKeyExist = false; if (NULL == pConfig) { OT_ASSERT(false); return false; } const bool bPreLoaded(pConfig->IsLoaded()); if (!bPreLoaded) { pConfig->Reset(); if(!pConfig->Load()) { OT_ASSERT(false); return false; } } bool bBoolExists(false), bStringExists(false), bIsRelative(false); OTString strRelativeKey(""), strOutFolder(""); strRelativeKey.Format("%s%s",strKey.Get(),OT_CONFIG_ISRELATIVE); if(pConfig->Check_bool(strSection,strRelativeKey,bIsRelative,bBoolExists)) { if(pConfig->Check_str(strSection,strKey,strOutFolder,bStringExists)) { if (bBoolExists && bStringExists) { if (!bIsRelative) // lets fix the path, so it dosn't matter how people write it in the config. { if(!ToReal(strOutFolder,strOutFolder)) { OT_ASSERT(false); return false; } if(!FixPath(strOutFolder,strOutFolder,true)) { OT_ASSERT(false); return false; } } out_strVar = strOutFolder; out_bIsRelative = bIsRelative; out_bKeyExist = true; } else { out_strVar = ""; out_bIsRelative = false; out_bKeyExist = false; } if (!bPreLoaded) { pConfig->Reset(); } return true; } } // if we get here, there has been a error! OT_ASSERT(false); pConfig->Reset(); return false; }
// static bool OTPaths::Get(OTSettings& config, const String& strSection, const String& strKey, String& out_strVar, bool& out_bIsRelative, bool& out_bKeyExist) { if (!strSection.Exists()) { otErr << __FUNCTION__ << ": Null: " << "strSection" << " passed in!\n"; OT_FAIL; } if (!strKey.Exists()) { otErr << __FUNCTION__ << ": Null: " << "strKey" << " passed in!\n"; OT_FAIL; } out_strVar = ""; out_bIsRelative = false; out_bKeyExist = false; const bool bPreLoaded(config.IsLoaded()); if (!bPreLoaded) { config.Reset(); if (!config.Load()) { OT_FAIL; } } bool bBoolExists(false), bIsRelative(false); String strRelativeKey(""), strOutFolder(""); strRelativeKey.Format("%s%s", strKey.Get(), OT_CONFIG_ISRELATIVE); if (config.Check_bool(strSection, strRelativeKey, bIsRelative, bBoolExists)) { bool bStringExists = false; if (config.Check_str(strSection, strKey, strOutFolder, bStringExists)) { if (bBoolExists && bStringExists) { if (!bIsRelative) // lets fix the path, so it dosn't matter how // people write it in the config. { if (!ToReal(strOutFolder, strOutFolder)) { OT_FAIL; } if (!FixPath(strOutFolder, strOutFolder, true)) { OT_FAIL; } } out_strVar = strOutFolder; out_bIsRelative = bIsRelative; out_bKeyExist = true; } else { out_strVar = ""; out_bIsRelative = false; out_bKeyExist = false; } if (!bPreLoaded) { config.Reset(); } return true; } } // if we get here, there has been a error! OT_FAIL; }