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


C++ Name::size方法代码示例

本文整理汇总了C++中ndn::Name::size方法的典型用法代码示例。如果您正苦于以下问题:C++ Name::size方法的具体用法?C++ Name::size怎么用?C++ Name::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ndn::Name的用法示例。


在下文中一共展示了Name::size方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: getSegmentationNumbers

void NdnRtcNamespace::getSegmentationNumbers(const ndn::Name &prefix,
                                             PacketNumber &packetNumber,
                                             SegmentNumber &segmentNumber)
{
    int p = -1;
    packetNumber = -1;
    segmentNumber = -1;
    
    if (isDeltaFramesPrefix(prefix))
    {
        p = findComponent(prefix, NameComponentStreamFramesDelta);
    }
    else if (isKeyFramePrefix(prefix))
    {
        p = findComponent(prefix, NameComponentStreamFramesKey);
    }
    
    if (p > 0)
    {
        if (p+1 < prefix.size())
        {
            Name::Component packetNoComp = prefix.get(p+1);
            packetNumber = NdnRtcUtils::frameNumber(packetNoComp);
        }
        
        if (p+3 < prefix.size())
        {
            Name::Component segmentNoComp = prefix.get(p+3);
            segmentNumber = NdnRtcUtils::segmentNumber(segmentNoComp);
        }
    }
}
开发者ID:monster-xie,项目名称:ndnrtc,代码行数:32,代码来源:ndnrtc-namespace.cpp

示例2: trimSegmentNumber

int NdnRtcNamespace::trimSegmentNumber(const ndn::Name &prefix,
                                        Name &trimmedPrefix)
{
    trimmedPrefix = prefix;
    
    if (getSegmentNumber(prefix) == -1)
        return -1;
    
    int p = -1;
    
    if (isDeltaFramesPrefix(prefix))
    {
        p = findComponent(prefix, NameComponentStreamFramesDelta);
    }
    else if (isKeyFramePrefix(prefix))
    {
        p = findComponent(prefix, NameComponentStreamFramesKey);
    }
    
    if (p > 0 &&
        p+3 < prefix.size())
    {
        p += 3;
        trimmedPrefix = prefix.getSubName(0, p);
    }
    
    return p;
}
开发者ID:monster-xie,项目名称:ndnrtc,代码行数:28,代码来源:ndnrtc-namespace.cpp

示例3: extractMeta

//******************************************************************************
bool extractMeta(const ndn::Name& name, NamespaceInfo& info)
{
    // example: name == %FD%05/%00%00
    if (name.size() >= 1 && name[0].isVersion())
    {
        info.metaVersion_ = name[0].toVersion();
        if (name.size() >= 2)
        {
            info.segNo_ = name[1].toSegment();
            info.hasSegNo_ = true;
        }
        else
            info.hasSegNo_ = false;
        return true;
    }

    return false;
}
开发者ID:remap,项目名称:ndnrtc,代码行数:19,代码来源:name-components.cpp

示例4: component

/**
 * @brief search a name component in ndn::Name and return the position of the component
 * @param name         where to search the searchString
 * @param searchString the string to search in name
 * @return -1 if searchString not found else return the position
 * starting from 0
 */
inline static int32_t
getNameComponentPosition(const ndn::Name& name, const std::string& searchString)
{
  ndn::name::Component component(searchString);
  size_t nameSize = name.size();
  for (uint32_t i = 0; i < nameSize; i++) {
    if (component == name[i]) {
      return (int32_t)i;
    }
  }
  return -1;
}
开发者ID:Antrek,项目名称:NDNProject,代码行数:19,代码来源:name-helper.hpp

示例5: findComponent

int NdnRtcNamespace::findComponent(const ndn::Name &prefix,
                                     const std::string &componentString)
{
    int pos = -1;
    int nComponents = prefix.size();
    Name::Component searchComponent((const uint8_t*)componentString.c_str(),
                                    componentString.size());
    
    for (int i = nComponents; i--; i >= 0)
    {
        Name::Component c = prefix.get(i);
        
        if (c == searchComponent)
        {
            pos = i;
            break;
        }
    }
    
    return pos;
}
开发者ID:monster-xie,项目名称:ndnrtc,代码行数:21,代码来源:ndnrtc-namespace.cpp

示例6: ndnrtcSubName

