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


C++ Brn类代码示例

本文整理汇总了C++中Brn的典型用法代码示例。如果您正苦于以下问题:C++ Brn类的具体用法?C++ Brn怎么用?C++ Brn使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: recv

void SuiteMulticast::Receiver()
{
    iPortLock.Wait();
    SocketUdpMulticast recv(0, Endpoint(iPort, kMulticastAddress));
    iPort = recv.Port();
    iPortLock.Signal();

    iSender.Signal(); // signal ready to begin receiving

    Bwh buf(kBufBytes);
    Brn exp = iExp.Split(4);
    while(1) {
        recv.Receive(buf);
        TUint num = *((TUint32*)buf.Ptr());
        if(num == kQuit) {
            break;
        }
        Brn exp2 = exp.Split(0, num);
        Brn buf2 = buf.Split(4);
        TEST(buf2 == exp2);
        iSender.Signal();
    }

    iSender.Signal();
}
开发者ID:chinshou,项目名称:ohNet,代码行数:25,代码来源:TestNetwork.cpp

示例2: a

void DviSessionLpec::Unsubscribe()
{
    AutoMutex a(iSubscriptionLock);
    Brn cmd = Ascii::Trim(iParser.Remaining());
    if (cmd.Bytes() == 0) {
        for (TUint i=0; i<iSubscriptions.size(); i++) {
            DoUnsubscribe(0);
        }
        return;
    }

    try {
        const TUint lpecSid = Ascii::Uint(cmd);
        for (TUint i=0; i<iSubscriptions.size(); i++) {
            if (iSubscriptions[i].LpecSid() == lpecSid) {
                DoUnsubscribe(i);
                return;
            }
        }
        ReportError(LpecError::kSubscriptionNotFound);
    }
    catch (AsciiError&) {
        // not a sid, fall through to below to check for device/service
    }

    AutoMutex b(iDeviceLock);
    ParseDeviceAndService();
    for (TUint i=0; i<iSubscriptions.size(); i++) {
        if (iSubscriptions[i].Matches(*iTargetDevice, *iTargetService)) {
            DoUnsubscribe(i);
            return;
        }
    }
    ReportError(LpecError::kServiceNotSubscribed);
}
开发者ID:Montellese,项目名称:ohNet,代码行数:35,代码来源:DviServerLpec.cpp

示例3: key

void DviDevice::SetAttribute(const TChar* aKey, const TChar* aValue)
{
    Brn key(aKey);
    Parser parser(key);
    Brn name = parser.Next('.');
    aKey += name.Bytes() + 1;
    // assume keys starting 'Test' are a special case which can be updated at any time
    if (strlen(aKey) < 4 || strncmp(aKey, "Test", 4) != 0) {
        ASSERT(iEnabled == eDisabled);
    }
    if (name == Brn("Core")) {
        static const char* longPollEnable = "LongPollEnable";
        if (iProviderSubscriptionLongPoll == NULL && 
            strncmp(aKey, longPollEnable, sizeof(longPollEnable)-1) == 0) {
            iProviderSubscriptionLongPoll = new DviProviderSubscriptionLongPoll(*this);
            ConfigChanged();
        }
    }
    else {
        for (TUint i=0; i<(TUint)iProtocols.size(); i++) {
            IDvProtocol* protocol = iProtocols[i];
            if (protocol->ProtocolName() == name) {
                protocol->SetAttribute(aKey, aValue);
                ConfigChanged();
                break;
            }
        }
    }
}
开发者ID:astaykov,项目名称:ohNet,代码行数:29,代码来源:DviDevice.cpp

示例4: parser

void DviSessionUpnp::ParseRequestUri(const Brx& aUrlTail, DviDevice** aDevice, DviService** aService)
{
    Parser parser(iReaderRequest->Uri());
    Brn tmp = parser.Next('/');
    if (tmp.Bytes() > 0) {
        Error(HttpStatus::kPreconditionFailed);
    }
    Brn udn = parser.Next('/');
    DviDevice* device = DviDeviceMap::Find(udn);
    *aDevice = device;
    if (device == NULL) {
        Error(HttpStatus::kPreconditionFailed);
    }
    Brn serviceName = parser.Next('/');
    if (parser.Remaining() != aUrlTail) {
        Error(HttpStatus::kPreconditionFailed);
    }
    const TUint count = device->ServiceCount();
    for (TUint i=0; i<count; i++) {
        DviService& service = device->Service(i);
        if (service.ServiceType().PathUpnp() == serviceName) {
            *aService = &service;
            break;
        }
    }
}
开发者ID:astaykov,项目名称:ohNet,代码行数:26,代码来源:DviServerUpnp.cpp

