本文整理汇总了C++中TPtrC8::Compare方法的典型用法代码示例。如果您正苦于以下问题:C++ TPtrC8::Compare方法的具体用法?C++ TPtrC8::Compare怎么用?C++ TPtrC8::Compare使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TPtrC8
的用法示例。
在下文中一共展示了TPtrC8::Compare方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: XmppStanzaAcknowledgedL
void CLocationEngine::XmppStanzaAcknowledgedL(const TDesC8& aStanza, const TDesC8& /*aId*/) {
CXmlParser* aXmlParser = CXmlParser::NewLC(aStanza);
TPtrC8 aAttributeType = aXmlParser->GetStringAttribute(_L8("type"));
if(aXmlParser->MoveToElement(_L8("location"))) {
if(aAttributeType.Compare(_L8("result")) == 0) {
// Beacon log result
iPatternQuality = aXmlParser->GetIntAttribute(_L8("cellpatternquality"));
iPlaceId = aXmlParser->GetIntAttribute(_L8("placeid"));
TPtrC8 aAttributeState = aXmlParser->GetStringAttribute(_L8("state"));
if(aAttributeState.Compare(_L8("stationary")) == 0) {
iMotionState = EMotionStationary;
}
else if(aAttributeState.Compare(_L8("restless")) == 0) {
iMotionState = EMotionRestless;
}
else {
iMotionState = EMotionMoving;
}
iEngineObserver->HandleLocationServerResult(iMotionState, iPatternQuality, iPlaceId);
}
}
CleanupStack::PopAndDestroy(); // aXmlParser
}
示例2: ProcessAssertionBranchingL
CSenElement* CPolicyNormalizer::ProcessAssertionBranchingL(CSenElement* aPolicy)
{
RPointerArray<CSenElement>& children = aPolicy->ElementsL();
TInt childCount = children.Count();
if(childCount == 0)
return aPolicy;
TInt i = 0;
while (i < childCount)
{
CSenElement* pChild = children[i];
TPtrC8 childName = pChild->LocalName();
if( childName.Compare(WSPolicy::KWsPolicy) == 0
|| childName.Compare(WSPolicy::KAndCompositeAssertion) == 0
|| childName.Compare(WSPolicy::KXorCompositeAssertion) == 0)
{
ProcessAssertionBranchingL(pChild);
}
else //Assertion
{
DuplicateAssertionBranchL(aPolicy , pChild);
}
i++;
}
return aPolicy;
}
示例3: Match
TBool CExampleResolver::Match(const TDesC8& aImplementationType,
const TDesC8& aMatchType,
TBool aUseWildcards) const
{
TInt matchPos = KErrNotFound;
_LIT8(dataSeparator, "||");
const TInt separatorLength = dataSeparator().Length();
// Look for the section separator marker '||'
TInt separatorPos = aImplementationType.Find(dataSeparator);
if(separatorPos == KErrNotFound)
{
// Match against the whole string
if(aUseWildcards)
matchPos = aImplementationType.Match(aMatchType);
else
matchPos = aImplementationType.Compare(aMatchType);
}
else
{
// Find the first section, up to the separator
TPtrC8 dataSection = aImplementationType.Left(separatorPos);
TPtrC8 remainingData = aImplementationType.Mid(separatorPos + separatorLength);
// Match against each section in turn
while(separatorPos != KErrNotFound)
{
// Search this section
if(aUseWildcards)
matchPos = dataSection.Match(aMatchType);
else
matchPos = dataSection.Compare(aMatchType);
// If we found it then no need to continue, so return
if(matchPos != KErrNotFound)
return ETrue;
// Move on to the next section
separatorPos = remainingData.Find(dataSeparator);
if(separatorPos != KErrNotFound)
{
dataSection.Set(remainingData.Left(separatorPos));
remainingData.Set(remainingData.Mid(separatorPos + separatorLength));
}
else
dataSection.Set(remainingData);
}
// Check the final part
if(aUseWildcards)
matchPos = dataSection.Match(aMatchType);
else
matchPos = dataSection.Compare(aMatchType);
}
return matchPos != KErrNotFound;
}
示例4: DecodeL
// -----------------------------------------------------------------------------
// TSdpTypedTime::DecodeL
// Decodes typed time from TDesC
// -----------------------------------------------------------------------------
//
TSdpTypedTime TSdpTypedTime::DecodeL(const TDesC8& aText)
{
TLex8 typedTimeLex(aText);
TSdpTypedTime typedTime;
User::LeaveIfError(typedTimeLex.Val(typedTime.iValue, EDecimal));
if (typedTimeLex.Peek() != 0)
{
TPtrC8 unitString = typedTimeLex.NextToken();
RStringPool pool = SdpCodecStringPool::StringPoolL();
const TDesC8& timeDays = pool.StringF(
SdpCodecStringConstants::ETimeUnitDays,
SdpCodecStringConstants::Table).DesC();
const TDesC8& timeHours = pool.StringF(
SdpCodecStringConstants::ETimeUnitHours,
SdpCodecStringConstants::Table).DesC();
const TDesC8& timeMinutes = pool.StringF(
SdpCodecStringConstants::ETimeUnitMinutes,
SdpCodecStringConstants::Table).DesC();
const TDesC8& timeSeconds = pool.StringF(
SdpCodecStringConstants::ETimeUnitSeconds,
SdpCodecStringConstants::Table).DesC();
if (unitString.Compare(timeDays) == 0)
{
typedTime.iUnit = ETimeUnitDays;
}
else if (unitString.Compare(timeHours) == 0)
{
typedTime.iUnit = ETimeUnitHours;
}
else if (unitString.Compare(timeMinutes) == 0)
{
typedTime.iUnit = ETimeUnitMinutes;
}
else if (unitString.Compare(timeSeconds) == 0)
{
typedTime.iUnit = ETimeUnitSeconds;
}
else
{
User::Leave(KErrSdpCodecTypedTime);
}
}
else
{
typedTime.iUnit = ETimeUnitNone;
}
return typedTime;
}
示例5: MatchServiceCmd
TBool CAiwResolver::MatchServiceCmd(const TDesC8& aOpaqueData, const TDesC8& aServiceCmd) const
{
_LIT8(dataSeparator, "||");
const TInt separatorLength = dataSeparator().Length();
// Look for the section separator marker '||'
TInt separatorPos = aOpaqueData.Find(dataSeparator);
if (separatorPos == KErrNotFound)
{
if (aServiceCmd.Compare(aOpaqueData) == 0)
{
return ETrue;
}
}
else
{
// Find the first section, up to the separator
TPtrC8 dataSection = aOpaqueData.Left(separatorPos);
TPtrC8 remainingData = aOpaqueData.Mid(separatorPos + separatorLength);
// Match against each section in turn
while (separatorPos != KErrNotFound)
{
if (dataSection.Compare(aServiceCmd) == 0)
{
return ETrue;
}
// Move on to the next section
separatorPos = remainingData.Find(dataSeparator);
if (separatorPos != KErrNotFound)
{
dataSection.Set(remainingData.Left(separatorPos));
remainingData.Set(remainingData.Mid(separatorPos + separatorLength));
}
else
{
dataSection.Set(remainingData);
}
}
if (dataSection.Compare(aServiceCmd) == 0)
{
return ETrue;
}
}
return EFalse;
}
示例6: ProcessXORTermL
CSenElement* CPolicyNormalizer::ProcessXORTermL(CSenElement* aAssertion, CSenElement* aNormalAssertion)
{
CSenElement* pNormChild = AddXorElementL(aNormalAssertion);
RPointerArray<CSenElement>& children = aAssertion->ElementsL();
TInt childCount = children.Count();
TInt i = 0;
while (i < childCount)
{
CSenElement* pChild = children[i];
CSenElement* pNewChild = NULL;
// CSenElement* newChild = NULL;
TPtrC8 childName = pChild->LocalName();
if(childName.Compare(WSPolicy::KAndCompositeAssertion) == 0)
{
//If AND element then take child of AND
// CSenElement* newChild =
ProcessANDTermL(pChild, pNormChild);
}
else if (childName.Compare(WSPolicy::KXorCompositeAssertion) == 0)
{
}
else if(childName.Compare(WSPolicy::KWsPolicy) == 0)
{
pNewChild = AddAndElementL(pNormChild);
if(HasChildL(pChild) > 0)
ProcessPolicyTermL(pChild,pNewChild);
}
else
{
pNewChild = AddAndElementL(pNormChild);
// newChild =
ProcessAssertionTermL(pChild, pNewChild);
//if Assertion then first we haveto add AND and then add Assertion
//(assertion will be done by AND too)
}
i++;
}
return pNormChild;
}
示例7: 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
}
}
示例8: CheckValueExist
//util to check any key within that section holds that value
//if not found simply return the number of keys within that section
TInt CConfigImpl::CheckValueExist(const TDesC8& aSectionName,const TDesC8& aValue,TInt& aKeyCount)
{
CIniSecIter8* iter=NULL;
TRAPD(err,iter=CIniSecIter8::NewL(aSectionName,iIniFileDocument));
//if section not found it might be the first time we are creating
//the document so it is fine to return KErrNone
if (err==KErrNotFound)
{
return KErrNone;
}
//return the error code if else than KErrNotFound e.g. KErrNoMemory;
if (err!=KErrNone)
{
return err;
}
TPtrC8 key;
TPtrC8 value;
TInt keyCount=0;
while (iter->Next(key,value))
{
if (value.Compare(aValue)==0)
{
delete iter;
keyCount=0;
return KErrAlreadyExists;
}
keyCount++;
}
aKeyCount=keyCount;
delete iter;
return KErrNone;
}
示例9: DecodeQuotedPrintableLC
HBufC8* CVBookmarkConverter::DecodeQuotedPrintableLC( const TDesC8& aEncodedData )
{
TInt encodedLength = aEncodedData.Length();
HBufC8* decodeBuffer = HBufC8::NewLC( encodedLength );
TPtr8 ptrDecodeBuffer = decodeBuffer->Des();
TInt i(0);
while ( i < encodedLength )
{
TChar nextChar = aEncodedData[i++];
if ( nextChar == '=' )
{
if ( i + 2 > encodedLength )
{
ptrDecodeBuffer.Append( '=' );
if ( i + 1 == encodedLength )
{
ptrDecodeBuffer.Append( aEncodedData[i++] );
}
}
else
{
TPtrC8 data = aEncodedData.Mid( i, 2 );
i += 2;
if ( data.Compare(KVBMKLinefeed) == 0 )
{
// Do nothing
// '=' at the end of line is soft line break, not to be decoded
}
else
{
TLex8 hexChar( data );
TUint8 value( 0 );
if ( hexChar.Val( value, EHex ) == KErrNone )
{
ptrDecodeBuffer.Append( TChar( value ) );
}
else
{
// Decoding failed, put the data at itself
ptrDecodeBuffer.Append( '=' );
ptrDecodeBuffer.Append( data );
}
}
}
}
else
{
ptrDecodeBuffer.Append( nextChar );
}
}
return decodeBuffer;
}
示例10: DecryptAndVerifyL
TInt CTlsEncrypt::DecryptAndVerifyL(const TDesC8& aInput,HBufC8*& aOutput,
TInt64& aSeqNumber, TRecordProtocol& aType)
{
if(!aInput.Length())
return KErrBadDescriptor;
TLSPROV_LOG2(_L("Before Decryption...RecordType: %d"),(TInt)aType)
TLSPROV_LOG_HEX(aInput.Ptr(),aInput.Size() )
TInt nAlloc = iCryptos.iDecryptor->MaxFinalOutputLength(aInput.Size()) + 24;
if ( !aOutput || aOutput->Des().MaxLength() < nAlloc )
{
delete aOutput;
aOutput = NULL;
aOutput = HBufC8::NewL( nAlloc );
}
TPtr8 DecOutput = aOutput->Des();
DecOutput.Zero();
TRAP_IGNORE(iCryptos.iDecryptor->ProcessFinalL(aInput,DecOutput));
TUint HashSize = KSetOfTLSCipherSuites[iCipherIndex].iHashSize;
if(DecOutput.Length() < HashSize)
{
return KErrSSLAlertDecryptError;
}
//set ptr to MAC
TPtrC8 ReceivedMac = DecOutput.Mid(DecOutput.Length()-HashSize,HashSize);
//& set length to trim MAC
DecOutput.SetLength( DecOutput.Length()-HashSize );
TBuf8<64> CalculatedMac;
ComputeMacL(CalculatedMac,DecOutput,ETrue,aSeqNumber,aType);
TInt err = KErrBadMAC;
if(ReceivedMac.Compare(CalculatedMac) == 0)
{
err = KErrNone;
}
else
{
TLSPROV_LOG(_L("Decryption: Received MAC error"))
err = KErrSSLAlertBadRecordMac;
}
TLSPROV_LOG(_L("After Decryption , no mac"))
TLSPROV_LOG_HEX(aOutput->Ptr(),aOutput->Size() )
return err;
}
示例11: SearchName
//-----------------------------------------------------------------------------
//Function Name : void* SearchName(const TE32ExpSymInfoHdr* aSymInfoHeader,
// const char* aName)
//Description : To search symbol name in symbol table of the dll.
//Return Value : Valid address if name found otherwise NULL
//-----------------------------------------------------------------------------
void* SearchName(const TE32ExpSymInfoHdr* aSymInfoHeader, const char* aName)
{
//Size of Offset used by Symbol Table, it depends upon iFlags of E32EpocExpSymInfoHdr
TInt sizeOfStringTableOffset = KTwoByteOffset;
// Check size of symbol table offset
if ( aSymInfoHeader->iFlags )
{
sizeOfStringTableOffset = KFourByteOffset;
}
//Total no of Symbol in a Symbol table
TInt noOfSymbols = aSymInfoHeader->iSymCount;
TInt start = 0;
TInt mid;
TInt end = noOfSymbols-1;
TInt temp = 0 ;
TInt offsetToString = 0;
TPtrC8 tempName;
TPtrC8 pName;
pName.Set((unsigned char*)aName, strlen(aName));
TUint8* tempSymbolOffset = (TUint8*) aSymInfoHeader+ aSymInfoHeader->iSymbolTblOffset + noOfSymbols * sizeof(TInt);
TUint8* tempStringTableOffset = (TUint8*) aSymInfoHeader + aSymInfoHeader->iStringTableOffset;
//Binary Search for searching name in symbol table
while (start <= end)
{
mid = (start + end) / 2;
if ( sizeOfStringTableOffset == KTwoByteOffset )
{
offsetToString = *(unsigned short int*)(tempSymbolOffset + (sizeOfStringTableOffset * mid));
}
else
{
offsetToString = *(unsigned int*)(tempSymbolOffset + (sizeOfStringTableOffset * mid));
}
//need to shift 2 bit to left for alignment reasons
offsetToString <<= 2;
tempName.Set((unsigned char*)(tempStringTableOffset + offsetToString), strlen((char*)tempStringTableOffset + offsetToString));
temp = pName.Compare(tempName);
//if found return address of symbol
if( !temp )
{
return *( (void**)( (TUint8*)aSymInfoHeader+ aSymInfoHeader->iSymbolTblOffset + mid * sizeof(TInt)));
}
//update start/end
if ( temp < 0 )
{
end = mid -1;
}
else
{
start = mid +1;
}
}
return NULL;
}
示例12: ProcessCommandParametersL
TBool CMulScreensTestAppUi::ProcessCommandParametersL(CApaCommandLine& aCommandLine)
{
TPtrC8 tailEnd = aCommandLine.TailEnd();
if(tailEnd.Compare(KScreenDevice) == 0)
{
RDebug::Print(_L("**** MultipleScreensAppTest - ScreenDevice: This should panic with ECoePanicInvalidScreenNumber"));
CCoeEnv::Static()->ScreenDevice(KInvalidScreenNumber);
}
else if(tailEnd.Compare(KWindowGroup) == 0)
{
RDebug::Print(_L("**** MultipleScreensAppTest - WindowGroup: This should panic with ECoePanicInvalidScreenNumber"));
CCoeEnv::Static()->RootWin(KInvalidScreenNumber);
}
else
{
RDebug::Print(_L("MultipleScreensAppTest - Bad arguments, failing test...."));
RProcess().Terminate(KMulScreensAppTestFailed);
}
return ETrue;
}
示例13: ProcessANDTermL
CSenElement* CPolicyNormalizer::ProcessANDTermL(CSenElement* aAssertion, CSenElement* aNormalAssertion)
{
CSenElement* pNormChild = AddAndElementL(aNormalAssertion);
RPointerArray<CSenElement>& children = aAssertion->ElementsL();
TInt childCount = children.Count();
// CSenElement* normalizedFinalChild = NULL;
TInt i=0;
while (i < childCount)
{
CSenElement* pChild = children[i];
// CSenElement* newChild = NULL;
TPtrC8 childName = pChild->LocalName();
if(childName.Compare(WSPolicy::KAndCompositeAssertion) == 0)
{
}
else if (childName.Compare(WSPolicy::KXorCompositeAssertion) == 0)
{
//will be solved during collapsing
}
else if (childName.Compare(WSPolicy::KWsPolicy) == 0)
{
ProcessPolicyTermL(pChild,pNormChild);
}
else
{
// normalizedFinalChild =
ProcessAssertionTermL(pChild, pNormChild);
}
i++;
}
return aNormalAssertion;
}
示例14: ProcessCommandParametersL
/**
* Processes the command line parameters
* @param aCommandLine - command to be passed based on the menu item
* selected by the user
*
* This function leaks intentionally some memory and examines the value of the trailing data
* in aCommandLine (expected to be either ETrue or EFalse). According to this value CCoeEnv::DisableExitChecks()
* is triggered in order to disable or not the exit checks at kernel resources.
*
*/
TBool CExampleAppUi::ProcessCommandParametersL(CApaCommandLine& aCommandLine)
{
CEikAppUi* aAppUI = new(ELeave) CExampleAppUi; //intentionally caused memory leak
TPtrC8 tailEnd = aCommandLine.TailEnd();
if(tailEnd.Compare(KETrue) == 0)
{
RDebug::Print(_L("Disable shutdown checks"));
iEikonEnv->DisableExitChecks(ETrue);
}
else if(tailEnd.Compare(KEFalse) == 0)
{
RDebug::Print(_L("Enable shutdown checks"));
iEikonEnv->DisableExitChecks(EFalse);
}
else
{
RDebug::Print(_L("Bad arguments, failing test...."));
RProcess().Terminate(KTestFailed);
}
Exit();
return ETrue;
}
示例15: DeleteAsertionIndexL
CSenElement* CPolicyNormalizer::DeleteAsertionIndexL(CSenElement* aAssertion, CSenElement* anewAssertion, TInt aIndx)
{
TPtrC8 name = aAssertion->LocalName();
TPtrC8 nsUri = aAssertion->NamespaceURI();
TInt i = 0;
RPointerArray<CSenElement>& assertionChildren = anewAssertion->ElementsL();
TInt newAssertionChildCount = assertionChildren.Count();
if(newAssertionChildCount == 0)
return anewAssertion;
TPtrC8 namee = anewAssertion->LocalName();
if (name.Compare(anewAssertion->LocalName())== 0)
{ //delete children from this assertion except index child
CSenXmlElement* PolicyElement = (CSenXmlElement*)anewAssertion->Child(0);
CSenXmlElement* XORElement = (CSenXmlElement*)PolicyElement->Child(0);
RPointerArray<CSenElement>& XorChildren = XORElement->ElementsL();
TInt XORChildrenCount = XorChildren.Count();
for (TInt k = 0; k <XORChildrenCount; k++)
{
if(k == aIndx)
{
}
else
{
CSenElement* newElement = XORElement->RemoveElement(*XorChildren[XORChildrenCount-1-k]);
if(newElement)
{
delete newElement;
// break;
}
}
}
return anewAssertion;
}
while (i < newAssertionChildCount)
{
DeleteAsertionIndexL(aAssertion, assertionChildren[i], aIndx);
i++;
}
return anewAssertion;
}