bool
NameComponents::extractInfo(const ndn::Name& name, NamespaceInfo& info)
{
    bool goodName = false;
    static Name ndnrtcSubName(NameComponents::NameComponentApp);
    Name subName;
    int i;

    for (i = name.size()-2; i > 0 && !goodName; --i)
    {
        subName = name.getSubName(i);
        goodName = ndnrtcSubName.match(subName);
    }

    if (goodName)
    {
        info.basePrefix_ = name.getSubName(0, i+1);

        if ((goodName = subName[1].isVersion()))
        {
            info.apiVersion_ = subName[1].toVersion();

            if (subName.size() > 2 &&
                (goodName = (subName[2] == Name::Component(NameComponents::NameComponentAudio) ||
                            subName[2] == Name::Component(NameComponents::NameComponentVideo)))  )
            {
                info.streamType_ = (subName[2] == Name::Component(NameComponents::NameComponentAudio) ? 
                                MediaStreamParams::MediaStreamType::MediaStreamTypeAudio : 
                                MediaStreamParams::MediaStreamType::MediaStreamTypeVideo );

                if (info.streamType_ == MediaStreamParams::MediaStreamType::MediaStreamTypeAudio)
                    return extractAudioStreamInfo(subName.getSubName(3), info);
                else
                    return extractVideoStreamInfo(subName.getSubName(3), info);
            }
        }
    }

    return false;
}
开发者ID:remap,项目名称:ndnrtc,代码行数:40,代码来源:name-components.cpp

示例7: interestName

    void
    onInterest(const ndn::Name& name, const ndn::Interest& interest)
    {
        ndn::Name interestName(interest.getName());

        if(DEBUG)
            std::cout << "received interest: " << interest.getName() << std::endl;

        //run scripts if requested by server
        ndn::Name cmpName(getFilter()+SCRIPT_SUFFIX);
        int num_components = cmpName.size();
        if(cmpName.isPrefixOf(interestName))
        {
            int numberOfComponents = interestName.size();
            for(int i = num_components; i < numberOfComponents; ++i)
            {
                m_scriptsList.push_front(interestName[i].toUri());
            }
            runScripts(interestName);
        }
        else
        {
            int numberOfComponents = interestName.size();
            if(!m_remoteLinks.empty())
            {
                std::cerr << "remote links list is not empty - check for a missing reports!!" << std::endl;
                m_remoteLinks.clear();
            }
            for(int i = name.size(); i < numberOfComponents; ++i)
            {
                m_remoteLinks.insert(interestName[i].toUri());
            }

            // ask for local status
            fetchFaceStatusInformation(interestName);
        }
    }
开发者ID:WU-ARL,项目名称:Emulated_NDN_Testbed_in_ONL,代码行数:37,代码来源:nfdStatusCollectorClient.cpp

示例8: getSegmentNumber

SegmentNumber NdnRtcNamespace::getSegmentNumber(const ndn::Name &prefix)
{
    PacketNumber segmentNo = -1;
    int p = -1;
    
    if (isDeltaFramesPrefix(prefix))
    {
        p = findComponent(prefix, NameComponentStreamFramesDelta);
    }
    else if (isKeyFramePrefix(prefix))
    {
        p = findComponent(prefix, NameComponentStreamFramesKey);
    }
    
    
    if (p > 0 &&
        p+3 < prefix.size())
    {
        Name::Component segmentNoComp = prefix.get(p+3);
        segmentNo = NdnRtcUtils::segmentNumber(segmentNoComp);
    }
    
    return segmentNo;
}
开发者ID:monster-xie,项目名称:ndnrtc,代码行数:24,代码来源:ndnrtc-namespace.cpp

示例9: extractAudioStreamInfo

bool extractAudioStreamInfo(const ndn::Name& name, NamespaceInfo& info)
{
    if (name.size() == 1)
    {
        info.streamName_ = name[0].toEscapedString();
        return true;
    }

    if (name.size() == 2 && name[1].isTimestamp())
    {
        info.streamName_ = name[0].toEscapedString();
        info.streamTimestamp_ = name[1].toTimestamp();
        return true;
    }

    if (name.size() < 2)
        return false;

    int idx = 0;
    info.streamName_ = name[idx++].toEscapedString();
    info.isMeta_ = (name[idx++] == Name::Component(NameComponents::NameComponentMeta));
    
    if (info.isMeta_)
    {
        info.segmentClass_ = SegmentClass::Meta;
        if (name.size() < idx+1)
            return false;

        info.threadName_ = "";
        return extractMeta(name.getSubName(idx), info);;
    }
    else
    {
        info.class_ = SampleClass::Unknown;
        info.segmentClass_ = SegmentClass::Unknown;
        info.streamTimestamp_ = name[idx-1].toTimestamp();
        info.threadName_ = name[idx++].toEscapedString();

        if (name.size() == 3)
        {
            info.hasSeqNo_ = false;
            return true;
        }

        info.isMeta_ = (name[idx] == Name::Component(NameComponents::NameComponentMeta));

        if (info.isMeta_)
        { 
            info.segmentClass_ = SegmentClass::Meta;
            if (name.size() > idx+1 && extractMeta(name.getSubName(idx+1), info))
                return true;
            return false;
        }

        info.isDelta_ = true;
        info.class_ = SampleClass::Delta;

        try
        {
            if (name.size() > 3)
                info.sampleNo_ = (PacketNumber)name[idx++].toSequenceNumber();
            
            info.hasSeqNo_ = true;
            if (name.size() > idx)
            {
                if (name[idx] == Name::Component(NameComponents::NameComponentManifest))
                    info.segmentClass_ = SegmentClass::Manifest;
                else
                {
                    info.hasSegNo_ = true;
                    info.segmentClass_ = SegmentClass::Data;
                    info.segNo_ = name[idx].toSegment();
                }
                return true;
            }
            else
            {
                info.hasSegNo_ = false;
                return true;
            }
        }
        catch (std::runtime_error& e)
        {
            return false;
        }
    }

    return false;
}
开发者ID:remap,项目名称:ndnrtc,代码行数:89,代码来源:name-components.cpp

