本文整理汇总了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();
}
示例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);
}
示例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;
}
}
}
}
示例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;
}
}
}
示例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));
}
示例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;
}
}
}
}
}
示例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);
}
}
示例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);
}
示例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);
}
示例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);
}
示例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();
}
}
示例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);
}
}
示例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);
}
示例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);
}
示例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);
}