Skip to content

Commit fb14d1f

Browse files
committed
code cleanup :)
1 parent 637e7a2 commit fb14d1f

11 files changed

+292
-282
lines changed

channels.cpp

+29-28
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "channels.h"
2+
using namespace std;
23

3-
void ChannelsResponder::reply(std::ostream& out, cxxtools::http::Request& request, cxxtools::http::Reply& reply)
4+
void ChannelsResponder::reply(ostream& out, cxxtools::http::Request& request, cxxtools::http::Reply& reply)
45
{
56
QueryHandler::addHeader(reply);
67

@@ -20,7 +21,7 @@ void ChannelsResponder::reply(std::ostream& out, cxxtools::http::Request& reques
2021
}
2122
}
2223

23-
void ChannelsResponder::replyChannels(std::ostream& out, cxxtools::http::Request& request, cxxtools::http::Reply& reply)
24+
void ChannelsResponder::replyChannels(ostream& out, cxxtools::http::Request& request, cxxtools::http::Reply& reply)
2425
{
2526
QueryHandler q("/channels", request);
2627

@@ -40,10 +41,10 @@ void ChannelsResponder::replyChannels(std::ostream& out, cxxtools::http::Request
4041
return;
4142
}
4243

43-
std::string channel_details = q.getParamAsString(0);
44+
string channel_details = q.getParamAsString(0);
4445
int start_filter = q.getOptionAsInt("start");
4546
int limit_filter = q.getOptionAsInt("limit");
46-
std::string group_filter = q.getOptionAsString("group");
47+
string group_filter = q.getOptionAsString("group");
4748

4849
if (channel_details.length() > 0) {
4950
cChannel* channel = VdrExtension::getChannel(channel_details);
@@ -54,7 +55,7 @@ void ChannelsResponder::replyChannels(std::ostream& out, cxxtools::http::Request
5455
} else {
5556
channelList->init();
5657

57-
std::string group = "";
58+
string group = "";
5859
int total = 0;
5960
for (cChannel *channelIt = Channels.First(); channelIt; channelIt = Channels.Next(channelIt))
6061
{
@@ -65,7 +66,7 @@ void ChannelsResponder::replyChannels(std::ostream& out, cxxtools::http::Request
6566
group = channelIt->Name();
6667
}
6768
channelList->setTotal(total);
68-
std::string image = FileCaches::get()->searchChannelLogo(channel);
69+
string image = FileCaches::get()->searchChannelLogo(channel);
6970
channelList->addChannel(channel, group, image.length() == 0);
7071
}
7172
} else {
@@ -74,12 +75,12 @@ void ChannelsResponder::replyChannels(std::ostream& out, cxxtools::http::Request
7475
}
7576
channelList->init();
7677
int total = 0;
77-
std::string group = "";
78+
string group = "";
7879
for (cChannel *channel = Channels.First(); channel; channel = Channels.Next(channel))
7980
{
8081
if (!channel->GroupSep()) {
8182
if ( group_filter.length() == 0 || group == group_filter ) {
82-
std::string image = FileCaches::get()->searchChannelLogo(channel);
83+
string image = FileCaches::get()->searchChannelLogo(channel);
8384
channelList->addChannel(channel, group, image.length() != 0);
8485
total++;
8586
}
@@ -94,37 +95,37 @@ void ChannelsResponder::replyChannels(std::ostream& out, cxxtools::http::Request
9495
delete channelList;
9596
}
9697

97-
void ChannelsResponder::replyImage(std::ostream& out, cxxtools::http::Request& request, cxxtools::http::Reply& reply)
98+
void ChannelsResponder::replyImage(ostream& out, cxxtools::http::Request& request, cxxtools::http::Reply& reply)
9899
{
99100
StreamExtension se(&out);
100101
QueryHandler q("/channels/image/", request);
101102

102-
std::string channelid = q.getParamAsString(0);
103+
string channelid = q.getParamAsString(0);
103104
cChannel* channel = VdrExtension::getChannel(channelid);
104-
std::string imageFolder = Settings::get()->ChannelLogoDirectory() + (std::string)"/";
105+
string imageFolder = Settings::get()->ChannelLogoDirectory() + (string)"/";
105106

106107
if (channel == NULL) {
107108
reply.httpReturn(502, "Channel not found!");
108109
return;
109110
}
110111

111-
std::string imageName = FileCaches::get()->searchChannelLogo(channel);
112+
string imageName = FileCaches::get()->searchChannelLogo(channel);
112113

113114
if (imageName.length() == 0 ) {
114115
reply.httpReturn(502, "No image found!");
115116
return;
116117
}
117118

118-
std::string absolute_path = imageFolder + imageName;
119-
std::string contenttype = (std::string)"image/" + imageName.substr( imageName.find_last_of('.') + 1 );
119+
string absolute_path = imageFolder + imageName;
120+
string contenttype = (string)"image/" + imageName.substr( imageName.find_last_of('.') + 1 );
120121
if ( se.writeBinary(absolute_path) ) {
121122
reply.addHeader("Content-Type", contenttype.c_str());
122123
} else {
123124
reply.httpReturn(502, "Binary Output failed");
124125
}
125126
}
126127

127-
void ChannelsResponder::replyGroups(std::ostream& out, cxxtools::http::Request& request, cxxtools::http::Reply& reply)
128+
void ChannelsResponder::replyGroups(ostream& out, cxxtools::http::Request& request, cxxtools::http::Reply& reply)
128129
{
129130
QueryHandler q("/channels/groups", request);
130131
ChannelGroupList* channelGroupList;
@@ -182,7 +183,7 @@ void operator<<= (cxxtools::SerializationInfo& si, const SerChannel& c)
182183
si.addMember("is_radio") <<= c.IsRadio;
183184
}
184185

185-
ChannelList::ChannelList(std::ostream* _out)
186+
ChannelList::ChannelList(ostream* _out)
186187
{
187188
s = new StreamExtension(_out);
188189
}
@@ -198,7 +199,7 @@ void HtmlChannelList::init()
198199
s->write("<ul>");
199200
}
200201

201-
void HtmlChannelList::addChannel(cChannel* channel, std::string group, bool image)
202+
void HtmlChannelList::addChannel(cChannel* channel, string group, bool image)
202203
{
203204
if ( filtered() ) return;
204205

@@ -213,20 +214,20 @@ void HtmlChannelList::finish()
213214
s->write("</body></html>");
214215
}
215216

216-
void JsonChannelList::addChannel(cChannel* channel, std::string group, bool image)
217+
void JsonChannelList::addChannel(cChannel* channel, string group, bool image)
217218
{
218219
if ( filtered() ) return;
219220

220-
std::string suffix = (std::string) ".ts";
221+
string suffix = (string) ".ts";
221222

222223
SerChannel serChannel;
223224
serChannel.Name = StringExtension::UTF8Decode(channel->Name());
224225
serChannel.Number = channel->Number();
225-
serChannel.ChannelId = StringExtension::UTF8Decode((std::string)channel->GetChannelID().ToString());
226+
serChannel.ChannelId = StringExtension::UTF8Decode((string)channel->GetChannelID().ToString());
226227
serChannel.Image = image;
227228
serChannel.Group = StringExtension::UTF8Decode(group);
228229
serChannel.Transponder = channel->Transponder();
229-
serChannel.Stream = StringExtension::UTF8Decode(((std::string)channel->GetChannelID().ToString() + (std::string)suffix).c_str());
230+
serChannel.Stream = StringExtension::UTF8Decode(((string)channel->GetChannelID().ToString() + (string)suffix).c_str());
230231
// TODO: There is an atsc Patch
231232
#if APIVERSNUM >= 10714
232233
serChannel.IsAtsc = channel->IsAtsc();
@@ -255,20 +256,20 @@ void XmlChannelList::init()
255256
s->write("<channels xmlns=\"http://www.domain.org/restfulapi/2011/channels-xml\">\n");
256257
}
257258

258-
void XmlChannelList::addChannel(cChannel* channel, std::string group, bool image)
259+
void XmlChannelList::addChannel(cChannel* channel, string group, bool image)
259260
{
260261
if ( filtered() ) return;
261262

262-
std::string suffix = (std::string) ".ts";
263+
string suffix = (string) ".ts";
263264

264265
s->write(" <channel>\n");
265266
s->write(cString::sprintf(" <param name=\"name\">%s</param>\n", StringExtension::encodeToXml(channel->Name()).c_str()));
266267
s->write(cString::sprintf(" <param name=\"number\">%i</param>\n", channel->Number()));
267-
s->write(cString::sprintf(" <param name=\"channel_id\">%s</param>\n", StringExtension::encodeToXml( (std::string)channel->GetChannelID().ToString()).c_str()));
268+
s->write(cString::sprintf(" <param name=\"channel_id\">%s</param>\n", StringExtension::encodeToXml( (string)channel->GetChannelID().ToString()).c_str()));
268269
s->write(cString::sprintf(" <param name=\"image\">%s</param>\n", (image ? "true" : "false")));
269270
s->write(cString::sprintf(" <param name=\"group\">%s</param>\n", StringExtension::encodeToXml( group ).c_str()));
270271
s->write(cString::sprintf(" <param name=\"transponder\">%i</param>\n", channel->Transponder()));
271-
s->write(cString::sprintf(" <param name=\"stream\">%s</param>\n", StringExtension::encodeToXml( ((std::string)channel->GetChannelID().ToString() + (std::string)suffix).c_str()).c_str()));
272+
s->write(cString::sprintf(" <param name=\"stream\">%s</param>\n", StringExtension::encodeToXml( ((string)channel->GetChannelID().ToString() + (string)suffix).c_str()).c_str()));
272273
// TODO: There is an atsc Patch
273274
#if APIVERSNUM >= 10714
274275
s->write(cString::sprintf(" <param name=\"is_atsc\">%s</param>\n", channel->IsAtsc() ? "true" : "false"));
@@ -305,7 +306,7 @@ void HtmlChannelGroupList::init()
305306
s->write("<ul>");
306307
}
307308

308-
void HtmlChannelGroupList::addGroup(std::string group)
309+
void HtmlChannelGroupList::addGroup(string group)
309310
{
310311
if ( filtered() ) return;
311312

@@ -320,7 +321,7 @@ void HtmlChannelGroupList::finish()
320321
s->write("</body></html>");
321322
}
322323

323-
void JsonChannelGroupList::addGroup(std::string group)
324+
void JsonChannelGroupList::addGroup(string group)
324325
{
325326
if ( filtered() ) return;
326327
groups.push_back(StringExtension::UTF8Decode(group));
@@ -341,7 +342,7 @@ void XmlChannelGroupList::init()
341342
s->write("<groups xmlns=\"http://www.domain.org/restfulapi/2011/groups-xml\">\n");
342343
}
343344

344-
void XmlChannelGroupList::addGroup(std::string group)
345+
void XmlChannelGroupList::addGroup(string group)
345346
{
346347
if ( filtered() ) return;
347348
s->write(cString::sprintf(" <group>%s</group>\n", group.c_str()));

epgsearch.cpp

+31-31
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "epgsearch.h"
22

3+
using namespace std;
34

45
void operator<<= (cxxtools::SerializationInfo& si, SerSearchTimerContainer s)
56
{
@@ -54,11 +55,10 @@ void operator<<= (cxxtools::SerializationInfo& si, SerSearchTimerContainer s)
5455

5556
namespace vdrlive {
5657

57-
using namespace std;
5858

59-
std::string SearchTimer::ToXml()
59+
string SearchTimer::ToXml()
6060
{
61-
std::ostringstream s;
61+
ostringstream s;
6262
s << "<searchtimer>\n"
6363
<< "<id>" << Id() << "</id>\n"
6464
<< "<search>" << StringExtension::encodeToXml(Search()) << "</search>\n"
@@ -89,7 +89,7 @@ std::string SearchTimer::ToXml()
8989
<< "<switch_min_before>" << SwitchMinBefore() << "</switch_min_before>\n"
9090
<< "<use_ext_epg_info>" << UseExtEPGInfo() << "</use_ext_epg_info>\n"
9191
<< "<ext_epg_info>\n";
92-
std::vector< std::string > epg_infos = ExtEPGInfo();
92+
vector<string > epg_infos = ExtEPGInfo();
9393
for (int i=0;i<(int)epg_infos.size();i++)
9494
{
9595
s << " <info>" << epg_infos[i] << "</info>\n";
@@ -115,14 +115,14 @@ std::string SearchTimer::ToXml()
115115
return s.str();
116116
}
117117

118-
std::string SearchTimer::ToHtml()
118+
string SearchTimer::ToHtml()
119119
{
120120
return Search();
121121
}
122122

123-
std::string SearchTimer::LoadFromQuery(QueryHandler& q)
123+
string SearchTimer::LoadFromQuery(QueryHandler& q)
124124
{
125-
std::string search = q.getBodyAsString("search");
125+
string search = q.getBodyAsString("search");
126126
if ( search.length() > 0 ) { m_search = search; } else { return "Search required."; }
127127

128128
m_useTime = q.getBodyAsBool("use_time");
@@ -200,7 +200,7 @@ std::string SearchTimer::LoadFromQuery(QueryHandler& q)
200200
int action = q.getBodyAsInt("search_timer_action");
201201
if ( action >= 0 ) m_action = action;
202202

203-
std::string directory = q.getBodyAsString("directory");
203+
string directory = q.getBodyAsString("directory");
204204
if ( directory.length() > 0 ) m_directory = directory;
205205

206206
int del_after_days = q.getBodyAsInt("del_recs_after_days");
@@ -284,7 +284,7 @@ istream& operator>>( istream& is, tChannelID& ret )
284284
template< typename To, typename From >
285285
To lexical_cast( From const& from )
286286
{
287-
std::stringstream parser;
287+
stringstream parser;
288288
parser << from;
289289
To result;
290290
parser >> result;
@@ -299,8 +299,8 @@ bool operator<( SearchTimer const& left, SearchTimer const& right )
299299
{
300300
string leftlower = left.m_search;
301301
string rightlower = right.m_search;
302-
std::transform(leftlower.begin(), leftlower.end(), leftlower.begin(), (int(*)(int)) tolower);
303-
std::transform(rightlower.begin(), rightlower.end(), rightlower.begin(), (int(*)(int)) tolower);
302+
transform(leftlower.begin(), leftlower.end(), leftlower.begin(), (int(*)(int)) tolower);
303+
transform(rightlower.begin(), rightlower.end(), rightlower.begin(), (int(*)(int)) tolower);
304304
return leftlower < rightlower;
305305
}
306306

@@ -422,17 +422,17 @@ SearchTimer::SearchTimer( string const& data )
422422
}
423423
}
424424

425-
std::string SearchTimer::ToText()
425+
string SearchTimer::ToText()
426426
{
427-
std::string tmp_Start;
428-
std::string tmp_Stop;
429-
std::string tmp_minDuration;
430-
std::string tmp_maxDuration;
431-
std::string tmp_chanSel;
432-
std::string tmp_search;
433-
std::string tmp_directory;
434-
std::string tmp_catvalues;
435-
std::string tmp_blacklists;
427+
string tmp_Start;
428+
string tmp_Stop;
429+
string tmp_minDuration;
430+
string tmp_maxDuration;
431+
string tmp_chanSel;
432+
string tmp_search;
433+
string tmp_directory;
434+
string tmp_catvalues;
435+
string tmp_blacklists;
436436

437437
tmp_search = StringExtension::replace(StringExtension::replace(m_search, "|", "!^pipe^!"), ":", "|");
438438
tmp_directory = StringExtension::replace(StringExtension::replace(m_directory, "|", "!^pipe^!"), ":", "|");
@@ -462,7 +462,7 @@ std::string SearchTimer::ToText()
462462
cChannel const* channelMax = Channels.GetByChannelID( m_channelMax );
463463

464464
if (channelMax && channelMin->Number() < channelMax->Number())
465-
tmp_chanSel = *m_channelMin.ToString() + std::string("|") + *m_channelMax.ToString();
465+
tmp_chanSel = *m_channelMin.ToString() + string("|") + *m_channelMax.ToString();
466466
else
467467
tmp_chanSel = *m_channelMin.ToString();
468468
}
@@ -611,7 +611,7 @@ bool SearchTimers::Save(SearchTimer* searchtimer)
611611
}
612612
}
613613

614-
SearchTimer* SearchTimers::GetByTimerId( std::string const& id )
614+
SearchTimer* SearchTimers::GetByTimerId( string const& id )
615615
{
616616
for (SearchTimers::iterator timer = m_timers.begin(); timer != m_timers.end(); ++timer)
617617
if (timer->Id() == lexical_cast< int >(id))
@@ -620,15 +620,15 @@ SearchTimer* SearchTimers::GetByTimerId( std::string const& id )
620620

621621
}
622622

623-
bool SearchTimers::ToggleActive(std::string const& id)
623+
bool SearchTimers::ToggleActive(string const& id)
624624
{
625625
SearchTimer* search = GetByTimerId( id );
626626
if (!search) return false;
627627
search->SetUseAsSearchTimer(search->UseAsSearchTimer()==1?0:1);
628628
return Save(search);
629629
}
630630

631-
bool SearchTimers::Delete(std::string const& id)
631+
bool SearchTimers::Delete(string const& id)
632632
{
633633
SearchTimer* search = GetByTimerId( id );
634634
if (!search) return false;
@@ -681,7 +681,7 @@ void ExtEPGInfo::ParseValues( string const& data )
681681
m_values = StringExtension::split( data, "," );
682682
}
683683

684-
bool ExtEPGInfo::Selected(unsigned int index, std::string const& values)
684+
bool ExtEPGInfo::Selected(unsigned int index, string const& values)
685685
{
686686
if (index >= m_values.size()) return false;
687687
string extepgvalue = StringExtension::trim(m_values[index]);
@@ -791,7 +791,7 @@ const cEvent* SearchResult::GetEvent()
791791
return Schedule->GetEvent(m_eventId);
792792
}
793793

794-
std::set<std::string> SearchResults::querySet;
794+
set<string> SearchResults::querySet;
795795

796796
void SearchResults::GetByID(int id)
797797
{
@@ -803,7 +803,7 @@ void SearchResults::GetByID(int id)
803803
m_list.sort();
804804
}
805805

806-
void SearchResults::GetByQuery(std::string const& query)
806+
void SearchResults::GetByQuery(string const& query)
807807
{
808808
Epgsearch_services_v1_0 service;
809809
cPluginManager::CallFirstService(ServiceInterface, &service);
@@ -831,22 +831,22 @@ RecordingDirs::RecordingDirs(bool shortList)
831831
}
832832
}
833833

834-
std::string EPGSearchSetupValues::ReadValue(const std::string& entry)
834+
string EPGSearchSetupValues::ReadValue(const string& entry)
835835
{
836836
Epgsearch_services_v1_0 service;
837837
cPluginManager::CallFirstService(ServiceInterface, &service);
838838
return service.handler->ReadSetupValue(entry);
839839
}
840840

841-
bool EPGSearchSetupValues::WriteValue(const std::string& entry, const std::string& value)
841+
bool EPGSearchSetupValues::WriteValue(const string& entry, const string& value)
842842
{
843843
Epgsearch_services_v1_0 service;
844844
cPluginManager::CallFirstService(ServiceInterface, &service);
845845

846846
return service.handler->WriteSetupValue(entry, value);
847847
}
848848

849-
std::string EPGSearchExpr::EvaluateExpr(const std::string& expr, const cEvent* event)
849+
string EPGSearchExpr::EvaluateExpr(const string& expr, const cEvent* event)
850850
{
851851
Epgsearch_services_v1_2 service;
852852
cPluginManager::CallFirstService(ServiceInterface, &service);

0 commit comments

Comments
 (0)