summaryrefslogtreecommitdiff
path: root/plugins/Quotes/src/QuotesProviderYahoo.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/QuotesProviderYahoo.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/QuotesProviderYahoo.cpp')
-rw-r--r--plugins/Quotes/src/QuotesProviderYahoo.cpp106
1 files changed, 53 insertions, 53 deletions
diff --git a/plugins/Quotes/src/QuotesProviderYahoo.cpp b/plugins/Quotes/src/QuotesProviderYahoo.cpp
index d7196b7466..ab09978d39 100644
--- a/plugins/Quotes/src/QuotesProviderYahoo.cpp
+++ b/plugins/Quotes/src/QuotesProviderYahoo.cpp
@@ -11,7 +11,7 @@ namespace
if (*s.rbegin() == _T('"'))
{
tstring::iterator i(s.begin());
- std::advance(i,s.size()-1);
+ std::advance(i, s.size() - 1);
s.erase(i);
}
}
@@ -21,47 +21,47 @@ namespace
if (*s.rbegin() == _T('\n'))
{
tstring::iterator i(s.begin());
- std::advance(i,s.size()-1);
+ std::advance(i, s.size() - 1);
s.erase(i);
}
if (*s.rbegin() == _T('\r'))
{
tstring::iterator i(s.begin());
- std::advance(i,s.size()-1);
+ std::advance(i, s.size() - 1);
s.erase(i);
}
}
- bool t2d(const tstring& s,double& d)
+ bool t2d(const tstring& s, double& d)
{
tistringstream stream(s);
stream >> d;
return ((false == stream.fail()) && (false == stream.bad()));
-// try
-// {
-// d = boost::lexical_cast<double>(s);
-// return true;
-// }
-// catch(boost::bad_lexical_cast& e)
-// {
-// }
-// return false;
+ // try
+ // {
+ // d = boost::lexical_cast<double>(s);
+ // return true;
+ // }
+ // catch(boost::bad_lexical_cast& e)
+ // {
+ // }
+ // return false;
}
typedef std::vector<tstring> TStrings;
- bool get_double_from_parsed_line(MCONTACT hContact,const TStrings& rasParsedLine,size_t nIndex,const char* pszDbName)
+ bool get_double_from_parsed_line(MCONTACT hContact, const TStrings& rasParsedLine, size_t nIndex, const char* pszDbName)
{
- if(rasParsedLine.size() > nIndex)
+ if (rasParsedLine.size() > nIndex)
{
double d = 0.0;
- if(true == t2d(rasParsedLine[nIndex],d))
+ if (true == t2d(rasParsedLine[nIndex], d))
{
- return Quotes_DBWriteDouble(hContact,QUOTES_MODULE_NAME,pszDbName,d);
+ return Quotes_DBWriteDouble(hContact, QUOTES_MODULE_NAME, pszDbName, d);
}
}
- db_set_ts(hContact,QUOTES_MODULE_NAME,pszDbName,_T(""));
+ db_set_ts(hContact, QUOTES_MODULE_NAME, pszDbName, _T(""));
return false;
}
}
@@ -71,28 +71,28 @@ void CQuotesProviderYahoo::RefreshQuotes(TContracts& anContacts)
tstring sURL = GetURL();
bool bUseExtendedStatus = CModuleInfo::GetInstance().GetExtendedStatusFlag();
- typedef std::map<tstring,MCONTACT> TQuoteID2ContractHandles;
+ typedef std::map<tstring, MCONTACT> TQuoteID2ContractHandles;
TQuoteID2ContractHandles aQuoteID2Handles;
tostringstream oURL;
oURL << sURL << _T("dioksin.txt?s=");
- for(TContracts::const_iterator i = anContacts.begin();i != anContacts.end() && IsOnline();++i)
+ for (TContracts::const_iterator i = anContacts.begin(); i != anContacts.end() && IsOnline(); ++i)
{
MCONTACT hContact = *i;
- if(bUseExtendedStatus)
+ if (bUseExtendedStatus)
{
- SetContactStatus(hContact,ID_STATUS_OCCUPIED);
+ SetContactStatus(hContact, ID_STATUS_OCCUPIED);
}
- tstring sQuoteID = Quotes_DBGetStringT(hContact,QUOTES_MODULE_NAME,DB_STR_QUOTE_ID);
+ tstring sQuoteID = Quotes_DBGetStringT(hContact, QUOTES_MODULE_NAME, DB_STR_QUOTE_ID);
aQuoteID2Handles[sQuoteID] = hContact;
- if(i != anContacts.begin())
+ if (i != anContacts.begin())
{
oURL << _T("+");
}
oURL << sQuoteID;
}
- if(true == IsOnline())
+ if (true == IsOnline())
{
oURL << _T("&f=snl1ohgpc1");
CHTTPSession http;
@@ -102,40 +102,40 @@ void CQuotesProviderYahoo::RefreshQuotes(TContracts& anContacts)
if ((true == http.ReadResponce(sFile)) && (true == IsOnline()))
{
tistringstream out_str(sFile.c_str());
- while(false == out_str.eof())
+ while (false == out_str.eof())
{
tstring sLine;
- std::getline(out_str,sLine);
- if(false == sLine.empty())
+ std::getline(out_str, sLine);
+ if (false == sLine.empty())
{
remove_end_of_line(sLine);
TStrings asStrings;
- for(tstring::size_type nPos = sLine.find(_T(','));nPos != tstring::npos; nPos = sLine.find(_T(',')))
+ for (tstring::size_type nPos = sLine.find(_T(',')); nPos != tstring::npos; nPos = sLine.find(_T(',')))
{
tstring::iterator i(sLine.begin());
- std::advance(i,nPos);
- tstring s(sLine.begin(),i);
+ std::advance(i, nPos);
+ tstring s(sLine.begin(), i);
remove_quotes(s);
asStrings.push_back(s);
- if(i != sLine.end())
+ if (i != sLine.end())
{
- std::advance(i,1);
+ std::advance(i, 1);
}
- sLine.erase(sLine.begin(),i);
+ sLine.erase(sLine.begin(), i);
}
- if(false == sLine.empty())
+ if (false == sLine.empty())
{
remove_quotes(sLine);
- if(false == sLine.empty())
- asStrings.push_back(sLine);
+ if (false == sLine.empty())
+ asStrings.push_back(sLine);
}
-
+
size_t cItems = asStrings.size();
- if(cItems >= 3)
+ if (cItems >= 3)
{
enum
{
@@ -149,33 +149,33 @@ void CQuotesProviderYahoo::RefreshQuotes(TContracts& anContacts)
indexChange
};
auto it3 = aQuoteID2Handles.find(asStrings[indexSymbol]);
- if(it3 != aQuoteID2Handles.end())
+ if (it3 != aQuoteID2Handles.end())
{
MCONTACT hContact = it3->second;
double dRate = 0.0;
- if(true == t2d(asStrings[indexLastTrade],dRate))
+ if (true == t2d(asStrings[indexLastTrade], dRate))
{
- db_set_ts(hContact,QUOTES_MODULE_NAME,DB_STR_QUOTE_DESCRIPTION,asStrings[indexName].c_str());
-
- get_double_from_parsed_line(hContact,asStrings,indexOpen,DB_STR_YAHOO_OPEN_VALUE);
- get_double_from_parsed_line(hContact,asStrings,indexDayHigh,DB_STR_YAHOO_DAY_HIGH);
- get_double_from_parsed_line(hContact,asStrings,indexDayLow,DB_STR_YAHOO_DAY_LOW);
- get_double_from_parsed_line(hContact,asStrings,indexPreviousClose,DB_STR_YAHOO_PREVIOUS_CLOSE);
- get_double_from_parsed_line(hContact,asStrings,indexChange,DB_STR_YAHOO_CHANGE);
- WriteContactRate(hContact,dRate);
+ db_set_ts(hContact, QUOTES_MODULE_NAME, DB_STR_QUOTE_DESCRIPTION, asStrings[indexName].c_str());
+
+ get_double_from_parsed_line(hContact, asStrings, indexOpen, DB_STR_YAHOO_OPEN_VALUE);
+ get_double_from_parsed_line(hContact, asStrings, indexDayHigh, DB_STR_YAHOO_DAY_HIGH);
+ get_double_from_parsed_line(hContact, asStrings, indexDayLow, DB_STR_YAHOO_DAY_LOW);
+ get_double_from_parsed_line(hContact, asStrings, indexPreviousClose, DB_STR_YAHOO_PREVIOUS_CLOSE);
+ get_double_from_parsed_line(hContact, asStrings, indexChange, DB_STR_YAHOO_CHANGE);
+ WriteContactRate(hContact, dRate);
aQuoteID2Handles.erase(it3);
}
- }
+ }
}
}
}
}
}
- if(true == IsOnline())
+ if (true == IsOnline())
{
- std::for_each(aQuoteID2Handles.begin(),aQuoteID2Handles.end(),
- [](const TQuoteID2ContractHandles::value_type& pair){SetContactStatus(pair.second,ID_STATUS_NA);});
+ std::for_each(aQuoteID2Handles.begin(), aQuoteID2Handles.end(),
+ [](const TQuoteID2ContractHandles::value_type& pair){SetContactStatus(pair.second, ID_STATUS_NA); });
}
}
}