示例5: ASSERT

Brn ReaderUntil::ReadProtocol(TUint aBytes)
{
    ASSERT(aBytes <= iMaxBytes);
    TByte* start = Ptr() + iOffset;
    TByte* p = start;
    if (aBytes <= iBytes - iOffset) {
        iOffset += aBytes;
        if (iOffset == iBytes) {
            iBytes = 0;
            iOffset = 0;
        }
        return Brn(start, aBytes);
    }
    if (iBytes > 0) {
        iBytes -= iOffset;
        start = Ptr();
        (void)memmove(start, start + iOffset, iBytes);
        p = start + iBytes;
        iOffset = 0;
        aBytes -= iBytes;
    }
    TUint remaining = aBytes;
    while (remaining > 0) {
        Brn buf = iReader.Read(remaining);
        (void)memcpy(p, buf.Ptr(), buf.Bytes());
        p += buf.Bytes();
    }
    iBytes = 0;
    iOffset = 0;
    return Brn(start, (TUint)(p - start));
}
开发者ID:SiMet,项目名称:ohNet,代码行数:31,代码来源:Stream.cpp

示例6: key

void DviProtocolUpnp::GetAttribute(const TChar* aKey, const TChar** aValue) const
{
    *aValue = iAttributeMap.Get(aKey);
    if (*aValue == NULL) {
        Brn key(aKey);
        static const Brn kServicePrefix("Service.");
        if (key.BeginsWith(kServicePrefix)) {
            Brn pathUpnp = key.Split(kServicePrefix.Bytes());
            const TUint count = iDevice.ServiceCount();
            for (TUint i=0; i<count; i++) {
                DviService& service = iDevice.Service(i);
                Bws<128> name(service.ServiceType().Domain());
                const TUint bytes = name.Bytes();
                for (TUint j=0; j<bytes; j++) {
                    if (name[j] == '.') {
                        name[j] = '-';
                    }
                }
                name.Append('.');
                name.Append(service.ServiceType().Name());
                if (name == pathUpnp) {
                    *aValue = (const TChar*)(service.ServiceType().VersionBuf().Ptr());
                    return;
                }
            }
        }
    }
}
开发者ID:Montellese,项目名称:ohNet,代码行数:28,代码来源:DviProtocolUpnp.cpp

示例7: parser

void HttpHeaderContentType::Process(const Brx& aValue)
{
    Parser parser(aValue);
    
    try {
        Brn type = parser.Next(';');
        Parser parser2(type);  // get first word of the type
        iType.Replace(parser2.Next());
        SetReceived();
    }
    catch (BufferOverflow&) {
        return;
    }
    
    Brn key;
    Brn value;
    
    for (;;) {
        key.Set(parser.Next('='));
        if (key.Bytes() == 0) {
            return;
        }
        value.Set(parser.Next());
        Process(key, value);
    }
}
开发者ID:astaykov,项目名称:ohNet,代码行数:26,代码来源:Http.cpp

示例8: kIndexFile