示例10: extractVideoStreamInfo

bool extractVideoStreamInfo(const ndn::Name& name, NamespaceInfo& info)
{
    if (name.size() == 1)
    {
        info.streamName_ = name[0].toEscapedString();
        return true;
    }

    if (name.size() == 2 && name[1].isTimestamp())
    {
        info.streamName_ = name[0].toEscapedString();
        info.streamTimestamp_ = name[1].toTimestamp();
        return true;
    }

    if (name.size() < 3)
        return false;

    int idx = 0;
    info.streamName_ = name[idx++].toEscapedString();
    info.isMeta_ = (name[idx++] == Name::Component(NameComponents::NameComponentMeta));

    if (info.isMeta_)
    {   // example: name == camera/_meta/%FD%05/%00%00
        info.segmentClass_ = SegmentClass::Meta;
        info.threadName_ = "";
        return extractMeta(name.getSubName(idx), info);
    }
    else
    {   // example: name == camera/%FC%00%00%01c_%27%DE%D6/hi/d/%FE%07/%00%00

        info.class_ = SampleClass::Unknown;
        info.segmentClass_ = SegmentClass::Unknown;
        info.streamTimestamp_ = name[idx-1].toTimestamp();
        info.threadName_ = name[idx++].toEscapedString();
        
        if (name.size() <= idx)
            return true;

        info.isMeta_ = (name[idx++] == Name::Component(NameComponents::NameComponentMeta));

        if (info.isMeta_)
        {   // example: camera/%FC%00%00%01c_%27%DE%D6/hi/_meta/%FD%05/%00%00
            info.segmentClass_ = SegmentClass::Meta;
            if(name.size() > idx-1 && extractMeta(name.getSubName(idx), info))
                return true;
            return false;
        }

        if (name[idx-1] == Name::Component(NameComponents::NameComponentDelta) || 
            name[idx-1] == Name::Component(NameComponents::NameComponentKey))
        {
            info.isDelta_ = (name[idx-1] == Name::Component(NameComponents::NameComponentDelta));
            info.class_ = (info.isDelta_ ? SampleClass::Delta : SampleClass::Key);

            try{
                if (name.size() > idx)
                    info.sampleNo_ = (PacketNumber)name[idx++].toSequenceNumber();
                else
                {
                    info.hasSeqNo_ = false;
                    return true;
                }
            
                info.hasSeqNo_ = true;
                if (name.size() > idx)
                {
                    info.isParity_ = (name[idx] == Name::Component(NameComponents::NameComponentParity));
                    info.hasSegNo_ = true;

                    if (info.isParity_ && name.size() > idx+1)
                    {
                        info.segmentClass_ = SegmentClass::Parity;
                        info.segNo_ = name[idx+1].toSegment();
                        return true;
                    }
                    else 
                    {
                        if (info.isParity_) 
                            return false;
                        else
                        {
                            if (name[idx] == Name::Component(NameComponents::NameComponentManifest))
                                info.segmentClass_ = SegmentClass::Manifest;
                            else
                            {
                                info.segmentClass_ = SegmentClass::Data;
                                info.segNo_ = name[idx].toSegment();
                            }
                        }
                        return true;
                    }
                }
                else
                {
                    info.segmentClass_ = SegmentClass::Unknown;
                    info.hasSegNo_ = false;
                    return true;
                }
            }
//.........这里部分代码省略.........
开发者ID:remap,项目名称:ndnrtc,代码行数:101,代码来源:name-components.cpp


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