本文整理汇总了C++中Brn::Set方法的典型用法代码示例。如果您正苦于以下问题:C++ Brn::Set方法的具体用法?C++ Brn::Set怎么用?C++ Brn::Set使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Brn
的用法示例。
在下文中一共展示了Brn::Set方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Process
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);
}
}
示例2: Element
Brn XmlParserBasic::Element(const Brx& aTag, const Brx& aDocument, Brn& aRemaining)
{
EParserState state = eSearchOpen;
TInt ignoreClose = 0;
Brn namesp;
Brn name;
Brn attributes;
Brn ns;
TUint index;
TUint startIndex = 0;
Brn docTrimmed(Ascii::Trim(aDocument));
Brn doc(docTrimmed);
Brn remaining(docTrimmed);
Brn retStart;
ETagType tagType;
for (;;) {
NextTag(doc, name, attributes, ns, index, remaining, tagType);
if (Ascii::CaseInsensitiveEquals(name, aTag)) {
if (state == eSearchOpen) {
if (tagType == eTagClose) {
if (--ignoreClose < 0)
THROW(XmlError);
}
else if (tagType == eTagOpenClose) {
return Brn(Brx::Empty());
}
namesp.Set(ns);
retStart.Set(remaining);
state = eSearchClose;
}
else { // eSearchClose
if (tagType == eTagOpen) {
++ignoreClose;
}
else if (tagType == eTagClose) {
if (ignoreClose == 0) {
if (namesp != ns) {
THROW(XmlError);
}
aRemaining.Set(remaining);
const TUint retBytes = (TUint)(aRemaining.Ptr() - docTrimmed.Ptr()) - startIndex;
Brn ret(docTrimmed.Split(startIndex, retBytes));
return ret;
}
ignoreClose--;
}
}
}
if (remaining.Bytes() == 0) {
THROW(XmlError);
}
if (state != eSearchClose)
{
startIndex += (TUint)(remaining.Ptr()-doc.Ptr());
}
doc.Set(remaining);
}
}
示例3: WriteResource
void DviProtocolUpnp::WriteResource(const Brx& aUriTail, TIpAddress aAdapter, std::vector<char*>& aLanguageList, IResourceWriter& aResourceWriter)
{
if (aUriTail == kDeviceXmlName) {
Brh xml;
Brn xmlBuf;
AutoMutex _(iLock);
const TInt index = FindListenerForInterface(aAdapter);
if (index == -1) {
return;
}
if (iDevice.IsRoot()) {
const Brx& cachedXml = iAdapters[index]->DeviceXml();
if (cachedXml.Bytes() > 0) {
xmlBuf.Set(cachedXml);
}
}
if (xmlBuf.Bytes() == 0) {
GetDeviceXml(xml, aAdapter);
if (iDevice.IsRoot()) {
iAdapters[index]->SetDeviceXml(xml);
xmlBuf.Set(iAdapters[index]->DeviceXml());
}
else {
xmlBuf.Set(xml);
}
}
aResourceWriter.WriteResourceBegin(xmlBuf.Bytes(), kOhNetMimeTypeXml);
aResourceWriter.WriteResource(xmlBuf.Ptr(), xmlBuf.Bytes());
aResourceWriter.WriteResourceEnd();
}
else {
Parser parser(aUriTail);
Brn buf = parser.Next('/');
Brn rem = parser.Remaining();
if (buf == DviDevice::kResourceDir) {
IResourceManager* resMgr = iDevice.ResourceManager();
if (resMgr != NULL) {
resMgr->WriteResource(rem, aAdapter, aLanguageList, aResourceWriter);
}
}
else if (rem == kServiceXmlName) {
iLock.Wait();
DviService* service = 0;
const TUint count = iDevice.ServiceCount();
for (TUint i=0; i<count; i++) {
DviService& s = iDevice.Service(i);
if (s.ServiceType().PathUpnp() == buf) {
service = &s;
break;
}
}
iLock.Signal();
if (service == 0) {
THROW(ReaderError);
}
DviProtocolUpnpServiceXmlWriter::Write(*service, *this, aResourceWriter);
}
}
}
示例4: WriteResource
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);
}
示例5: ReadLine
Brn ReaderText::ReadLine()
{
Brn line;
try {
line.Set(Ascii::Trim(ReadUntil(Ascii::kLf)));
}
catch (ReaderError&) {
// treat any content following the last newline as a final line
line.Set(Read(iMaxBytes));
if (line.Bytes() == 0) {
throw;
}
}
return line;
}
示例6: Process
void HeaderAcceptLanguage::Process(const Brx& aValue)
{
SetReceived();
ClearLanguageList();
iLanguages.Set(aValue);
std::vector<PrioritisedLanguage> prioritisedList;
Parser parser(iLanguages);
while (parser.Remaining().Bytes() > 0) {
Brn langBuf = parser.Next(',');
Parser parser2(langBuf);
Brn lang = parser2.Next(';');
parser2.Set(parser2.Remaining());
Brn qualityBuf = parser2.Next('=');
if (qualityBuf.Bytes() > 0) {
qualityBuf.Set(parser2.Remaining());
}
TUint quality = ParseQualityValue(qualityBuf);
PrioritisedLanguage prioritisedLang;
prioritisedLang.iLanguage = (char*)malloc(lang.Bytes()+1);
(void)memcpy(prioritisedLang.iLanguage, lang.Ptr(), lang.Bytes());
prioritisedLang.iLanguage[lang.Bytes()] = '\0';
prioritisedLang.iPriority = quality;
AddPrioritisedLanguage(prioritisedList, prioritisedLang);
}
for (TUint i=0; i<(TUint)prioritisedList.size(); i++) {
iLanguageList.push_back(prioritisedList[i].iLanguage);
}
}
示例7: ParseUrn
TBool Ssdp::ParseUrn(const Brx& aUrn, const Brx& aType, Brn& aDomainName, Brn& aDeviceType, TUint& aVer)
{
Parser parser(aUrn);
aDomainName.Set(parser.NextNoTrim(kUrnSeparator));
if (!aType.Equals(parser.NextNoTrim(kUrnSeparator))) {
return false;
}
aDeviceType.Set(parser.NextNoTrim(kUrnSeparator));
Brn ver = parser.Remaining();
try {
aVer = Ascii::Uint(ver);
}
catch(AsciiError&) {
return false;
}
return true;
}
示例8: RedirectUri
TBool DviServerUpnp::RedirectUri(const Brx& aUri, Brn& aRedirectTo)
{
if (aUri == iRedirectUriRequested) {
aRedirectTo.Set(iRedirectUriRedirectedTo);
return true;
}
return false;
}
示例9: GetServiceUri
void CpiDeviceUpnp::GetServiceUri(Uri& aUri, const TChar* aType, const ServiceType& aServiceType)
{
Brn root = XmlParserBasic::Find("root", iXml);
Brn device = XmlParserBasic::Find("device", root);
Brn udn = XmlParserBasic::Find("UDN", device);
if (!CpiDeviceUpnp::UdnMatches(udn, Udn())) {
Brn deviceList = XmlParserBasic::Find("deviceList", device);
do {
Brn remaining;
device.Set(XmlParserBasic::Find("device", deviceList, remaining));
udn.Set(XmlParserBasic::Find("UDN", device));
deviceList.Set(remaining);
} while (!CpiDeviceUpnp::UdnMatches(udn, Udn()));
}
Brn serviceList = XmlParserBasic::Find("serviceList", device);
Brn service;
Brn serviceType;
Brn devServiceTypeNoVer;
const Brx& targServiceType = aServiceType.FullName();
// Must have backwards compatibility. Need to compare service type and version separately.
Parser serviceParser = targServiceType;
serviceParser.Next(':'); // urn
serviceParser.Next(':'); // schema url
serviceParser.Next(':'); // service
serviceParser.Next(':'); // name
Brn targServiceTypeNoVer(targServiceType.Ptr(), serviceParser.Index()); // full name minus ":x" (where x is version)
do {
Brn remaining;
service.Set(XmlParserBasic::Find("service", serviceList, remaining));
serviceType.Set(XmlParserBasic::Find("serviceType", service));
serviceList.Set(remaining);
// Parse service type and version separately.
serviceParser.Set(serviceType);
serviceParser.Next(':'); // urn
serviceParser.Next(':'); // schema url
serviceParser.Next(':'); // service
serviceParser.Next(':'); // name
devServiceTypeNoVer.Set(serviceType.Ptr(), serviceParser.Index()); // full name minus ":x" (where x is version)
// MUST allow use of device with version >= target version
} while (devServiceTypeNoVer != targServiceTypeNoVer);
Brn path = XmlParserBasic::Find(aType, service);
if (path.Bytes() == 0) {
// no event url => service doesn't have any evented state variables
THROW(XmlError);
}
// now create a uri using the scheme/host/port of the device xml location
// plus the path we've just constructed
Bws<40> base; // just need space for http://xxx.xxx.xxx.xxx:xxxxx
aUri.Replace(iLocation);
base.Append(aUri.Scheme());
base.Append("://");
base.Append(aUri.Host());
base.Append(':');
Ascii::AppendDec(base, aUri.Port());
aUri.Replace(base, path);
}
示例10: Version
TUint CpiDeviceUpnp::Version(const TChar* aDomain, const TChar* aName, TUint /*aProxyVersion*/) const
{
ServiceType serviceType(iDevice->GetCpStack().Env(), aDomain, aName, 0);
const Brx& targServiceType = serviceType.FullName();
// Must have backwards compatibility. Need to compare service type and version separately.
Parser serviceParser = targServiceType;
serviceParser.Next(':'); // urn
serviceParser.Next(':'); // schema url
serviceParser.Next(':'); // service
serviceParser.Next(':'); // name
Brn targServiceTypeNoVer(targServiceType.Ptr(), serviceParser.Index()); // full name minus ":x" (where x is version)
try {
Brn root = XmlParserBasic::Find("root", iXml);
Brn device = XmlParserBasic::Find("device", root);
Brn udn = XmlParserBasic::Find("UDN", device);
if (!CpiDeviceUpnp::UdnMatches(udn, Udn())) {
Brn deviceList = XmlParserBasic::Find("deviceList", device);
do {
Brn remaining;
device.Set(XmlParserBasic::Find("device", deviceList, remaining));
udn.Set(XmlParserBasic::Find("UDN", device));
deviceList.Set(remaining);
} while (!CpiDeviceUpnp::UdnMatches(udn, Udn()));
}
Brn serviceList = XmlParserBasic::Find("serviceList", device);
Brn service;
Brn serviceType;
Brn devServiceTypeNoVer;
for (;;) {
Brn remaining;
service.Set(XmlParserBasic::Find("service", serviceList, remaining));
serviceType.Set(XmlParserBasic::Find("serviceType", service));
serviceList.Set(remaining);
// Parse service type and version separately.
serviceParser.Set(serviceType);
serviceParser.Next(':'); // urn
serviceParser.Next(':'); // schema url
serviceParser.Next(':'); // service
serviceParser.Next(':'); // name
devServiceTypeNoVer.Set(serviceType.Ptr(), serviceParser.Index()); // full name minus ":x" (where x is version)
if (devServiceTypeNoVer == targServiceTypeNoVer) {
Brn devVersionBuf = serviceParser.NextToEnd(); // version
try {
return Ascii::Uint(devVersionBuf);
}
catch (AsciiError&) {
THROW(XmlError);
}
}
}
}
catch (XmlError&) {
return 0;
}
}
示例11: 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));
}
示例12: GetAttribute
TBool CpiDeviceUpnp::GetAttribute(const char* aKey, Brh& aValue) const
{
Brn key(aKey);
Parser parser(key);
if (parser.Next('.') == Brn("Upnp")) {
Brn property = parser.Remaining();
if (property == Brn("Location")) {
aValue.Set(iLocation);
return (true);
}
if (property == Brn("DeviceXml")) {
aValue.Set(iXml);
return (true);
}
const DeviceXml* device = iDeviceXml;
if (parser.Next('.') == Brn("Root")) {
device = &iDeviceXmlDocument->Root();
property.Set(parser.Remaining());
}
try {
if (property == Brn("FriendlyName")) {
device->GetFriendlyName(aValue);
return (true);
}
if (property == Brn("PresentationUrl")) {
device->GetPresentationUrl(aValue);
return (true);
}
Parser parser(property);
Brn token = parser.Next('.');
if (token == Brn("Service")) {
aValue.Set(device->ServiceVersion(parser.Remaining()));
return (true);
}
}
catch (XmlError&) {
}
}
return (false);
}
示例13: Read
void ReaderHttpRequest::Read(TUint aTimeoutMs)
{
TUint count = 0;
iMethod = 0;
ResetHeaders();
for (;;) {
Brn line;
{
Timer timer(MakeFunctor(*this, &ReaderHttpRequest::ReadTimeout));
if (aTimeoutMs > 0) {
timer.FireIn(aTimeoutMs);
}
line.Set(Ascii::Trim(iReader.ReadUntil(Ascii::kLf)));
timer.Cancel();
}
// LOG(kHttp, "HTTP Read Request ");
// LOG(kHttp, line);
// LOG(kHttp, "\n");
TUint bytes = line.Bytes();
if (!bytes) {
if (count == 0) {
continue; // a blank line before first header - ignore (RFC 2616 section 4.1)
}
if (iMethod == 0) {
THROW(HttpError);
}
return;
}
if (Ascii::IsWhitespace(line[0])) {
continue; // a line starting with spaces is a continuation line
}
Parser parser(line);
if (count == 0) { // method
Brn method = parser.Next();
Brn uri = parser.Next();
Brn version = Ascii::Trim(parser.Remaining());
ProcessMethod(method, uri, version);
}
else { // header
Brn field = parser.Next(':');
Brn value = Ascii::Trim(parser.Remaining());
ProcessHeader(field, value);
}
count++;
}
}
示例14: 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 (;;) {
prop.Set(XmlParserBasic::Find("property", propertySet, remaining));
prop.Set(Ascii::Trim(prop));
if (prop.Bytes() < 8 || prop[0] != '<' || prop[1] == '/') {
THROW(XmlError);
}
Parser parser(prop);
(void)parser.Next('<');
Brn tagName = parser.Next('>');
Brn val = 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);
}
}
catch(XmlError&) {}
aEventProcessor.EventUpdateEnd();
}
示例15: Run
void ShellSession::Run()
{
FunctorMsg logger = MakeFunctorMsg(*this, &OpenHome::Net::ShellSession::Log);
FunctorMsg oldLogger = Log::SwapOutput(logger);
iShutdownSem.Wait();
for (;;) {
try {
Brn buf = iReadBuffer->ReadUntil('\n');
TUint bytes = buf.Bytes();
if (bytes > 0 && buf[bytes - 1] == '\r') { // strip any trailing LF
buf.Set(buf.Ptr(), bytes-1);
}
Parser parser(buf);
Brn command = parser.Next(' ');
if (command == kCmdExit) {
break;
}
std::vector<Brn> args;
for (;;) {
Brn arg = parser.Next(' ');
if (arg.Bytes() == 0) {
break;
}
args.push_back(arg);
}
iCommandHandler.HandleShellCommand(command, args, *iWriterResponse);
}
catch (ReaderError&) {
break;
}
catch (WriterError&) {
break;
}
catch (Exception& e) {
Log::Print("Unexpected exception: %s from %s:%u\n", e.Message(), e.File(), e.Line());
break;
}
}
(void)Log::SwapOutput(oldLogger);
iShutdownSem.Signal();
}