summaryrefslogtreecommitdiff
path: root/plugins/CurrencyRates/src/DBUtils.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2018-12-08 20:12:16 +0300
committerGeorge Hazan <ghazan@miranda.im>2018-12-08 20:12:26 +0300
commit8ffc77be71507825a8f7585bcabff8ccc370206a (patch)
treeaa13a8070f31286db6ad22e17a577e547942f951 /plugins/CurrencyRates/src/DBUtils.cpp
parent41b2fdfc654e3eec07c97ceba00cda13d988ffff (diff)
db_get_sa / db_get_wsa to receive the default value, massive code simplification
Diffstat (limited to 'plugins/CurrencyRates/src/DBUtils.cpp')
-rw-r--r--plugins/CurrencyRates/src/DBUtils.cpp26
1 files changed, 4 insertions, 22 deletions
diff --git a/plugins/CurrencyRates/src/DBUtils.cpp b/plugins/CurrencyRates/src/DBUtils.cpp
index ebb816a8ea..cdc6560db7 100644
--- a/plugins/CurrencyRates/src/DBUtils.cpp
+++ b/plugins/CurrencyRates/src/DBUtils.cpp
@@ -1,31 +1,13 @@
#include "StdAfx.h"
-std::string CurrencyRates_DBGetStringA(MCONTACT hContact, const char* szModule, const char* szSetting, const char* pszDefValue /*= NULL*/)
+std::string CurrencyRates_DBGetStringA(MCONTACT hContact, const char* szModule, const char* szSetting, const char* pszDefValue)
{
- std::string sResult;
- char* pszSymbol = db_get_sa(hContact, szModule, szSetting);
- if (nullptr != pszSymbol) {
- sResult = pszSymbol;
- mir_free(pszSymbol);
- }
- else if (nullptr != pszDefValue)
- sResult = pszDefValue;
-
- return sResult;
+ return std::string(ptrA(db_get_sa(hContact, szModule, szSetting, pszDefValue)));
}
-std::wstring CurrencyRates_DBGetStringW(MCONTACT hContact, const char* szModule, const char* szSetting, const wchar_t* pszDefValue/* = NULL*/)
+std::wstring CurrencyRates_DBGetStringW(MCONTACT hContact, const char* szModule, const char* szSetting, const wchar_t* pszDefValue)
{
- std::wstring sResult;
- wchar_t* pszSymbol = db_get_wsa(hContact, szModule, szSetting);
- if (nullptr != pszSymbol) {
- sResult = pszSymbol;
- mir_free(pszSymbol);
- }
- else if (nullptr != pszDefValue)
- sResult = pszDefValue;
-
- return sResult;
+ return std::wstring(ptrW(db_get_wsa(hContact, szModule, szSetting, pszDefValue)));
}
bool CurrencyRates_DBWriteDouble(MCONTACT hContact, const char* szModule, const char* szSetting, double dValue)