本文整理汇总了C++中ChannelList::activateLimit方法的典型用法代码示例。如果您正苦于以下问题:C++ ChannelList::activateLimit方法的具体用法?C++ ChannelList::activateLimit怎么用?C++ ChannelList::activateLimit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ChannelList
的用法示例。
在下文中一共展示了ChannelList::activateLimit方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: replyChannels
void ChannelsResponder::replyChannels(std::ostream& out, cxxtools::http::Request& request, cxxtools::http::Reply& reply)
{
QueryHandler q("/channels", request);
ChannelList* channelList;
if ( q.isFormat(".json") ) {
reply.addHeader("Content-Type", "application/json; charset=utf-8");
channelList = (ChannelList*)new JsonChannelList(&out);
} else if ( q.isFormat(".html") ) {
reply.addHeader("Content-Type", "text/html; charset=utf-8");
channelList = (ChannelList*)new HtmlChannelList(&out);
} else if ( q.isFormat(".xml") ) {
reply.addHeader("Content-Type", "text/xml; charset=utf-8");
channelList = (ChannelList*)new XmlChannelList(&out);
} else {
reply.httpReturn(403, "Resources are not available for the selected format. (Use: .json, .html or .xml)");
return;
}
std::string channel_details = q.getParamAsString(0);
int start_filter = q.getOptionAsInt("start");
int limit_filter = q.getOptionAsInt("limit");
std::string group_filter = q.getOptionAsString("group");
if (channel_details.length() > 0) {
cChannel* channel = VdrExtension::getChannel(channel_details);
if (channel == NULL || channel->GroupSep()) {
reply.httpReturn(403, "The requested channel is not available.");
delete channelList;
return;
} else {
channelList->init();
std::string group = "";
int total = 0;
for (cChannel *channelIt = Channels.First(); channelIt; channelIt = Channels.Next(channelIt))
{
if (!channelIt->GroupSep())
total++;
else
if ( total < channel->Number())
group = channelIt->Name();
}
channelList->setTotal(total);
std::string image = FileCaches::get()->searchChannelLogo(channel);
channelList->addChannel(channel, group, image.length() == 0);
}
} else {
if ( start_filter >= 0 && limit_filter >= 1 ) {
channelList->activateLimit(start_filter, limit_filter);
}
channelList->init();
int total = 0;
std::string group = "";
for (cChannel *channel = Channels.First(); channel; channel = Channels.Next(channel))
{
if (!channel->GroupSep()) {
if ( group_filter.length() == 0 || group == group_filter ) {
std::string image = FileCaches::get()->searchChannelLogo(channel);
channelList->addChannel(channel, group, image.length() != 0);
total++;
}
} else {
group = channel->Name();
}
}
channelList->setTotal(total);
}
channelList->finish();
delete channelList;
}