void DeviceBasic::WriteResource(const Brx& aUriTail, TIpAddress /*aInterface*/, std::vector<char*>& /*aLanguageList*/, IResourceWriter& aResourceWriter)
{
    const Brn kIndexFile("index.html");
    Bwh filePath(iConfigDir);
    Brn file;
    if (aUriTail.Bytes() == 0) {
        file.Set(kIndexFile);
    }
    else {
        file.Set(aUriTail);
    }
    const TByte sep =
#ifdef _WIN32
                      '\\';
#else
                      '/';
#endif
    filePath.Grow(filePath.Bytes() + 1 + file.Bytes()+1);
    filePath.Append(sep);
    filePath.Append(file);
    filePath.PtrZ();

    const char* path = (const char*)filePath.Ptr();
    FILE* fd = fopen(path, "rb");
    if (fd == NULL) {
        return;
    }
    static const TUint kMaxReadSize = 4096;
    struct stat fileStats;
    (void)stat(path, &fileStats);
    TUint bytes = (TUint)fileStats.st_size;
    const char* mime = NULL;
    for (TUint i=filePath.Bytes()-1; i>0; i--) {
        if (filePath[i] == '/' || filePath[i] == '\\') {
            break;
        }    
        if (filePath[i] == '.') {
            const char* ext = (const char*)filePath.Split(i+1, filePath.Bytes()-i-1).Ptr();
            if (strcmp(ext, "html") == 0 || strcmp(ext, "htm") == 0) {
                mime = kOhNetMimeTypeHtml;
            }
            break;
        }
    }
    aResourceWriter.WriteResourceBegin(bytes, mime);
    do {
        TByte buf[kMaxReadSize];
        TUint size = (bytes<kMaxReadSize? bytes : kMaxReadSize);
        size_t records_read = fread(buf, size, 1, fd);
        ASSERT(records_read == 1);
        aResourceWriter.WriteResource(buf, size);
        bytes -= size;
    } while (bytes > 0);
    aResourceWriter.WriteResourceEnd();
    (void)fclose(fd);
}
开发者ID:astaykov,项目名称:ohNet,代码行数:56,代码来源:TestDvTestBasic.cpp

示例9: readerResponse

void XmlFetch::Read()
{
    iDechunker.ReadFlush();
    ReaderHttpResponse readerResponse(iCpStack.Env(), iReaderUntil);
    HttpHeaderContentLength headerContentLength;
    HttpHeaderTransferEncoding headerTransferEncoding;

    readerResponse.AddHeader(headerContentLength);
    readerResponse.AddHeader(headerTransferEncoding);
    readerResponse.Read(kResponseTimeoutMs);
    const HttpStatus& status = readerResponse.Status();
    if (status != HttpStatus::kOk) {
        LOG2(kXmlFetch, kError, "XmlFetch::Read, http error %u ", status.Code());
        LOG2(kXmlFetch, kError, status.Reason());
        LOG2(kXmlFetch, kError, "\n");
        SetError(Error::eHttp, status.Code(), status.Reason());
        THROW(HttpError);
    }
    if (iCheckContactable) {
        iContactable = true;
        return;
    }

    WriterBwh writer(1024);
    static const TUint kMaxReadBytes = 4 * 1024;
    if (headerTransferEncoding.IsChunked()) {
        iDechunker.SetChunked(true);
        for (;;) {
            Brn buf = iDechunker.Read(kMaxReadBytes);
            writer.Write(buf);
            if (buf.Bytes() == 0) { // end of stream
                break;
            }
        }
    }
    else {
        TUint remaining = headerContentLength.ContentLength();
        if (remaining == 0) { // no content length - read until connection closed by server
            try {
                for (;;) {
                    writer.Write(iReaderUntil.Read(kMaxReadBytes));
                }
            }
            catch (ReaderError&) {
            }
        }
        else {
            do {
                Brn buf = iReaderUntil.Read(kMaxReadBytes);
                remaining -= buf.Bytes();
                writer.Write(buf);
            } while (remaining > 0);
        }
    }
    writer.TransferTo(iXml);
}
开发者ID:DoomHammer,项目名称:ohNet,代码行数:56,代码来源:XmlFetcher.cpp

示例10: prefix

void DviProtocolUpnpServiceXmlWriter::GetRelatedVariableName(Bwh& aName, const Brx& aActionName, const Brx& aParameterName)
{
    static const Brn prefix("A_ARG_TYPE_");
    const TUint len = prefix.Bytes() + aActionName.Bytes() + 1 + aParameterName.Bytes();
    aName.Grow(len);
    aName.Append(prefix);
    aName.Append(aActionName);
    aName.Append('_');
    aName.Append(aParameterName);
}
开发者ID:Jacik,项目名称:ohNet,代码行数:10,代码来源:DviProtocolUpnp.cpp

示例11: ASSERT

void ReaderBinary::ReadReplace(TUint aBytes, Bwx& aBuffer)
{
    ASSERT(aBytes <= aBuffer.MaxBytes());
    aBuffer.SetBytes(0);
    while (aBytes > 0) {
        Brn buf = iReader.Read(aBytes);
        aBuffer.Append(buf);
        aBytes -= buf.Bytes();
    }
}
开发者ID:Montellese,项目名称:ohNet,代码行数:10,代码来源:Stream.cpp

