当前位置: 首页>>代码示例>>C++>>正文


C++ ChannelList::activateLimit方法代码示例

本文整理汇总了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;
}
开发者ID:sja,项目名称:vdr-plugin-restfulapi,代码行数:73,代码来源:channels.cpp


注:本文中的ChannelList::activateLimit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。