本文整理汇总了C++中TPtrC8::Locate方法的典型用法代码示例。如果您正苦于以下问题:C++ TPtrC8::Locate方法的具体用法?C++ TPtrC8::Locate怎么用?C++ TPtrC8::Locate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TPtrC8
的用法示例。
在下文中一共展示了TPtrC8::Locate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DecodeGenericNumberL
void CUPnPHeaderReader::DecodeGenericNumberL(RHeaderField& aHeader) const
{
TPtrC8 buffer;
aHeader.RawDataL(buffer);
TInt number = KErrNotFound;
TInt decimalPos = buffer.Locate('.');
if(decimalPos == 0)
{
// first character is decimal. So, set the value as zero.
SetNewIntegerPartL(aHeader, 0, 0);
}
else
{
// Search for '\n' separator. In the case when a duplicate header has been received,
// only use the fist instance of the valid data.
TInt newLinePos = buffer.Locate('\n');
if (newLinePos != KErrNotFound)
{
buffer.Set(buffer.Left(newLinePos));
}
TInt value = KErrNotFound;
TInt ret = InetProtTextUtils::ConvertDescriptorToInt(buffer, value);
if ( ret > KErrNone )
{
// Extract an integer. Do not permit terminators other than WS or EOL.
InetProtTextUtils::ExtractIntegerValueL(buffer, number, EFalse);
}
SetNewIntegerPartL(aHeader, 0, number); // part 0, i.e. the first (and only) part
}
}
示例2: DecodeTimeoutHeaderL
void CUPnPHeaderReader::DecodeTimeoutHeaderL(RHeaderField& aHeader) const
{
TPtrC8 buffer;
aHeader.RawDataL(buffer);
// Search for '\n' separator. In the case when a duplicate header has been received,
// only use the fist instance of the valid data.
TInt newLinePos = buffer.Locate('\n');
if (newLinePos != KErrNotFound)
{
buffer.Set(buffer.Left(newLinePos));
}
RStringF infinite = iStringPool.StringF(UPnP::EInfinite, TUPnPTable::Table());
if(buffer.Compare(infinite.DesC()) == 0)
{
SetNewIntegerPartL(aHeader, 0, -(KMaxTInt));
}
else
{
TPtrC8 token;
InetProtTextUtils::ExtractNextTokenFromList(buffer, token, KSemiSpaceSep);
TInt consumed = token.Locate('-');
token.Set(token.Mid(consumed+1));
TInt intVal;
InetProtTextUtils::ConvertDescriptorToInt(token, intVal);
SetNewIntegerPartL(aHeader, 0, intVal); // part 0, i.e. the first (and only) part
}
}
示例3: DoRecognizeL
void CApaDRMRecognizer::DoRecognizeL( const TDesC& aName, const TDesC8& aBuffer )
{
if ( aBuffer.Size() < 3)
{
return;
}
#ifdef RECOGNIZE_KEY_CHAIN
// Recognize device key chain
if ( aName.Length() > 3 && aName.Right(4).CompareF(_L(".dkc")) == 0)
{
iConfidence = ECertain;
iDataType = TDataType( _L8("application/x-device-key-chain") );
return;
}
#endif
#ifdef DRM_OMA2_ENABLED
// Recognize ROAP Trigger
if ( RecognizeRoapTrigger( aBuffer ) )
{
return;
}
// Recognize DCFv2
if ( RecognizeODF( aBuffer ) )
{
return;
}
#endif
// Recognize DCFv1
TUint8 version = aBuffer[0];
TUint8 contentTypeLen = aBuffer[1];
TUint8 contentURILen = aBuffer[2];
if ( contentTypeLen < KMinContentTypeLen || contentURILen == 0 )
{
return;
}
if ( version != KDCFVersionSupported )
{
return;
}
// Too little data received
if ( aBuffer.Size() < ( contentTypeLen + KDCFHeaderLength ) )
{
return;
}
TPtrC8 mimeType = aBuffer.Mid( KDCFHeaderLength, contentTypeLen );
if ( mimeType.Locate( '/' ) != KErrNotFound )
{
iConfidence = ECertain;
iDataType=TDataType( mimeType );
}
return;
}
示例4: DecodeCallbackL
void CUPnPHeaderReader::DecodeCallbackL(RHeaderField& aHeader) const
{
//Callback: <token1><token2><token3>...<tokenN>
TPtrC8 rawData;
aHeader.RawDataL(rawData);
TInt remaining = rawData.Length();
TPtrC8 token;
TInt tokensFound = 0;
TInt consumed;
while (remaining)
{
// Locate and remove the '<' character from the token
consumed = rawData.Locate(KOpenAngleBracket);
if(consumed == KErrNotFound)
{
// No more tokens.
break;
}
// '<' character has now been removed.
rawData.Set(rawData.Mid(consumed+1));
// Now extract the value before '>' character.
// This will be the actual value of the token.
remaining -= InetProtTextUtils::ExtractNextTokenFromList(rawData, token, KCloseAngleBracket);
// No parameters. Just store the field value
InetProtTextUtils::RemoveWhiteSpace(token, InetProtTextUtils::ERemoveBoth);
SetNewFStringPartL(aHeader, tokensFound, token);
++tokensFound;
}
}
示例5: IsValidQuery
/**
Checks that a Query/Header is in a valid form as specified in RFC 3261.
@return A boolean value of ETrue if uri contains valid Query/Header,
EFalse if it does not.
*/
TBool TValidatorSip::IsValidQuery() const
{
const TDesC8& headers = iUri.Extract(EUriQuery);
if (IsEmpty(headers))
{
return EFalse;
}
TDelimitedQueryParser8 parser;
parser.Parse(headers);
TPtrC8 name;
TPtrC8 value;
TPtrC8 segment;
while( parser.GetNext(segment) == KErrNone )
{
// must be in the form name=value even if the value part is empty
if (segment.Locate(KEqualsSeparator) == KErrNotFound)
{
return EFalse;
}
GetNameValuePair(segment, name, value);
if (IsDuplicated(name, parser) || !IsValidHeaderSegment(name, value))
{
return EFalse;
}
}
return ETrue;
}
示例6:
/**
Parses the descriptor aUri into uri components.
@param aUri A reference to a descriptor pointer of an Uri.
@param aScheme A reference to a descriptor pointer for retieved
scheme component.
*/
void TUriParser8::RetrieveScheme(const TPtrC8& aUri, TPtrC8& aScheme)
{
TInt schemePos = aUri.Locate(KSchemeDelimiter);
if(schemePos != KErrNotFound)
{
// Got a scheme - store information
aScheme.Set(aUri.Left(schemePos));
}
}
示例7: CountSeparators
TInt CExampleCookieManager::CountSeparators(const TDesC8& aDes)
{
const TChar pathSeparator('/');
TInt numSeps = 0;
// Get all the descriptor to start with
TPtrC8 desPtr = aDes.Mid(0);
TInt sepPos = desPtr.Locate(pathSeparator);
while(sepPos != KErrNotFound)
{
++numSeps;
// Get the rest of the descriptor without the separator that we have found
desPtr.Set(desPtr.Mid(sepPos + 1));
sepPos = desPtr.Locate(pathSeparator);
}
return numSeps;
}
示例8: SetListL
void RElementIdArray::SetListL( const TDesC8& aChilds)
{
TInt index = 0;
TPtrC8 ptr = aChilds;
while ( 0 <= ( index = ptr.Locate( KMessageDelimiterChar)))
{
AppendL( ptr.Left( index).AllocL());
ptr.Set( ptr.Mid(index + 1));
}
}
示例9: IsTokenTextPair
// -----------------------------------------------------------------------------
// SdpUtil::IsTokenTextPair
// Checks if aValue is valid pair ("valid token":"valid byte-string")
// -----------------------------------------------------------------------------
//
TBool SdpUtil::IsTokenTextPair(
const TDesC8& aValue,
TInt aStart,
TInt aEnd )
{
// token ":" text
TBool result = EFalse;
if ( aStart >= 0 && aEnd <= aValue.Length() && aStart < aEnd )
{
TPtrC8 subVal = aValue.Mid( aStart, aEnd - aStart );
TInt colonPos = subVal.Locate( KColonChar );
result = colonPos != KErrNone &&
IsToken( subVal, 0, colonPos ) &&
IsByteString( subVal, colonPos + 1, subVal.Length() );
}
return result;
}
示例10: DecodeGenericUpnpHeadersL
void CUPnPHeaderReader::DecodeGenericUpnpHeadersL(RHeaderField& aHeader) const
{
TPtrC8 buffer;
aHeader.RawDataL(buffer);
// Search for '\n' separator. In the case when a duplicate header has been received,
// only use the fist instance of the valid data.
TInt newLinePos = buffer.Locate('\n');
if (newLinePos != KErrNotFound)
{
buffer.Set(buffer.Left(newLinePos));
}
TPtrC8 token;
InetProtTextUtils::ExtractNextTokenFromList(buffer, token, KSemiSpaceSep);
SetNewFStringPartL(aHeader, 0, token); // part 0, i.e. the first (and only) part
}
示例11: ToSIPExtensionHeadersL
// -----------------------------------------------------------------------------
// MceSip::ToSIPExtensionHeadersL
// -----------------------------------------------------------------------------
//
void MceSip::ToSIPExtensionHeadersL( RPointerArray<CSIPHeaderBase>& aSIPHeaders,
const MDesC8Array& aHeaders )
{
for ( int i = 0; i < aHeaders.MdcaCount(); i++ )
{
TPtrC8 param = aHeaders.MdcaPoint( i );
TInt index = param.Locate( KMceSipSeparator );
if ( index != KErrNotFound &&
param.Left( index ) != KMceSipSubscriptionStateHeader )
{
CSIPExtensionHeader* extHeader = CSIPExtensionHeader::NewL(
param.Left(index),
param.Right( param.Length() - ( index + 1 ) ) );
CleanupStack::PushL( extHeader );
User::LeaveIfError( aSIPHeaders.Append( extHeader ) );
CleanupStack::Pop( extHeader );
}
}
}
示例12: ParseLicenseL
// ---------------------------------------------------------
// CDdEng::ParseLicenseL()
// ---------------------------------------------------------
//
void CDdEng::ParseLicenseL()
{
HBufC8* descriptorBuf = CodUtil::ConvertLC( iCodBuf->Des());
TPtrC8 license;
TPtrC8 descriptor (descriptorBuf->Ptr());
TInt startTag = descriptor.Find(KLicenseStartTag); // "<license"
if (startTag != KErrNotFound)
{
descriptor.Set(descriptor.Right(descriptor.Length()- startTag -1));
TInt endTag = descriptor.Locate(KElementEnd); //'>'
if (endTag != KErrNotFound)
{
license.Set(descriptor.Right(descriptor.Length()-endTag-1));
TInt licenseTagEnd = license.Find(KLicenseEndTag); // "</license"
if (licenseTagEnd != KErrNotFound)
{
license.Set(license.Left(licenseTagEnd));
}
}
}
iSaver->AppendData( license );
CleanupStack::PopAndDestroy( descriptorBuf );
}
示例13: ValidateCookieL
TBool CExampleCookieManager::ValidateCookieL(CCookie& aCookie, const TUriC8& aUri)
{
THTTPHdrVal attributeVal;
if(aCookie.Attribute(CCookie::EPath, attributeVal) == KErrNone)
{
// if the path attribute exists check it is a prefix of the path
// of the uri that issued it (if not reject)
RStringF cookiePath = attributeVal.StrF();
const TDesC8& uriPath = aUri.Extract(EUriPath);
if(uriPath.FindF(RemoveQuotes(cookiePath.DesC())) != 0)
return EFalse;
}
else
{
// if the path attribute doesn't exist add it
THTTPHdrVal val(iStringPool.OpenFStringL(aUri.Extract(EUriPath)));
aCookie.SetAttributeL(CCookie::EPath, val);
}
if(aCookie.Attribute(CCookie::EDomain, attributeVal) == KErrNone)
{
const TChar dot('.');
const TDesC8& cookieDomain = attributeVal.StrF().DesC();
const TDesC8& uriDomain = aUri.Extract(EUriHost);
// if the domain does not exactly match the uri and does not begin
// with a dot then add one
if((cookieDomain.Compare(uriDomain) != 0) &&
(cookieDomain.Locate(dot) != 0))
{
_LIT8(KAddDotString, ".%S");
HBufC8* newDomain = HBufC8::NewLC(cookieDomain.Length() + 1);
newDomain->Des().AppendFormat(KAddDotString(), &cookieDomain);
RStringF domain = iStringPool.OpenFStringL(*newDomain);
CleanupStack::PopAndDestroy(newDomain);
THTTPHdrVal val(domain);
aCookie.SetAttributeL(CCookie::EDomain, val);
domain.Close();
}
// if the domain does not contain an embedded dot then reject it
// ie reject .com or .com.
// Start by removing one character from each end. ie start at pos 1 and take a length
// which is 2 shorter than the original descriptor
TPtrC8 domainMiddle = cookieDomain.Mid(1, cookieDomain.Length() - 2);
if(domainMiddle.Locate(dot) == KErrNotFound)
return EFalse;
// Reject the cookie if the domain differs by two or more levels from the uri
// ie if uri=www.x.y.com then accept a cookie with .x.y.com but reject .y.com
TInt pos = uriDomain.FindF(cookieDomain);
if(pos > 2)
{
const TDesC8& domainDiff = uriDomain.Left(pos);
// Remove one character from each end. ie start at pos 1 and take a length
// which is 2 shorter than the original descriptor
const TDesC8& diffMiddle = domainDiff.Mid(1, domainDiff.Length() - 2);
if(diffMiddle.Locate(dot) != KErrNotFound)
return EFalse;
}
}
else
{
// if the domain attribute is not found add it
THTTPHdrVal val(iStringPool.OpenFStringL(aUri.Extract(EUriHost)));
aCookie.SetAttributeL(CCookie::EDomain, val);
val.StrF().Close();
}
if(!CheckPortMatch(aCookie, aUri))
return EFalse;
return ETrue;
}
示例14: urlP
SYSCALL(MAHandle, maConnect(const char* url)) {
TPtrC8 urlP(CBP url, SYSCALL_THIS->ValidatedStrLen(url));
LOGST("Connect %i %s", gConnNextHandle, url);
if(gConnections.size() >= CONN_MAX)
return CONNERR_MAX;
_LIT8(KLocalhost, "localhost");
CConnection* conn = NULL;
TPtrC8 match;
SocketType socketType = TCP; // initialized to placate stupid compiler
ConnectionType type;
// determine type of connection
if(SSTREQ(urlP, KSocket)) {
match.Set(KSocket);
type = eSocket;
socketType = TCP;
} else if(SSTREQ(urlP, KDatagram)) {
match.Set(KDatagram);
type = eSocket;
socketType = UDP;
} else if(SSTREQ(urlP, KSsl)) {
match.Set(KSsl);
type = eSocket;
socketType = SSL;
} else if(SSTREQ(urlP, KHttp)) {
match.Set(KHttp);
type = eHttp;
socketType = TCP;
} else if(SSTREQ(urlP, KHttps)) {
match.Set(KHttps);
type = eHttp;
socketType = SSL;
} else if(SSTREQ(urlP, KBtspp)) {
match.Set(KBtspp);
type = eBtspp;
} else { //error
return CONNERR_URL;
}
TPtrC8 parturl = urlP.Mid(match.Length());
if(type == eSocket) {
TPtrC8 hostnamePtrC8;
int port;
if(!splitPurl(parturl, hostnamePtrC8, port, (1<<16))) {
return CONNERR_URL;
}
Smartie<CSocket> sockp(createSocket(socketType));
_LIT8(K127, "127.");
TInetAddr addr;
bool localhost = false;
if(hostnamePtrC8 == KLocalhost) {
localhost = true;
addr.SetAddress(INET_ADDR(127,0,0,1));
} else if(hostnamePtrC8.Length() > K127().Length()) {
if(hostnamePtrC8.Left(K127().Length()) == K127) {
localhost = true;
Smartie<HBufC16> hostname(CreateHBufC16FromDesC8LC(hostnamePtrC8));
addr.Input(*hostname());
}
}
sockp->state |= CONNOP_CONNECT;
if(localhost) {
StartConnOpL(CO_AddrConnect::NewL(false, *this, gConnNextHandle, *sockp(),
addr, port, *sockp()));
} else {
Smartie<HBufC16> hostname(CreateHBufC16FromDesC8LC(hostnamePtrC8));
CleanupStack::Pop(hostname());
StartConnOpL(CO_NameConnect::NewL(gNetworkingState != EStarted,
*this, gConnNextHandle, *sockp(), hostname, port, *sockp()));
}
conn = sockp.extract();
} else if(type == eHttp) {
CHttpConnection* http;
TLTZ_PASS(httpCreateConnectionLC(parturl, http, HTTP_GET, socketType));
http->state |= CONNOP_CONNECT;
StartConnOpL(CO_HttpFinish::NewL(gNetworkingState != EStarted,
*this, gConnNextHandle, *http, *http, true));
http->mState = CHttpConnection::WRITING;
conn = http;
CleanupStack::Pop(conn);
} else if(type == eBtspp) {
if(gBtState != eAvailable) {
return CONNERR_UNAVAILABLE;
}
TPtrC8 hostnamePtrC8;
int port_m1_index = parturl.Locate(':');
if(port_m1_index == KErrNotFound) {
return false;
}
hostnamePtrC8.Set(parturl.Left(port_m1_index));
if(hostnamePtrC8 == KLocalhost) { // server
// extract and parse uuid
static const int KUuidLength = 32;
int uuidStartIndex = port_m1_index + 1;
int paramStartIndex = uuidStartIndex + KUuidLength;
if(parturl.Length() < paramStartIndex) {
return CONNERR_URL;
}
//.........这里部分代码省略.........
示例15: DecodeWWWAuthenticateL
// Convert the WWW-Authenticate header field from OTA to generic form.
void CHttpClientHeaderReader::DecodeWWWAuthenticateL( RHeaderField& aHeader ) const
{
// RFC2616, section 14.47 WWW-Authenticate
// RFC2617, 'HTTP Authentication: Basic and Digest Access Authentication'
//
// WWW-Authenticate = "WWW-Authenticate" ":" 1#challenge
// challenge = auth-scheme 1*SP 1#auth-param
// auth-scheme = token
// auth-param = token "=" ( token | quoted-string )
// There may be one or more challenge, in a comma-separated list.
TPtrC8 buffer;
aHeader.RawDataL( buffer );
TInt totalBytesConsumed = 0;
TInt numChallenges = 0;
CHeaderFieldPart* part = NULL;
TBool done = EFalse;
while ( !done )
{
_LIT8( commaSpaceNewline, ", \n" );
TPtrC8 token;
TInt bytesConsumed = InetProtTextUtils::ExtractNextTokenFromList( buffer, token, commaSpaceNewline );
done = (bytesConsumed == 0);
if ( done && ( numChallenges == 0 ) ) // if we didn't find _anything_ at all...
{
User::Leave( KErrHttpDecodeWWWAuthenticate );
}
if ( !done && ( token.Length() > 0 ) )
{
totalBytesConsumed += bytesConsumed;
TBool equalsPresent = ( token.Locate( '=' ) != KErrNotFound );
if ( ( totalBytesConsumed == bytesConsumed ) && equalsPresent )
{
// The first token has an equals sign in it. That
// can't be as it has to be an authentication scheme
User::Leave( KErrHttpDecodeWWWAuthenticate );
}
if ( !equalsPresent )
{
// Got a new part. Add it.
++numChallenges;
part = SetNewFStringPartL( aHeader, numChallenges - 1, token );
if( token.Compare( iStrPool.StringF(HTTP::ENTLM, iStringTable).DesC() ) == 0 )
{
TInt consumed = InetProtTextUtils::ExtractNextTokenFromList( buffer, token, commaSpaceNewline );
if( consumed > 0 )
{
++numChallenges;
part = SetNewFStringPartL( aHeader, numChallenges -1, token );
}
}
}
else
{
// Got a param & parameter value.
TPtrC8 paramName;
TInt paramBytesConsumed = InetProtTextUtils::ExtractNextTokenFromList( token, paramName, '=' );
if ( paramBytesConsumed == 0 )
{
User::Leave( KErrHttpDecodeBasicAuth );
}
// Obtain the parameter value. It is a string which
// may or may not be quoted.
TPtrC8 paramVal;
if ( token.Length() > 0 && token[0] == '"' )
{
bytesConsumed += InetProtTextUtils::ExtractQuotedStringL( token, paramVal );
}
else
{
paramVal.Set( token );
}
SetNewStringParamL( *part, paramName, paramVal );
}
}
}
}