diff options
author | George Hazan <george.hazan@gmail.com> | 2016-02-25 13:36:37 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2016-02-25 13:36:37 +0000 |
commit | 42095fb5cb7228f9dfb94965988029fd7f47b793 (patch) | |
tree | 6185ec5d7450fb474ed80b0ce95d0d1c0e0b26a8 /plugins/Quotes/src/Locale.cpp | |
parent | 8e891173c74ceaa0964f32be247f380fd5f8bcd1 (diff) |
Quotes: major code cleaning
git-svn-id: http://svn.miranda-ng.org/main/trunk@16335 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Quotes/src/Locale.cpp')
-rw-r--r-- | plugins/Quotes/src/Locale.cpp | 91 |
1 files changed, 38 insertions, 53 deletions
diff --git a/plugins/Quotes/src/Locale.cpp b/plugins/Quotes/src/Locale.cpp index fe1427dac7..4e72558cff 100644 --- a/plugins/Quotes/src/Locale.cpp +++ b/plugins/Quotes/src/Locale.cpp @@ -5,70 +5,55 @@ const std::locale GetSystemLocale() return std::locale("");
}
-namespace
+tstring get_int_registry_value(LPCTSTR pszValueName)
{
- tstring get_int_registry_value(LPCTSTR pszValueName)
- {
- tstring sResult;
- HKEY hKey = NULL;
- LONG lResult = ::RegOpenKeyEx(HKEY_CURRENT_USER,
- _T("Control Panel\\International"), 0, KEY_QUERY_VALUE, &hKey);
- if ((ERROR_SUCCESS == lResult) && (NULL != hKey))
- {
- DWORD dwType = 0;
- DWORD dwSize = 0;
- lResult = ::RegQueryValueEx(hKey, pszValueName, nullptr, &dwType, nullptr, &dwSize);
- if ((ERROR_SUCCESS == lResult) && ((REG_SZ == dwType) || (REG_EXPAND_SZ == dwType)))
- {
- std::vector<TCHAR> aBuffer(dwSize);
- lResult = ::RegQueryValueEx(hKey, pszValueName, nullptr, nullptr, reinterpret_cast<LPBYTE>(&*aBuffer.begin()), &dwSize);
- if (ERROR_SUCCESS == lResult)
- {
- std::copy(aBuffer.begin(), aBuffer.end(), std::back_inserter(sResult));
- }
- }
+ tstring sResult;
+ HKEY hKey = NULL;
+ LONG lResult = ::RegOpenKeyEx(HKEY_CURRENT_USER,
+ _T("Control Panel\\International"), 0, KEY_QUERY_VALUE, &hKey);
+ if ((ERROR_SUCCESS == lResult) && (NULL != hKey)) {
+ DWORD dwType = 0;
+ DWORD dwSize = 0;
+ lResult = ::RegQueryValueEx(hKey, pszValueName, nullptr, &dwType, nullptr, &dwSize);
+ if ((ERROR_SUCCESS == lResult) && ((REG_SZ == dwType) || (REG_EXPAND_SZ == dwType))) {
+ std::vector<TCHAR> aBuffer(dwSize);
+ lResult = ::RegQueryValueEx(hKey, pszValueName, nullptr, nullptr, reinterpret_cast<LPBYTE>(&*aBuffer.begin()), &dwSize);
+ if (ERROR_SUCCESS == lResult)
+ std::copy(aBuffer.begin(), aBuffer.end(), std::back_inserter(sResult));
}
-
- if (NULL != hKey)
- {
- lResult = ::RegCloseKey(hKey);
- assert(ERROR_SUCCESS == lResult);
- }
-
- return sResult;
}
- tstring date_win_2_boost(const tstring& sFrmt)
- {
- tstring sResult(_T("%d.%m.%y"));
- if (sFrmt == _T("dd/MM/yy"))
- {
- sResult = _T("%d/%m/%y");
- }
- else if (sFrmt == _T("yyyy-MM-dd"))
- {
- sResult = _T("%y-%m-%d");
- }
- return sResult;
+ if (NULL != hKey) {
+ lResult = ::RegCloseKey(hKey);
+ assert(ERROR_SUCCESS == lResult);
}
- tstring time_win_2_boost(const tstring& sFrmt)
- {
- tstring sResult = _T("%H:%M:%S");
- if (sFrmt == _T("H:mm") || sFrmt == _T("HH:mm"))
- {
- sResult = _T("%H:%M");
- }
- return sResult;
- }
+ return sResult;
}
-tstring Quotes_GetDateFormat(bool bShort)
+LPCTSTR date_win_2_boost(const tstring& sFrmt)
+{
+ if (sFrmt == _T("dd/MM/yy"))
+ return _T("%d/%m/%y");
+ if (sFrmt == _T("yyyy-MM-dd"))
+ return _T("%y-%m-%d");
+ return _T("%d.%m.%y");
+}
+
+LPCTSTR time_win_2_boost(const tstring& sFrmt)
+{
+ if (sFrmt == _T("H:mm") || sFrmt == _T("HH:mm"))
+ return _T("%H:%M");
+
+ return _T("%H:%M:%S");
+}
+
+LPCTSTR Quotes_GetDateFormat(bool bShort)
{
return date_win_2_boost(get_int_registry_value(bShort ? _T("sShortDate") : _T("sLongDate")));
}
-tstring Quotes_GetTimeFormat(bool bShort)
+LPCTSTR Quotes_GetTimeFormat(bool bShort)
{
return time_win_2_boost(get_int_registry_value(bShort ? _T("sShortTime") : _T("sTimeFormat")));
-}
\ No newline at end of file +}
|