本文整理汇总了C++中TPtrC8类的典型用法代码示例。如果您正苦于以下问题:C++ TPtrC8类的具体用法?C++ TPtrC8怎么用?C++ TPtrC8使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TPtrC8类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetTestStepResult
TVerdict CMacIncrementalWithReplicateStep::doTestStepL()
{
//Assume faliure, unless all is successful
SetTestStepResult(EFail);
INFO_PRINTF1(_L("*** Mac - Incremental with Replicate ***"));
INFO_PRINTF2(_L("HEAP CELLS: %d"), User::CountAllocCells());
TVariantPtrC algorithmUid;
TPtrC sourcePath;
TPtrC expectedMac;
TPtrC encryptKey;
TVariantPtrC keyType;
//Extract the Test Case ID parameter from the specified INI file
if(!GetStringFromConfig(ConfigSection(),KConfigAlgorithmUid,algorithmUid) ||
!GetStringFromConfig(ConfigSection(),KConfigSourcePath,sourcePath) ||
!GetStringFromConfig(ConfigSection(),KConfigExMacValue,expectedMac) ||
!GetStringFromConfig(ConfigSection(),KConfigEncryptKey,encryptKey) ||
!GetStringFromConfig(ConfigSection(),KConfigEncryptKeyType,keyType))
{
ERR_PRINTF1(_L("** Error: Failed to Load Configuration Parameters **"));
return EFail;
}
//Create a pointer for the Mac Implementation Object
CMac* macImpl= NULL;
//Convert encryption key to an 8 Bit Descriptor
HBufC8* keyStr = HBufC8::NewLC(encryptKey.Length());
TPtr8 keyStrPtr = keyStr->Des();
keyStrPtr.Copy(encryptKey);
//Create an new CryptoParams object to encapsulate the key type and secret key string
CCryptoParams* keyParams = CCryptoParams::NewL();
CleanupStack::PushL(keyParams);
keyParams->AddL(*keyStr,keyType);
//Create Key Object
TKeyProperty keyProperty;
CKey* key=CKey::NewL(keyProperty,*keyParams);
CleanupStack::PushL(key);
//Retrieve a Mac Factory Object
TRAPD(err,CMacFactory::CreateMacL(macImpl,
algorithmUid,
*key,
NULL));
if (err != KErrNone)
{
CleanupStack::PopAndDestroy(3, keyStr); // keyStr, keyParams, key
delete macImpl;
ERR_PRINTF2(_L("*** FAIL: Failed to Create Mac Object - %d ***"), err);
return EFail;
}
//Push the Mac Implementation Object onto the Cleanup Stack
CleanupStack::PushL(macImpl);
RFs fsSession;
User::LeaveIfError(fsSession.Connect());
CleanupClosePushL(fsSession);
RFile sourceFile;
CleanupClosePushL(sourceFile);
//Open the specified source file
User::LeaveIfError(sourceFile.Open(fsSession,sourcePath, EFileRead));
TInt sourceLength = 0;
TInt readPosition = 0;
TInt readIncrement = 0;
TBool macComplete = EFalse;
TBool macReplicated = EFalse;
TPtrC8 macStr;
CMac* macReplicateImpl = NULL;
User::LeaveIfError(sourceFile.Size(sourceLength));
//Divide the total size of the source file up into individual equal sized blocks to read
//over several increments
readIncrement = sourceLength/KDataReadBlocks;
if (readIncrement == 0)
{
ERR_PRINTF2(_L("*** Error: Source File must be larger than %d bytes ***"), KDataReadBlocks);
User::LeaveIfError(KErrNotSupported);
}
do
{
//Create a heap based descriptor to store the data
HBufC8* sourceData = HBufC8::NewL(readIncrement);
CleanupStack::PushL(sourceData);
TPtr8 sourcePtr = sourceData->Des();
//Read in a block of data from the source file from the current position
//.........这里部分代码省略.........
示例2: qname
CSenElement* CPolicyNormalizer::ProcessAssertionTermL(CSenElement* aAssertion, CSenElement* aNormalAssertion)
{
TPtrC8 assertionName = aAssertion->LocalName();
TPtrC8 assertionNsUri = aAssertion->NamespaceURI();
TPtrC8 nsPrefix = aAssertion->NsPrefix();
TBuf8<255> qname(nsPrefix);
qname.Append(':');
qname.Append(assertionName);
CSenElement& newNormalForm = aNormalAssertion->AddElementL(assertionNsUri,assertionName, qname);
if(IsOptionalL(aAssertion))
{
if (CopySenElementWithoutOptionL(aAssertion, &newNormalForm))
{
CSenElement* parent = aNormalAssertion->Parent();
AddAndElementL(parent);
}
}
else
{
CopySenElementL(aAssertion, &newNormalForm);
}
RPointerArray<CSenElement>& children = aAssertion->ElementsL();
TInt childCount = children.Count();
if (childCount > 0)
{
CSenElement* pNextChild;
TInt i =0;
while (i < childCount)
{
pNextChild = children[i];
TPtrC8 localName = pNextChild->LocalName();
if(localName.Compare(KXorCompositeAssertion) == 0)
{
}
else if (localName.Compare(KAndCompositeAssertion) == 0)
{
}
else if (localName.Compare(KWsPolicy) == 0 )
{
CSenElement* aNewElement = AddPolicyElementL(&newNormalForm);
aNewElement = ProcessPolicyTermL(pNextChild,aNewElement);
}
else
{//if asserion is not well defined and dont have apolicy object here
//then it should add one and then add XOR and AND
// CSenElement* aNewElement = AddPolicyElementL(&newNormalForm);
// CSenElement* pChildXor = AddXorElementL(aNewElement);
// CSenElement* pChildAnd = AddAndElementL(pChildXor);
aNormalAssertion = ProcessAssertionTermL(pNextChild, &newNormalForm);
}
i++;
}
}
return aNormalAssertion;
}
示例3: while
CSenElement* CPolicyNormalizer::ProcessLogicL(CSenElement* aTerm)
{
//if sibling names are same as <ExactlyOne>
RPointerArray<CSenElement> matchingSiblings;
TInt matchingSiblingCount = 0;
if(aTerm->ElementsL(matchingSiblings, WSPolicy::KXorCompositeAssertion) == KErrNone)
matchingSiblingCount= matchingSiblings.Count();
if(matchingSiblingCount>1)
{ //XOR elements should have AND elements in them else normalization error
//Find elements
CSenElement* firstSibling = matchingSiblings[0];
TInt i = 1;
while ( i < matchingSiblingCount)
{
CSenElement* nextSibling = matchingSiblings[i];
firstSibling = ProcessAndAndLogicL(firstSibling, nextSibling);
i++;
}
TInt j = 0;
while ( j < matchingSiblingCount)
{
CSenElement* removed = aTerm->RemoveElement(*matchingSiblings[j]);
if(removed)
delete removed;
j++;
}
/**** aTerm->AddElementL(*firstSibling); */
}
RPointerArray<CSenElement>& children = aTerm->ElementsL();
TInt childCount = children.Count();
TInt i=0;
while (i < childCount)
{
CSenElement* pChild = children[i];
if(childCount == 1)
ProcessLogicL(pChild);
TPtrC8 childName = pChild->LocalName();
TPtrC8 parentName = aTerm->LocalName();
//if parent name and child name are same
if(childName.Compare(parentName) == 0)
{
if(childName.Compare(WSPolicy::KWsPolicy) == 0)
{
}
else if(childName.Compare(WSPolicy::KAndCompositeAssertion) == 0)
{
}
else if(childName.Compare(WSPolicy::KXorCompositeAssertion) == 0)
{
ProcessXorCollapseLogicL(aTerm,pChild);
continue;
}
}
i++;
}
matchingSiblings.Close();
return aTerm;
}
示例4: PerformanceTest3L
static void PerformanceTest3L()
{
test.Printf(_L("\n8 byte performance with existing parser comparison \n"));
TTime startTime, stopTime;
//legacy
startTime.UniversalTime();
TPtrC value;
for (TInt i=0;i<1000;i++)
{
CIniFile* ini=CIniFile::NewL(_L("z:\\resource\\legacy8.ini"));
test(ini->FindVar(_L("test_section"),_L("key1"),value));
test(value.Compare(_L("value1"))==0);
test(ini->FindVar(_L("test_section"),_L("key2"),value));
test(value.Compare(_L("value2"))==0);
test(ini->FindVar(_L("test_section"),_L("key3"),value));
test(value.Compare(_L("value3"))==0);
test(ini->FindVar(_L("test_section"),_L("key4"),value));
test(value.Compare(_L("value4"))==0);
test(ini->FindVar(_L("test_section"),_L("key5"),value));
test(value.Compare(_L("value value value"))==0);
test(ini->FindVar(_L("1"),_L("timestamps"),value));
test(value.Compare(_L("0"))==0);
test(ini->FindVar(_L("1"),_L("setting"),value));
test(value.Compare(_L("value"))==0);
delete ini;
}
stopTime.UniversalTime();
TTimeIntervalMicroSeconds timeTaken = stopTime.MicroSecondsFrom(startTime);
test.Printf(_L("Time taken for 8 bit Legacy= %d microseconds\n"), timeTaken.Int64() );
//light weight
startTime.UniversalTime();
for (TInt i=0;i<1000;i++)
{
TPtrC8 value;
//it is not necessarily to reopen a new file server session but just
//for fair performance comparison
RFs myFs;
User::LeaveIfError(myFs.Connect()) ;
CIniFile8* ini=CIniFile8::NewL(myFs,_L("z:\\resource\\legacy8.ini"));
test(ini->FindVar(_L8("test_section"),_L8("key1"),value)==KErrNone);
test(value.Compare(_L8("value1"))==0);
test(ini->FindVar(_L8("test_section"),_L8("key2"),value)==KErrNone);
test(value.Compare(_L8("value2"))==0);
test(ini->FindVar(_L8("test_section"),_L8("key3"),value)==KErrNone);
test(value.Compare(_L8("value3"))==0);
test(ini->FindVar(_L8("test_section"),_L8("key4"),value)==KErrNone);
test(value.Compare(_L8("value4"))==0);
test(ini->FindVar(_L8("test_section"),_L8("key5"),value)==KErrNone);
test(value.Compare(_L8("value value value"))==0);
test(ini->FindVar(_L8("1"),_L8("timestamps"),value)==KErrNone);
test(value.Compare(_L8("0"))==0);
test(ini->FindVar(_L8("1"),_L8("setting"),value)==KErrNone);
test(value.Compare(_L8("value"))==0);
delete ini;
myFs.Close();
}
stopTime.UniversalTime();
timeTaken = stopTime.MicroSecondsFrom(startTime);
test.Printf(_L("Time taken for 8 bit Light= %d microseconds\n"), timeTaken.Int64() );
//heavy weight
startTime.UniversalTime();
for (TInt i=0;i<1000;i++)
{
TPtrC8 value;
//it is not necessarily to reopen a new file server session but just
//for fair performance comparison
RFs myFs;
User::LeaveIfError(myFs.Connect()) ;
CIniDocument8* ini=CIniDocument8::NewL(myFs,_L("z:\\resource\\legacy8.ini"));
test(ini->GetKeyValue(_L8("test_section"),_L8("key1"),value)==KErrNone);
test(value.Compare(_L8("value1"))==0);
test(ini->GetKeyValue(_L8("test_section"),_L8("key2"),value)==KErrNone);
test(value.Compare(_L8("value2"))==0);
test(ini->GetKeyValue(_L8("test_section"),_L8("key3"),value)==KErrNone);
test(value.Compare(_L8("value3"))==0);
test(ini->GetKeyValue(_L8("test_section"),_L8("key4"),value)==KErrNone);
test(value.Compare(_L8("value4"))==0);
test(ini->GetKeyValue(_L8("test_section"),_L8("key5"),value)==KErrNone);
test(value.Compare(_L8("value value value"))==0);
test(ini->GetKeyValue(_L8("1"),_L8("timestamps"),value)==KErrNone);
test(value.Compare(_L8("0"))==0);
test(ini->GetKeyValue(_L8("1"),_L8("setting"),value)==KErrNone);
test(value.Compare(_L8("value"))==0);
delete ini;
myFs.Close();
}
stopTime.UniversalTime();
timeTaken = stopTime.MicroSecondsFrom(startTime);
test.Printf(_L("Time taken for 8 bit Heavy= %d microseconds\n"), timeTaken.Int64() );
//.........这里部分代码省略.........
示例5: while
// -----------------------------------------------------------------------------
// CWPPushMessage::ParseContentType
// -----------------------------------------------------------------------------
//
void CWPPushMessage::ParseContentType( TLex8& aPointer )
{
// Go through the whole content type header.
while( !aPointer.Eos() )
{
// Each parameter might be well-known (integer) or unknown (text)
if( IsIntegerValue( aPointer ) )
{
// For well-known parameters, the token is an integer value
TUint paramToken( I64LOW( GetIntegerValue( aPointer ) ) );
// These are filled with results from parsing.
TInt resultInteger( 0 );
TPtrC8 resultString;
// Make sure paramToken fits into KParameterTypes table
if( paramToken
< sizeof(KParameterTypes)/sizeof(TParameterCodingType))
{
// Get the coding and use it to determine how we should decode
// the next parameter value. We actually ignore all results
// except short integer (SEC) and text-value (MAC), but the
// rest of the parameters have to be parsed anyway.
TParameterCodingType coding( KParameterTypes[paramToken] );
switch( coding )
{
case EQValue:
GetQValue( aPointer );
break;
case EWellKnownCharset:
GetWellKnownCharset( aPointer );
break;
case EVersionValue:
GetVersionValue( aPointer );
break;
case EIntegerValue:
GetIntegerValue( aPointer );
break;
case ETextString:
GetTextString( aPointer );
break;
case EFieldName:
GetFieldName( aPointer );
break;
case EShortInteger:
resultInteger = GetShortInteger( aPointer );
break;
case EConstrainedEncoding:
GetConstrainedEncoding( aPointer );
break;
case EDeltaSecondsValue:
GetDeltaSecondsValue( aPointer );
break;
case ENoValue:
GetNoValue( aPointer );
break;
case ETextValue:
resultString.Set( GetTextValue( aPointer ) );
break;
case EDateValue:
GetDateValue( aPointer );
break;
default:
break;
}
// We have a result. We're actually only interested in
// SEC and MAC parameters, so we save them here.
switch( paramToken )
{
case KWSPHeaderSEC:
iSEC = resultInteger;
break;
case KWSPHeaderMAC:
iMAC.Set( resultString );
break;
default:
break;
}
}
}
//.........这里部分代码省略.........
示例6: GetNextDataPart
// -----------------------------------------------------------------------------
// CHttpCacheDataSupplier::GetNextDataPart
// Return the next chunk of response body from the Cache
// -----------------------------------------------------------------------------
//
TBool CHttpCacheDataSupplier::GetNextDataPart(
TPtrC8 &aDataChunk )
{
aDataChunk.Set( *m_body );
return ETrue;
}
示例7: WriteToL
void CSenLayeredXmlProperties::WriteToL(RWriteStream& aWriteStream)
{
// Find out whether we should declare the namespace
TPtrC8 nsPrefix = ipFragment->NsPrefix();
// Element name
aWriteStream.WriteL(KSenLessThan);
if ( nsPrefix.Length() > 0 )
{
aWriteStream.WriteL(nsPrefix);
aWriteStream.WriteL(KSenColon);
}
aWriteStream.WriteL(ipFragment->AsElement().LocalName());
RPointerArray<CSenBaseAttribute>& attrs = ipFragment->AsElement().AttributesL();
RPointerArray<CSenNamespace>& namespaces = ipFragment->AsElement().NamespacesL();
if ( ( attrs.Count() > 0 ) || ( namespaces.Count() > 0 ) )
{
CSenNamespace* ns = NULL;
TInt count = namespaces.Count();
for (TInt i=0; i < count; i++)
{
ns = (namespaces)[i];
if (ns)
{
aWriteStream.WriteL(KSenSpaceXmlns);
if (ns->Prefix().Length() > 0)
{
aWriteStream.WriteL(KSenColon);
aWriteStream.WriteL(ns->Prefix());
}
aWriteStream.WriteL(KSenEqualsDblQuot);
aWriteStream.WriteL(ns->URI());
aWriteStream.WriteL(KSenDblQuot);
}
}
count = attrs.Count();
for (TInt j = 0; j < count; j++)
{
aWriteStream.WriteL(KSenSpace);
aWriteStream.WriteL((attrs)[j]->Name());
aWriteStream.WriteL(KSenEqualsDblQuot);
aWriteStream.WriteL((attrs)[j]->Value());
aWriteStream.WriteL(KSenDblQuot);
}
}
// Elements and content
RPointerArray<CSenElement> elements;
ElementsL(elements);
if ( (elements.Count() > 0) || ipFragment->AsElement().HasContent() )
{
aWriteStream.WriteL(KSenGreaterThan);
// Body
TInt elementCount(elements.Count());
for (TInt k=0; k<elementCount; k++)
{
elements[k]->WriteAsXMLToL(aWriteStream);
}
aWriteStream.WriteL(ipFragment->AsElement().Content());
// Closing element
aWriteStream.WriteL(KSenLessThanSlash);
if (nsPrefix.Length() > 0)
{
aWriteStream.WriteL(nsPrefix);
aWriteStream.WriteL(KSenColon);
}
aWriteStream.WriteL(ipFragment->AsElement().LocalName());
aWriteStream.WriteL(KSenGreaterThan);
}
else
{
aWriteStream.WriteL(KSenSlashGreaterThan);
}
elements.Close();
}
示例8: PropertyL
TInt CSenLayeredXmlProperties::PropertyL(const TDesC8& aName,
TPtrC8& aValue,
TPtrC8& aType)
{
if ( ipChildProperties )
{
TInt retVal = ipChildProperties->PropertyL(aName, aValue);
if ( retVal == KErrNotFound )
{
CSenElement* pElement = ipFragment->AsElement().Element(aName);
if ( pElement )
{
/*
CSenPropertiesElement* pPropertyElement
= (CSenPropertiesElement*) pElement;
aValue.Set(pPropertyElement->Value());
aType.Set(pPropertyElement->Type());
*/
const TDesC8* pAttrValue = pElement->AttrValue(KSenOmittedAttributeName);
if ( pAttrValue )
{
if ( *pAttrValue == KSenOmittedTrueNoValue)
{
return KErrSenOmitted;
}
else if ( *pAttrValue == KSenPropertyTrue)
{
return KErrSenOmitted;
}
}
aValue.Set(pElement->Content());
aType.Set(*pElement->AttrValue(KSenTypeAttributeName));
return KErrNone;
}
else
{
return KErrNotFound;
}
}
return retVal;
}
else
{
CSenElement* pElement = ipFragment->AsElement().Element(aName);
if ( pElement )
{
/*
CSenPropertiesElement* pPropertyElement
= (CSenPropertiesElement*) pElement;
aValue.Set(pPropertyElement->Value());
aType.Set(pPropertyElement->Type());
*/
const TDesC8* pAttrValue = pElement->AttrValue(KSenOmittedAttributeName);
if ( pAttrValue )
{
if ( *pAttrValue == KSenOmittedTrueNoValue)
{
return KErrSenOmitted;
}
else if ( *pAttrValue == KSenPropertyTrue)
{
return KErrSenOmitted;
}
}
aValue.Set(pElement->Content());
aType.Set(*pElement->AttrValue(KSenTypeAttributeName));
return KErrNone;
}
else
{
return KErrNotFound;
}
}
}
示例9: _LIT8
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;
}
示例10: switch
void CSTTrackerConnection::MHFRunL(RHTTPTransaction aTransaction,
const THTTPEvent& aEvent)
{
switch (aEvent.iStatus)
{
case THTTPEvent::EGotResponseHeaders:
{
// HTTP response headers have been received. Use
// aTransaction.Response() to get the response. However, it's not
// necessary to do anything with the response when this event occurs.
LWRITELN(iLog, _L("[Trackerconnection] Got HTTP headers"));
// Get HTTP status code from header (e.g. 200)
RHTTPResponse resp = aTransaction.Response();
TInt status = resp.StatusCode();
if (status != 200) // ERROR, hiba esetén mi legyen? 404-et lekezelni!
{
LWRITE(iLog, _L("[Trackerconnection] Error, status = "));
TBuf<20> numBuf;
numBuf.Num(status);
LWRITELN(iLog, numBuf);
Cancel();
if (iObserver)
iObserver->TrackerConnectionFailedL();
break;
}
// Get status text (e.g. "OK")
HLWRITE(iLog, _L("[Trackerconnection] Status text = "));
TBuf<32> statusText;
statusText.Copy(resp.StatusText().DesC());
HLWRITELN(iLog, statusText);
#ifdef LOG_TO_FILE
RHTTPHeaders headers =
aTransaction.Response().GetHeaderCollection();
THTTPHdrFieldIter i =
headers.Fields();
for (i.First(); !(i.AtEnd()); ++i)
{
RStringF header = iSession.StringPool().StringF(i());
if ((header.DesC() == _L8("Content-Type")))
{
HLWRITE(iLog, header.DesC());
HLWRITE(iLog, _L(": "));
THTTPHdrVal val;
headers.GetField(header, 0, val);
RStringF value = val.StrF();
HLWRITELN(iLog, value.DesC());
}
else
HLWRITELN(iLog, header.DesC());
}
#endif
}
break;
case THTTPEvent::EGotResponseBodyData:
{
// Part (or all) of response's body data received. Use
// aTransaction.Response().Body()->GetNextDataPart() to get the actual
// body data.
// Get the body data supplier
MHTTPDataSupplier* body = aTransaction.Response().Body();
TPtrC8 dataChunk;
// GetNextDataPart() returns ETrue, if the received part is the last
// one.
TBool isLast = body->GetNextDataPart(dataChunk);
//iDownloadedSize += dataChunk.Size();
HLWRITELN(iLog, _L8("[TrackerConnection] HTTP response body chunk received: "));
HLWRITELN(iLog, dataChunk);
if (iReceiveBuffer)
{
HBufC8* temp = HBufC8::NewL(
iReceiveBuffer->Length() + dataChunk.Length());
TPtr8 tempPtr(temp->Des());
tempPtr.Copy(*iReceiveBuffer);
tempPtr.Append(dataChunk);
delete iReceiveBuffer;
iReceiveBuffer = temp;
}
else
iReceiveBuffer = dataChunk.AllocL();
// Always remember to release the body data.
body->ReleaseData();
// NOTE: isLast may not be ETrue even if last data part received.
// (e.g. multipart response without content length field)
// Use EResponseComplete to reliably determine when body is completely
//.........这里部分代码省略.........
示例11: switch
// MHTTPTransactionCallback interface functions
void CXmlHandler::MHFRunL(RHTTPTransaction aTransaction, const THTTPEvent& aEvent)
{
switch (aEvent.iStatus)
{
case THTTPEvent::EGotResponseHeaders:
{
iObserver.GIEStateChanged(eStateFoundServer);
iModel.iState = eStateFoundServer;
/*
Not interested in the received header
*/
}
break;
case THTTPEvent::EGotResponseBodyData:
{
#ifdef _INCREMENTAL_H
#else
/*
The non incremental version of the parser will just build
up a string of the data until the EReponseComplete code is
received. Then the string is sent to parser in one go
*/
RHTTPResponse response = aTransaction.Response();
MHTTPDataSupplier* bodyPtr = response.Body();
/*
Received data is appended to the existing block (if there is a block),
otherwise a new block is created
*/
TPtrC8 bodypart;
bodyPtr->GetNextDataPart(bodypart);
if (iQueryResponse == NULL)
{
iQueryResponse = HBufC8::NewL( bodypart.Length() );
}
else
{
const TInt newSize = iQueryResponse->Length() + bodypart.Length();
iQueryResponse = iQueryResponse->ReAllocL( newSize );
}
TPtr8 tmp = iQueryResponse->Des();
tmp.Append(bodypart);
bodyPtr->ReleaseData();
#endif
}
break;
case THTTPEvent::EResponseComplete:
{
iObserver.GIEStateChanged(eStateReceivedResponse);
iModel.iState = eStateReceivedResponse;
#ifdef _INCREMENTAL_H
#else
#ifdef LOG_RESONSE
LogMessage(iFs, KResponseFilename, *iQueryResponse);
#endif
/*
Data block ready. Parse and fill data model
*/
OneTripParse(iQueryResponse->Des(), iModel.iError, iModel.iResult, iModel.iItems);
#endif
CleanupQueryText();
iObserver.GIEStateChanged(eStateComplete);
iModel.iState = eStateComplete;
}
break;
case THTTPEvent::ESucceeded:
{
// transaction successful
// we do not do this in the response complete phase or error
// phase as it is nicer to break it up because if the parser
// is working non incrementally we have potientionally done
// a lot of work in the ReponseComplete phase
iObserver.GIEStateChanged(eStateComplete);
iModel.iState = eStateComplete;
}
break;
case THTTPEvent::EFailed:
{
// Transaction failed
MHFRunError(aEvent.iStatus, aTransaction, aEvent);
}
break;
default:
{
/*
All errors will fall through to the generic event handler
The only exceptional error handling is done when the soap
request itself fails and it reports an error
*/
MHFRunError(aEvent.iStatus, aTransaction, aEvent);
}
break;
//.........这里部分代码省略.........
示例12: codec
/**
Finds Implementation UID.
@param aCodec Codec names.
@param aNext Pointer to 8-bit data that is to recieve the delegate name.
@return always returns a valid UID of the codec plugin.
@leave KErrNotFound Specified Codec.
@internalComponent
*/
TUid CHeaderCodecPlugin::FindImplementationUidL(const TDesC8& aCodec, TPtrC8& aNext)
{
TEComResolverParams resolverParams;
TPtrC8 codec(aCodec); // The codec to look for (may be changed so we need our own pointer)
TUid id = KNullUid;
while(id == KNullUid) // while there is no match
{
// if the string we need to match can't be made by a TPtrC, we will create it in resolve
HBufC8* resolve = NULL;
resolverParams.SetWildcardMatch(ETrue);
// find the first slash of text in the form: "protocol/type/name/etc" or "protocol/type" or "protocol"
// This will be the name of the protocol
TInt firstSlash = codec.Locate('/');
if( firstSlash < 0 ) // no slashes -- this is just the protocol name ("protocol")
{
resolverParams.SetDataType(codec); // look for a match for "protocol"
aNext.Set(KNullDesC8); // no next codec in chain.
}
else if( firstSlash == codec.Length() - 1) // just "protocol/"
// it's easier to use this than to pass around with the *, since this
// way aNext always points to the original descriptor
{
resolve = HBufC8::NewL(codec.Length()+1);
TPtr8 res = resolve->Des();
res.Copy(codec);
res.Append('*');
resolverParams.SetDataType(res); // the string "protocol/*"
aNext.Set( codec.Left(firstSlash) ); // next codec is "protocol" (no slash)
}
else // there is at least one slash with subsequent content ("protocol/name")
{
TInt lastSlash = codec.LocateReverse('/'); // find the last slash
// must match exactly otherwise we'd always resolve "protocol/*"
resolverParams.SetWildcardMatch(EFalse);
if (lastSlash > firstSlash)
{// has at least 2 slashes ("protocol/name1/name2")
// resolve = up to and including first slash, and everything after last slash ("protocol/name2")
resolve = HBufC8::NewL(firstSlash+1 + codec.Length()-lastSlash);
TPtr8 res = resolve->Des();
res.Copy(codec.Left(firstSlash+1)); // up to and including first slash
res.Append(codec.Mid(lastSlash+1)); // everything after last slash
aNext.Set( codec.Left(lastSlash) ); // up to,but not including the last slash
resolverParams.SetDataType(res);
}
else // just the one slash ("protocol/name")
{
resolverParams.SetDataType(codec); // look for "protocol/name"
aNext.Set(codec.Left(firstSlash+1)); // next codec is "protocol"
}
}
CleanupStack::PushL(resolve); // resolve might be NULL, but that's ok
RImplInfoPtrArray implArray; // the list of plugins will be put here.
REComSession::ListImplementationsL(KUidHeaderCodecPlugin, resolverParams, implArray);
TInt count = implArray.Count();; // number of matches
CleanupStack::PopAndDestroy(resolve); // don't need this anymore
if(count != 0) // we found the match. save it in id
{
id = implArray[0]->ImplementationUid();
}
implArray.ResetAndDestroy();
if(count == 0 && aNext.Length() == 0) // no more codecs to try
{
User::Leave(KErrNotFound); // No suitable implementation is present
}
codec.Set(aNext);
}
return id;
}
示例13: CopyAddr
//***************************************************************************
//Helpers
//***************************************************************************
static void CopyAddr(const TBTSockAddr& aAddr, void* dst) {
const TBTDevAddr& devAddr(aAddr.BTAddr());
const TPtrC8 devPtrC8(devAddr.Des());
DEBUG_ASSERT(devPtrC8.Length() == BTADDR_LEN);
memcpy(dst, devPtrC8.Ptr(), BTADDR_LEN);
}
示例14: lexer
// -----------------------------------------------------------------------------
// CEcmtPanPlugin::HandleNotifyL
//
// -----------------------------------------------------------------------------
//
void CEcmtPanPlugin::HandleNotifyL( const CEcmtMessageEvent& aEvent )
{
const TPtrC8 m = iMessaging->Message( aEvent );
TLex8 lexer( m );
TPtrC8 btCom = lexer.NextToken();
TPtrC8 btComVal = lexer.NextToken();
TPtrC8 hci = lexer.NextToken();
TPtrC8 hciVal = lexer.NextToken();
TPtrC8 irdaCom = lexer.NextToken();
TPtrC8 irdaComVal = lexer.NextToken();
if ( btCom != KBtCom || hci != KHci || irdaCom != KIrdaCom )
{
ErrorReply( R_INTERNAL_ERROR, KNullDesC );
return;
}
_LIT8( KMinusOne, "-1" );
if ( btComVal != KMinusOne && btComVal == irdaComVal )
{
ErrorReply( R_IRDA_BT_ERROR, KNullDesC );
return;
}
TBuf<KMaxWin32Path> buff;
TPtrC8 line;
/*
* Handle bt.esk
*/
GetBtEskFilename( buff );
REcmtFile btFile( buff );
btFile.Read();
if ( !btFile.IsGood() )
{
ErrorReply( R_FILE_NOT_FOUND, buff );
return;
}
// Set port number
line.Set( btFile.FindLine( KBtPort ) );
if ( line.Length() == 0 )
{
ErrorReply( R_FILE_CORRUPTED, buff );
return;
}
TBuf8< 64 > newLine;
newLine.Append( KBtPort );
newLine.Append( _L(" ") );
newLine.Append( btComVal );
newLine.Append( _L("\r\n") );
if ( !btFile.ReplaceLine( line, newLine ) )
{
ErrorReply( R_INTERNAL_ERROR, KNullDesC );
return;
}
// Set hci dll
line.Set( btFile.FindLine( KHciDll ) );
if ( line.Length() == 0 )
{
ErrorReply( R_FILE_CORRUPTED, buff );
return;
}
newLine.Zero();
newLine.Append( KHciDll );
newLine.Append( _L(" ") );
if ( hciVal[0] == '0' )
{
newLine.Append( KHciDllBcsp );
}
else if ( hciVal[0] == '1' )
{
newLine.Append( KHciDllH4 );
}
else if ( hciVal[0] == '2' )
{
newLine.Append( KHciDllUsb );
}
else
{
newLine.Append( KHciDllH4 );
}
newLine.Append( _L("\r\n") );
if ( !btFile.ReplaceLine( line, newLine ) )
{
ErrorReply( R_INTERNAL_ERROR, KNullDesC );
return;
}
if ( !btFile.Write() )
//.........这里部分代码省略.........
示例15: FirstReadChunk
EXPORT_C TInt TMTPTypeNull::FirstReadChunk(TPtrC8& aChunk) const
{
aChunk.Set(KNullDesC8);
return KMTPChunkSequenceCompletion;
}