示例12: InvocationReadBinary

void DviSessionLpec::InvocationReadBinary(const TChar* /*aName*/, Brh& aData)
{
    (void)iParser.Next(Lpec::kArgumentDelimiter);
    Brn val = iParser.NextNoTrim(Lpec::kArgumentDelimiter);
    if (val.Bytes() != 0) {
        Bwh writable(val.Bytes()+1);
        writable.Append(val);
        Converter::FromBase64(writable);
        writable.TransferTo(aData);
    }
}
开发者ID:Montellese,项目名称:ohNet,代码行数:11,代码来源:DviServerLpec.cpp

示例13: SetReceived

void WsHeaderKey80::Process(const Brx& aValue)
{
    SetReceived();
    Brn suffix("258EAFA5-E914-47DA-95CA-C5AB0DC85B11");
    Brn val = Ascii::Trim(aValue);
    Bwh buf(val.Bytes() + suffix.Bytes() + 1);
    buf.Append(val);
    buf.Append(suffix);
    buf.PtrZ();
    buf.TransferTo(iKey);
}
开发者ID:astaykov,项目名称:ohNet,代码行数:11,代码来源:DviServerWebSocket.cpp

示例14: InvocationReadString

void DviSessionLpec::InvocationReadString(const TChar* /*aName*/, Brhz& aString)
{
    (void)iParser.Next(Lpec::kArgumentDelimiter);
    Brn val = iParser.NextNoTrim(Lpec::kArgumentDelimiter);
    Bwh writable(val.Bytes()+1);
    if (val.Bytes()) {
        writable.Append(val);
        Converter::FromXmlEscaped(writable);
    }
    writable.PtrZ();
    writable.TransferTo(aString);
}
开发者ID:Montellese,项目名称:ohNet,代码行数:12,代码来源:DviServerLpec.cpp

示例15: MakeFunctor

void CpTopology2Product::EventProductInitialEvent()
{
    Functor functorRoom = MakeFunctor(*this, &CpTopology2Product::EventProductRoomChanged);
    Functor functorName = MakeFunctor(*this, &CpTopology2Product::EventProductNameChanged);
    Functor functorStandby = MakeFunctor(*this, &CpTopology2Product::EventProductStandbyChanged);
    Functor functorSourceIndex = MakeFunctor(*this, &CpTopology2Product::EventProductSourceIndexChanged);
    Functor functorSourceXml = MakeFunctor(*this, &CpTopology2Product::EventProductSourceXmlChanged);

    iServiceProduct->SetPropertyProductRoomChanged(functorRoom);    
    iServiceProduct->SetPropertyProductNameChanged(functorName);    
    iServiceProduct->SetPropertyStandbyChanged(functorStandby); 
    iServiceProduct->SetPropertySourceIndexChanged(functorSourceIndex); 
    iServiceProduct->SetPropertySourceXmlChanged(functorSourceXml);
      
    TBool hasVolumeControl = false;

    Brhz attributes;

    iServiceProduct->PropertyAttributes(attributes);

    Parser parser(attributes);
    
    for (;;) {
        Brn attribute = parser.Next();
        
        if (attribute.Bytes() == 0) {
            break;
        }
        
        if (attribute == Brn("Volume")) {
            hasVolumeControl = true;
            break;
        }
    }
    
    Brhz room;
    Brhz name;
    TUint sourceIndex;
    TBool standby;
    Brhz xml;
    
    iServiceProduct->PropertyProductRoom(room);
    iServiceProduct->PropertyProductName(name);
    iServiceProduct->PropertySourceIndex(sourceIndex);
    iServiceProduct->PropertyStandby(standby);
    iServiceProduct->PropertySourceXml(xml);
    
    iGroup = new CpTopology2Group(iDevice, *this, standby, room, name, sourceIndex, hasVolumeControl);
    
    ProcessSourceXml(xml, true);
    
    iHandler.GroupAdded(*iGroup);
}
开发者ID:fuzzy01,项目名称:ohTopology,代码行数:53,代码来源:CpTopology2.cpp


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