summaryrefslogtreecommitdiff
path: root/plugins/Quotes/src/QuotesProviderDukasCopy.cpp
diff options
context:
space:
mode:
authorKirill Volinsky <mataes2007@gmail.com>2014-12-21 09:49:05 +0000
committerKirill Volinsky <mataes2007@gmail.com>2014-12-21 09:49:05 +0000
commit9b119cadd74e1343cad493e8b366e69743a620d0 (patch)
treee11d3923e86eb667f1a2f20e1126066e51ed73ce /plugins/Quotes/src/QuotesProviderDukasCopy.cpp
parent1b85ad91e7aa1af9d295d399e560a2adc6d413d3 (diff)
Quotes: changed warning level to w4
git-svn-id: http://svn.miranda-ng.org/main/trunk@11552 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Quotes/src/QuotesProviderDukasCopy.cpp')
-rw-r--r--plugins/Quotes/src/QuotesProviderDukasCopy.cpp148
1 files changed, 74 insertions, 74 deletions
diff --git a/plugins/Quotes/src/QuotesProviderDukasCopy.cpp b/plugins/Quotes/src/QuotesProviderDukasCopy.cpp
index 0be79c498e..a2aaa28e93 100644
--- a/plugins/Quotes/src/QuotesProviderDukasCopy.cpp
+++ b/plugins/Quotes/src/QuotesProviderDukasCopy.cpp
@@ -12,10 +12,10 @@ namespace
{
inline tstring get_quote_id(MCONTACT hContact)
{
- return Quotes_DBGetStringT(hContact,QUOTES_MODULE_NAME,DB_STR_QUOTE_ID);
+ return Quotes_DBGetStringT(hContact, QUOTES_MODULE_NAME, DB_STR_QUOTE_ID);
}
- inline bool is_quote_id_equal(MCONTACT hContact,const tstring& sID)
+ inline bool is_quote_id_equal(MCONTACT hContact, const tstring& sID)
{
return sID == get_quote_id(hContact);
}
@@ -23,18 +23,18 @@ namespace
bool CQuotesProviderDukasCopy::IsQuoteWatched(const CQuote& rQuote)const
{
- return m_aContacts.end() != std::find_if(m_aContacts.begin(),m_aContacts.end(),
- boost::bind(is_quote_id_equal,_1,rQuote.GetID()));
+ return m_aContacts.end() != std::find_if(m_aContacts.begin(), m_aContacts.end(),
+ boost::bind(is_quote_id_equal, _1, rQuote.GetID()));
}
-bool CQuotesProviderDukasCopy::WatchForQuote(const CQuote& rQuote,bool bWatch)
+bool CQuotesProviderDukasCopy::WatchForQuote(const CQuote& rQuote, bool bWatch)
{
const tstring& sQuoteID = rQuote.GetID();
- TContracts::iterator i =
- std::find_if(m_aContacts.begin(),m_aContacts.end(),
- boost::bind(is_quote_id_equal,_1,sQuoteID));
+ TContracts::iterator i =
+ std::find_if(m_aContacts.begin(), m_aContacts.end(),
+ boost::bind(is_quote_id_equal, _1, sQuoteID));
- if((false == bWatch) && (i != m_aContacts.end()))
+ if ((false == bWatch) && (i != m_aContacts.end()))
{
MCONTACT hContact = *i;
{// for CCritSection
@@ -45,15 +45,15 @@ bool CQuotesProviderDukasCopy::WatchForQuote(const CQuote& rQuote,bool bWatch)
CallService(MS_DB_CONTACT_DELETE, WPARAM(hContact), 0);
return true;
}
- else if((true == bWatch) && (i == m_aContacts.end()))
+ else if ((true == bWatch) && (i == m_aContacts.end()))
{
MCONTACT hContact = CreateNewContact(rQuote.GetSymbol());
- if(hContact)
+ if (hContact)
{
- db_set_ts(hContact,QUOTES_PROTOCOL_NAME,DB_STR_QUOTE_ID,sQuoteID.c_str());
- if(false == rQuote.GetName().empty())
+ db_set_ts(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_ID, sQuoteID.c_str());
+ if (false == rQuote.GetName().empty())
{
- db_set_ts(hContact,QUOTES_PROTOCOL_NAME,DB_STR_QUOTE_DESCRIPTION,rQuote.GetName().c_str());
+ db_set_ts(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_DESCRIPTION, rQuote.GetName().c_str());
}
return true;
@@ -70,11 +70,11 @@ tstring CQuotesProviderDukasCopy::BuildHTTPURL()const
{
CGuard<CLightMutex> cs(m_cs);
- for(TContracts::const_iterator i = m_aContacts.begin();i != m_aContacts.end();++i)
+ for (TContracts::const_iterator i = m_aContacts.begin(); i != m_aContacts.end(); ++i)
{
MCONTACT hContact = *i;
tstring sID = get_quote_id(hContact);
- if(false == sID.empty())
+ if (false == sID.empty())
{
sURL << sID << _T(",");
}
@@ -88,7 +88,7 @@ namespace
{
struct CEconomicRateInfo
{
- CEconomicRateInfo() : m_dCurRate(0.0),m_dPrevRate(0.0) {}
+ CEconomicRateInfo() : m_dCurRate(0.0), m_dPrevRate(0.0) {}
tstring m_sName;
double m_dCurRate;
double m_dPrevRate;
@@ -98,14 +98,14 @@ namespace
typedef std::vector<CEconomicRateInfo> TEconomicRates;
typedef IHTMLNode::THTMLNodePtr THTMLNodePtr;
- bool string2double(const TCHAR* pszText,double& rValue)
+ bool string2double(const TCHAR* pszText, double& rValue)
{
assert(pszText);
try
{
rValue = boost::lexical_cast<double>(pszText);
}
- catch(boost::bad_lexical_cast &)
+ catch (boost::bad_lexical_cast &)
{
return false;
}
@@ -114,43 +114,43 @@ namespace
}
- void parse_row(const THTMLNodePtr& pRow,TEconomicRates& raRates)
+ void parse_row(const THTMLNodePtr& pRow, TEconomicRates& raRates)
{
CEconomicRateInfo ri;
ri.m_sID = pRow->GetAttribute(_T("sid"));
- if(false == ri.m_sID.empty())
+ if (false == ri.m_sID.empty())
{
unsigned short cColsHandled = 0;
tostringstream sSidID;
sSidID << _T("id") << ri.m_sID;
size_t cNodes = pRow->GetChildCount();
- for(size_t i = 0;i < cNodes && cColsHandled < 2;++i)
+ for (size_t i = 0; i < cNodes && cColsHandled < 2; ++i)
{
THTMLNodePtr pCol = pRow->GetChildPtr(i);
- if(pCol)
+ if (pCol)
{
tstring sColID = pCol->GetAttribute(_T("id"));
- if(false == sColID.empty())
+ if (false == sColID.empty())
{
- if(0 == quotes_stricmp(sColID.c_str(),_T("stock")))
+ if (0 == quotes_stricmp(sColID.c_str(), _T("stock")))
{
ri.m_sName = pCol->GetText();
- if(false == ri.m_sName.empty())
+ if (false == ri.m_sName.empty())
{
++cColsHandled;
}
}
- else if(0 == quotes_stricmp(sSidID.str().c_str(),sColID.c_str()))
+ else if (0 == quotes_stricmp(sSidID.str().c_str(), sColID.c_str()))
{
tstring sRate = pCol->GetText();
- if((false == sRate.empty()) && (true == string2double(sRate.c_str(),ri.m_dCurRate)))
+ if ((false == sRate.empty()) && (true == string2double(sRate.c_str(), ri.m_dCurRate)))
{
ri.m_dPrevRate = ri.m_dCurRate;
++cColsHandled;
tstring sOldRate = pCol->GetAttribute(_T("oldPrice"));
- if(false == sOldRate.empty())
+ if (false == sOldRate.empty())
{
- string2double(sOldRate.c_str(),ri.m_dPrevRate);
+ string2double(sOldRate.c_str(), ri.m_dPrevRate);
}
}
}
@@ -158,47 +158,47 @@ namespace
}
}
- if(2 == cColsHandled)
+ if (2 == cColsHandled)
{
raRates.push_back(ri);
}
}
}
-// void parse_table(const THTMLNodePtr& pNode,TEconomicRates& raRates)
-// {
-// size_t cNodes = pNode->GetChildCount();
-// for(size_t i = 0;i < cNodes;++i)
-// {
-// THTMLNodePtr pChild = pNode->GetChildPtr(i);
-// if(pChild && pChild->Is(IHTMLNode::TableRow))
-// {
-// parse_row(pChild,raRates);
-// }
-// }
-//
-// }
-
- void parser_html_node(const THTMLNodePtr& pNode,TEconomicRates& raRates)
+ // void parse_table(const THTMLNodePtr& pNode,TEconomicRates& raRates)
+ // {
+ // size_t cNodes = pNode->GetChildCount();
+ // for(size_t i = 0;i < cNodes;++i)
+ // {
+ // THTMLNodePtr pChild = pNode->GetChildPtr(i);
+ // if(pChild && pChild->Is(IHTMLNode::TableRow))
+ // {
+ // parse_row(pChild,raRates);
+ // }
+ // }
+ //
+ // }
+
+ void parser_html_node(const THTMLNodePtr& pNode, TEconomicRates& raRates)
{
size_t cNodes = pNode->GetChildCount();
- for(size_t i = 0;i < cNodes;++i)
+ for (size_t i = 0; i < cNodes; ++i)
{
THTMLNodePtr pChild = pNode->GetChildPtr(i);
- if(pChild && pChild->Is(IHTMLNode::TableRow))
+ if (pChild && pChild->Is(IHTMLNode::TableRow))
{
- parse_row(pChild,raRates);
+ parse_row(pChild, raRates);
}
}
}
- bool parse_HTML(const tstring& sHTML,TEconomicRates& raRates)
+ bool parse_HTML(const tstring& sHTML, TEconomicRates& raRates)
{
IHTMLEngine::THTMLParserPtr pHTMLParser = CModuleInfo::GetHTMLEngine()->GetParserPtr();
THTMLNodePtr pRoot = pHTMLParser->ParseString(sHTML);
- if(pRoot)
+ if (pRoot)
{
- parser_html_node(pRoot,raRates);
+ parser_html_node(pRoot, raRates);
return true;
}
else
@@ -211,42 +211,42 @@ namespace
void CQuotesProviderDukasCopy::RefreshQuotes(TContracts& anContacts)
{
- if(CModuleInfo::GetInstance().GetExtendedStatusFlag())
+ if (CModuleInfo::GetInstance().GetExtendedStatusFlag())
{
- std::for_each(anContacts.begin(),anContacts.end(),
- boost::bind(SetContactStatus,_1,ID_STATUS_OCCUPIED));
+ std::for_each(anContacts.begin(), anContacts.end(),
+ boost::bind(SetContactStatus, _1, ID_STATUS_OCCUPIED));
}
tstring sURL = BuildHTTPURL();
CHTTPSession http;
-// LogIt(Info,sURL);
- if(true == http.OpenURL(sURL))
+ // LogIt(Info,sURL);
+ if (true == http.OpenURL(sURL))
{
-// if(true == IsOnline())
+ // if(true == IsOnline())
{
tstring sHTML;
- if(true == http.ReadResponce(sHTML))
+ if (true == http.ReadResponce(sHTML))
{
-// LogIt(Info,sHTML);
-// if(true == IsOnline())
+ // LogIt(Info,sHTML);
+ // if(true == IsOnline())
{
TEconomicRates aRates;
- if(true == parse_HTML(sHTML,aRates)
+ if (true == parse_HTML(sHTML, aRates)
&& (true == IsOnline()))
{
- for(TEconomicRates::const_iterator it = aRates.begin();(it != aRates.end()) && (true == IsOnline());++it)
+ for (TEconomicRates::const_iterator it = aRates.begin(); (it != aRates.end()) && (true == IsOnline()); ++it)
{
const CEconomicRateInfo& ri = *it;
- TContracts::iterator i = std::find_if(anContacts.begin(),anContacts.end(),
- boost::bind(is_quote_id_equal,_1,ri.m_sID));
- if(i != anContacts.end() && (true == IsOnline()))
+ TContracts::iterator i = std::find_if(anContacts.begin(), anContacts.end(),
+ boost::bind(is_quote_id_equal, _1, ri.m_sID));
+ if (i != anContacts.end() && (true == IsOnline()))
{
MCONTACT hContact = *i;
anContacts.erase(i);
- WriteContactRate(hContact,ri.m_dCurRate,ri.m_sName);
+ WriteContactRate(hContact, ri.m_dCurRate, ri.m_sName);
}
}
}
@@ -255,13 +255,13 @@ void CQuotesProviderDukasCopy::RefreshQuotes(TContracts& anContacts)
}
}
- std::for_each(anContacts.begin(),anContacts.end(),
- boost::bind(&SetContactStatus,_1,ID_STATUS_NA));
+ std::for_each(anContacts.begin(), anContacts.end(),
+ boost::bind(&SetContactStatus, _1, ID_STATUS_NA));
}
-void CQuotesProviderDukasCopy::ShowPropertyPage(WPARAM wp,OPTIONSDIALOGPAGE& odp)
+void CQuotesProviderDukasCopy::ShowPropertyPage(WPARAM wp, OPTIONSDIALOGPAGE& odp)
{
- ShowDukasCopyPropPage(this,wp,odp);
+ ShowDukasCopyPropPage(this, wp, odp);
}
void CQuotesProviderDukasCopy::Accept(CQuotesProviderVisitor& visitor)const
@@ -274,9 +274,9 @@ MCONTACT CQuotesProviderDukasCopy::GetContactByQuoteID(const tstring& rsQuoteID)
{
CGuard<CLightMutex> cs(m_cs);
- TContracts::const_iterator i = std::find_if(m_aContacts.begin(),m_aContacts.end(),
- boost::bind(std::equal_to<tstring>(),rsQuoteID,boost::bind(get_quote_id,_1)));
- if(i != m_aContacts.end())
+ TContracts::const_iterator i = std::find_if(m_aContacts.begin(), m_aContacts.end(),
+ boost::bind(std::equal_to<tstring>(), rsQuoteID, boost::bind(get_quote_id, _1)));
+ if (i != m_aContacts.end())
return *i;
return NULL;