本文整理汇总了C++中Brn::Split方法的典型用法代码示例。如果您正苦于以下问题:C++ Brn::Split方法的具体用法?C++ Brn::Split怎么用?C++ Brn::Split使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Brn
的用法示例。
在下文中一共展示了Brn::Split方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Process
void HeaderCallback::Process(const Brx& aValue)
{
SetReceived();
Parser parser(aValue);
parser.Next('<');
Brn uri = parser.Next('>');
TUint bytes = uri.Bytes();
if (bytes < Http::kUriPrefix.Bytes()) {
THROW(HttpError);
}
if (uri.Split(0, Http::kUriPrefix.Bytes()) != Http::kUriPrefix) {
THROW(HttpError);
}
parser.Set(uri.Split(Http::kUriPrefix.Bytes()));
Brn address = parser.Next(':');
Brn port = parser.Next('/');
try {
iEndpoint = OpenHome::Endpoint(Ascii::Uint(port), address);
}
catch (AsciiError) {
THROW(HttpError);
}
Brn remaining = parser.Remaining();
iUri.Grow(remaining.Bytes() + 1);
iUri.Replace(Brn("/"));
iUri.Append(remaining);
}
示例2: Receiver
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();
}
示例3: THROW
void WsProtocol76::Read(Brn& aData, TBool& aClosed)
{
aData.Set(NULL, 0);
aClosed = false;
Brn data = iReadBuffer.ReadUntil(kMsgEnd);
if (data.Bytes() == 1 && data[0] == kFrameCloseStart) {
Brn msg = iReadBuffer.Read(1);
if (msg[0] != kMsgCloseEnd) {
THROW(WebSocketError);
}
LOG(kDvWebSocket, "WS: Received close cmd from browser\n");
Close();
aClosed = true;
return;
}
if (data[0] != kFrameMsgStart) {
LOG2(kDvWebSocket, kError, "WS: Unexpected leading byte - %u\n", data[0]);
THROW(WebSocketError);
}
aData.Set(data.Split(1, data.Bytes()-1));
}
示例4: ProcessNotification
void EventSessionUpnp::ProcessNotification(IEventProcessor& aEventProcessor, const Brx& aEntity)
{
aEventProcessor.EventUpdateStart();
OutputProcessorUpnp outputProcessor;
Brn propertySet = XmlParserBasic::Find("propertyset", aEntity);
Brn prop;
Brn remaining;
try {
for (;;) {
try {
prop.Set(XmlParserBasic::Find("property", propertySet, remaining));
}
catch (XmlError&) {
// we've successfully processed all <property> tags from aEntity
break;
}
prop.Set(Ascii::Trim(prop));
if (prop.Bytes() < 8 || prop[0] != '<' || prop[1] == '/') {
THROW(XmlError);
}
Parser parser(prop);
(void)parser.Next('<');
Brn tagNameFull = parser.Next('>');
Brn tagName = tagNameFull;
TUint bytes = tagNameFull.Bytes();
TUint i;
for (i = 0; i < bytes; i++) {
if (Ascii::IsWhitespace(tagNameFull[i])) {
break;
}
}
if (i < bytes) {
tagName.Set(tagNameFull.Split(0, i));
}
Brn val;
if (bytes > 0 && tagNameFull[bytes-1] == '/') {
// empty element tag
val.Set(Brx::Empty());
if (i == bytes) { // no white space before '/'
tagName.Set(tagName.Split(0, bytes-1));
}
}
else {
val.Set(parser.Next('<'));
Brn closingTag = parser.Next('/');
closingTag.Set(parser.Next('>'));
if (tagName != closingTag) {
THROW(XmlError);
}
}
try {
aEventProcessor.EventUpdate(tagName, val, outputProcessor);
}
catch(AsciiError&) {
THROW(XmlError);
}
propertySet.Set(remaining);
}
aEventProcessor.EventUpdateEnd();
}
catch(XmlError&) {
aEventProcessor.EventUpdateError();
}
}
示例5: NextTag
void XmlParserBasic::NextTag(const Brx& aDocument, Brn& aName, Brn& aAttributes, Brn& aNamespace, TUint& aIndex, Brn& aRemaining, ETagType& aType)
{
aName.Set(Brx::Empty());
aAttributes.Set(Brx::Empty());
aNamespace.Set(Brx::Empty());
aRemaining.Set(Brx::Empty());
Parser parser(aDocument);
for (;;) {
Brn item = parser.Next('>');
TUint bytes = item.Bytes();
if (bytes > 0 && item[0] != '<') {
Parser valueParser(item);
Brn value = valueParser.Next('<');
bytes -= value.Bytes();
item.Set(item.Split(value.Bytes(), bytes));
item.Set(Ascii::Trim(item));
bytes = item.Bytes();
}
if (bytes < 2 || item[0] != '<') {
THROW(XmlError);
}
aIndex = (TUint)(item.Ptr() - aDocument.Ptr());
if (item[1] == '?') {
if (bytes < 3) { // catch special case of <?>
THROW(XmlError);
}
if (item[bytes - 1] == '?') { // processing instruction
continue;
}
THROW(XmlError);
}
aRemaining.Set(parser.Remaining());
TUint start = 1; // skip opening '<'
TUint len = bytes-1;
if (item[1] == '/') {
aType = eTagClose;
start++;
len--;
}
else if (item[bytes-1] == '/') {
aType = eTagOpenClose;
len--;
}
else {
aType = eTagOpen;
}
parser.Set(item.Split(start, len));
aName.Set(parser.NextWhiteSpace());
aAttributes.Set(parser.Remaining());
if (Ascii::Contains(aName, ':')) { // collect the namespace
parser.Set(aName);
aNamespace.Set(parser.Next(':'));
if (!aNamespace.Bytes()) {
THROW(XmlError);
}
aName.Set(parser.Remaining());
}
else {
aNamespace.Set(Brx::Empty());
}
if (!aName.Bytes()) {
THROW(XmlError);
}
return;
}
}