summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2019-02-21 14:19:47 +0300
committerGeorge Hazan <ghazan@miranda.im>2019-02-21 14:19:47 +0300
commita7d1b6c89d200736226183753ffc88f094c3bc16 (patch)
treeacc572f0009eddf5379fb1d67c9ad42e02ec3f5c /plugins
parenteb49354573e56105a5afc5517c5012fcb4439be5 (diff)
even less shit
Diffstat (limited to 'plugins')
-rw-r--r--plugins/CurrencyRates/src/CurrencyRatesProviderBase.cpp28
-rw-r--r--plugins/CurrencyRates/src/CurrencyRatesProviderBase.h1
-rw-r--r--plugins/CurrencyRates/src/CurrencyRatesProviderVisitorTendency.cpp24
-rw-r--r--plugins/CurrencyRates/src/CurrencyRatesProviderVisitorTendency.h25
-rw-r--r--plugins/CurrencyRates/src/stdafx.h1
5 files changed, 21 insertions, 58 deletions
diff --git a/plugins/CurrencyRates/src/CurrencyRatesProviderBase.cpp b/plugins/CurrencyRates/src/CurrencyRatesProviderBase.cpp
index 2247f547d5..b44d01aedb 100644
--- a/plugins/CurrencyRates/src/CurrencyRatesProviderBase.cpp
+++ b/plugins/CurrencyRates/src/CurrencyRatesProviderBase.cpp
@@ -227,7 +227,7 @@ public:
public:
CTendency() : m_nComparison(NonValid) {}
- bool Parse(const ICurrencyRatesProvider* pProvider, const tstring& rsFrmt, MCONTACT hContact)
+ bool Parse(CCurrencyRatesProviderBase *pProvider, const tstring& rsFrmt, MCONTACT hContact)
{
m_abValueFlags[0] = false;
m_abValueFlags[1] = false;
@@ -249,13 +249,10 @@ public:
if (i != rsFrmt.end()) {
wchar_t t = *i;
++i;
- CCurrencyRatesProviderVisitorTendency visitor(hContact, t);
- pProvider->Accept(visitor);
- if (false == visitor.IsValid()) {
- bValid = false;
- }
- else {
- double d = visitor.GetResult();
+
+ double d;
+ bValid = pProvider->ParseSymbol(hContact, t, d);
+ if (bValid) {
m_adValues[nCurValue] = d;
m_abValueFlags[nCurValue] = true;
++nCurValue;
@@ -855,3 +852,18 @@ void CCurrencyRatesProviderBase::FillFormat(TFormatSpecificators &array) const
array.push_back(CFormatSpecificator(L"\\t", TranslateT("Tabulation")));
array.push_back(CFormatSpecificator(L"\\\\", TranslateT("Left slash (\\)")));
}
+
+bool CCurrencyRatesProviderBase::ParseSymbol(MCONTACT hContact, wchar_t c, double &d)
+{
+ switch (c) {
+ case 'r':
+ case 'R':
+ return CurrencyRates_DBReadDouble(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CURRENCYRATE_CURR_VALUE, d);
+
+ case 'p':
+ case 'P':
+ return CurrencyRates_DBReadDouble(hContact, CURRENCYRATES_MODULE_NAME, DB_STR_CURRENCYRATE_PREV_VALUE, d);
+ }
+
+ return false;
+} \ No newline at end of file
diff --git a/plugins/CurrencyRates/src/CurrencyRatesProviderBase.h b/plugins/CurrencyRates/src/CurrencyRatesProviderBase.h
index cfaab4236d..49813f640f 100644
--- a/plugins/CurrencyRates/src/CurrencyRatesProviderBase.h
+++ b/plugins/CurrencyRates/src/CurrencyRatesProviderBase.h
@@ -106,6 +106,7 @@ public:
void RefreshContact(MCONTACT hContact) override;
void FillFormat(TFormatSpecificators&) const override;
+ bool ParseSymbol(MCONTACT hContact, wchar_t c, double &d);
protected:
const tstring& GetURL() const;
diff --git a/plugins/CurrencyRates/src/CurrencyRatesProviderVisitorTendency.cpp b/plugins/CurrencyRates/src/CurrencyRatesProviderVisitorTendency.cpp
deleted file mode 100644
index 2d5260aab5..0000000000
--- a/plugins/CurrencyRates/src/CurrencyRatesProviderVisitorTendency.cpp
+++ /dev/null
@@ -1,24 +0,0 @@
-#include "stdafx.h"
-
-CCurrencyRatesProviderVisitorTendency::CCurrencyRatesProviderVisitorTendency(MCONTACT hContact, wchar_t chr) :
- m_hContact(hContact), m_chr(chr)
-{
-}
-
-void CCurrencyRatesProviderVisitorTendency::Visit(const CCurrencyRatesProviderBase&)
-{
- switch (m_chr) {
- case 'r':
- case 'R':
- GetValue(DB_STR_CURRENCYRATE_CURR_VALUE);
- break;
- case 'p':
- GetValue(DB_STR_CURRENCYRATE_PREV_VALUE);
- break;
- }
-}
-
-void CCurrencyRatesProviderVisitorTendency::GetValue(LPCSTR pszDbKeyName)
-{
- m_bValid = CurrencyRates_DBReadDouble(m_hContact, CURRENCYRATES_MODULE_NAME, pszDbKeyName, m_dResult);
-}
diff --git a/plugins/CurrencyRates/src/CurrencyRatesProviderVisitorTendency.h b/plugins/CurrencyRates/src/CurrencyRatesProviderVisitorTendency.h
deleted file mode 100644
index 0ec92d4ee4..0000000000
--- a/plugins/CurrencyRates/src/CurrencyRatesProviderVisitorTendency.h
+++ /dev/null
@@ -1,25 +0,0 @@
-#ifndef __AD721194_E9944366_9CF1_0307460EF32F_CurrencyRatesProviderVisitorTendency_h__
-#define __AD721194_E9944366_9CF1_0307460EF32F_CurrencyRatesProviderVisitorTendency_h__
-
-class CCurrencyRatesProviderVisitorTendency : public CCurrencyRatesProviderVisitor
-{
-public:
- CCurrencyRatesProviderVisitorTendency(MCONTACT hContact, wchar_t chr);
-
- bool IsValid() const{ return m_bValid; }
- double GetResult() const{ return m_dResult; }
-
-private:
- virtual void Visit(const CCurrencyRatesProviderBase& rProvider);
-
-private:
- void GetValue(LPCSTR pszDbKeyName);
-
-private:
- MCONTACT m_hContact;
- wchar_t m_chr;
- bool m_bValid = false;
- double m_dResult = 0.0;
-};
-
-#endif //__AD721194_E9944366_9CF1_0307460EF32F_CurrencyRatesProviderVisitorTendency_h__
diff --git a/plugins/CurrencyRates/src/stdafx.h b/plugins/CurrencyRates/src/stdafx.h
index 6aa8daef76..3ed55d1173 100644
--- a/plugins/CurrencyRates/src/stdafx.h
+++ b/plugins/CurrencyRates/src/stdafx.h
@@ -99,7 +99,6 @@ inline tstring currencyrates_a2t(const char* s)
#include "CurrencyRatesProviderBase.h"
#include "CurrencyRatesProviderVisitor.h"
#include "CurrencyRatesProviderVisitorFormater.h"
-#include "CurrencyRatesProviderVisitorTendency.h"
#define CHART_IMPLEMENT
#ifdef CHART_IMPLEMENT