本文整理汇总了C++中HBufC::Locate方法的典型用法代码示例。如果您正苦于以下问题:C++ HBufC::Locate方法的具体用法?C++ HBufC::Locate怎么用?C++ HBufC::Locate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HBufC
的用法示例。
在下文中一共展示了HBufC::Locate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: lexer
void
CConnectionSettings::SetPreferredIAPsL(const TDesC& aPreferredIAPs)
{
if(aPreferredIAPs.Length() > 0) {
if(iPreferredIAPs) {
iPreferredIAPs->Reset();
delete iPreferredIAPs;
}
iPreferredIAPs = new (ELeave) CDesCArrayFlat(2);
TLex lexer(aPreferredIAPs);
while (!lexer.Eos()) {
HBufC *tmp = lexer.NextToken().AllocLC();
TChar ch = '_';
TInt pos = tmp->Locate(ch);
while (pos != KErrNotFound) {
tmp->Des().Replace(pos, 1, _L(" "));
pos = tmp->Locate(ch);
}
iPreferredIAPs->AppendL(*tmp);
CleanupStack::PopAndDestroy(tmp);
}
}
}
示例2: EscapeEncodeL
EXPORT_C HBufC* CUrl::EscapeEncodeL(const TDesC& aString, TInt aEscapeMode)
//
// Encodes any excluded characters in aString as escape triples - excluded characters set by aEscapeMode
{
// Need to create an HBufC with our excluded characters
HBufC* excludedBuf = NULL;
switch (aEscapeMode)
{
case EUrlGenericCompare:
{
// This is normal operation - escape all sets of data other than KReservedData
excludedBuf = HBufC::NewLC(KUnwiseData().Length() + KDelimsData().Length());
TPtr excluded = excludedBuf->Des();
excluded.Append(KUnwiseData);
excluded.Append(KDelimsData);
} break;
case EUrlScheme:
{
// Escaping data in scheme - reserved chars have no special meaning so escape as well.
excludedBuf = HBufC::NewLC(KUnwiseData().Length() + KDelimsData().Length() + KReservedData().Length());
TPtr excluded = excludedBuf->Des();
excluded.Append(KUnwiseData);
excluded.Append(KDelimsData);
excluded.Append(KReservedData);
} break;
case EUrlPath:
{
// Escaping data in a local file path - same as EUrlScheme but don't escape '/' and ':'
excludedBuf = HBufC::NewLC(KUnwiseData().Length() + KDelimsData().Length() + KReservedDataForPath().Length());
TPtr excluded = excludedBuf->Des();
excluded.Append(KUnwiseData);
excluded.Append(KDelimsData);
excluded.Append(KReservedDataForPath);
} break;
default:
// Not supported return NULL
return NULL;
break;
}
// Descriptor to hex digits
const TDesC& HexDigit = KHexDigit;
// Allocate space to build escaped url - consider worse case, where all characters are excluded => length x 3
HBufC* buf = HBufC::NewLC(aString.Length()*3); // CS
TPtr escapedBuf = buf->Des();
for (TInt i=0; i<aString.Length(); ++i)
{
// Check if current character must be escaped, will leave if non 8-bit character
TChar currentChar = aString[i];
if (currentChar > 0xff)
User::Leave(EWapErrCorruptUrl);
// Check if aChar is a member of DelimsData or UnwiseData or a control character
if (excludedBuf->Locate(currentChar)!=KErrNotFound || (currentChar>=0x00 && currentChar<=0x1F) || currentChar==' ' || currentChar > 0x7E )
{
// Escaped character will be 8-bit
escapedBuf.Append('%');
TInt msNibble = (currentChar & 0xf0) >> 4; // Get msNibble by masking against 11110000 and dividing by 16 (>>4)
escapedBuf.Append(HexDigit[msNibble]);
TInt lsNibble = (currentChar & 0x0f); // Get lsNibble by masking against 00001111
escapedBuf.Append(HexDigit[lsNibble]);
}
else
{