本文整理汇总了C++中TPtrC8::Mid方法的典型用法代码示例。如果您正苦于以下问题:C++ TPtrC8::Mid方法的具体用法?C++ TPtrC8::Mid怎么用?C++ TPtrC8::Mid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TPtrC8
的用法示例。
在下文中一共展示了TPtrC8::Mid方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BearerToInterface
TInt CCoreSerialConverter::BearerToInterface(const TDesC8& aBearerData,
TUid& aInterfaceUid,
TUint& aOperationId,
TRemConMessageType& aMsgType,
TDes8& aData) const
{
TInt ret = KErrCorrupt;
// We read KRemConSerialBearerMessageLength bytes at a time, so we should
// get precisely one message.
if ( aBearerData.Length() == KRemConSerialBearerMessageLength )
{
TPtrC8 ptr;
ptr.Set(aBearerData);
TPtrC8 interfaceUid;
interfaceUid.Set(ptr.Mid(2, 8));
TLex8 interfaceLex(interfaceUid);
TUint uid = 0;
ret = interfaceLex.Val(uid, EHex);
if ( ret == KErrNone )
{
aInterfaceUid = TUid::Uid(uid);
TPtrC8 operationId;
operationId.Set(ptr.Mid(13, 2));
TLex8 operationLex(operationId);
TUint id = 0;
ret = operationLex.Val(id, EHex);
if ( ret == KErrNone )
{
aOperationId = id;
TPtrC8 data;
data.Set(ptr.Mid(16, 3));
if ( data == KCmdText() )
{
aMsgType = ERemConCommand;
}
else if ( data == KRspText() )
{
aMsgType = ERemConResponse;
}
else
{
ret = KErrCorrupt;
}
if ( ret == KErrNone )
{
TPtrC8 data;
data.Set(ptr.Mid(20, 10));
aData.Copy(data);
}
}
}
}
return ret;
}
示例2: Read
TPtrC8 Read(TDes8& aTempBuf, TPtrC8& aData, TInt aLength, TPtrC8& aOverflowData)
{
if (aLength <= aData.Length())
{
// Can read it from this buffer
TPtrC8 res(aData.Left(aLength));
aData.Set(aData.Mid(aLength));
return res;
}
else /*if (aLength > aData.Length())*/
{
// Descriptor spans wrap point, so need to copy into temp buf
aTempBuf.Copy(aData.Left(aTempBuf.MaxLength())); // If anyone's crazy enough to write a platsec diagnostic string longer than 2k, it gets truncated
TInt overflowLen = aLength - aData.Length();
aData.Set(aOverflowData); // Wrap aData
aOverflowData.Set(TPtrC8());
if (overflowLen > aData.Length())
{
ASSERT(EFalse); // Shouldn't happen
// in urel, return everything we've got
return aData;
}
aTempBuf.Append(aData.Left(overflowLen));
aData.Set(aData.Mid(overflowLen));
return TPtrC8(aTempBuf);
}
}
示例3: DecodeGenericNewStringValueL
void CWspHeaderReader::DecodeGenericNewStringValueL(RHeaderField& aHeader) const
{
TPtrC8 rawHeaderData;
aHeader.RawDataL(rawHeaderData);
TInt startPos = 0;
TInt separatorPos = 0;
TInt ii = 0;
// Loop through all the parts separated by the header field name
do
{
TPtrC8 rawData(rawHeaderData.Mid(startPos));
separatorPos = rawData.Locate((TUint8)(aHeader.Name().Index(WSP::Table) + KTopBitMask));
if(separatorPos!=KErrNotFound)
rawData.Set(rawHeaderData.Mid(startPos, separatorPos));
CheckLengthL(rawData, 1);
TWspPrimitiveDecoder wspDecoder(rawData);
if( !(CheckNullDesPartL(aHeader, rawData, ii)) )
{
AddNewDecoderStringPartL(aHeader, wspDecoder, ii);
}
++ii;
startPos += (separatorPos + 1);
} while( separatorPos != KErrNotFound );
}
示例4: ptr
void
CContentWindowContainer::DataReceived(class MBrCtlLinkContent* aLinkContent,
const isab::DataGuiMess* aMess, const char *aUrl)
{
HBufC8* data = NULL;
HBufC* contentType = NULL;
HBufC* url = WFTextUtil::AllocLC(aUrl);
TPtr8 ptr(const_cast<unsigned char*>(aMess->getData()), aMess->getSize(), aMess->getSize());
TInt neck = ptr.Find(KNeck());
if (neck == KErrNotFound) {
data = HBufC8::NewLC( ptr.Length());
data->Des().Copy(ptr);
contentType = WFTextUtil::AllocLC("text/html");
} else {
TPtrC8 header = ptr.Left(neck);
TPtrC8 body = ptr.Mid(neck+4);
data = HBufC8::NewLC( body.Length());
data->Des().Copy(body);
TInt pos = header.Find(KLineEnd);
TPtrC8 rest = header;
while (pos != KErrNotFound) {
TPtrC8 tmp = rest.Left(pos);
rest.Set(rest.Mid(pos+2));
pos = rest.Find(KLineEnd);
TInt ctpos = tmp.FindF(KContentTypeMarker);
if (ctpos != KErrNotFound) {
TPtrC8 tmp2 = tmp.Mid(ctpos+KContentTypeMarker().Length());
TInt scpos = tmp2.Find(KSemiColon);
if (scpos == KErrNotFound) {
contentType = HBufC::NewLC(tmp2.Length());
contentType->Des().Copy(tmp2);
} else {
contentType = HBufC::NewLC(tmp2.Left(scpos).Length());
contentType->Des().Copy(tmp2.Left(scpos));
}
break;
}
}
if (!contentType) {
contentType = WFTextUtil::AllocLC("text/html");
}
}
/* contentType = RecognizeLC(*url, ptr); */
/* contentType = WFTextUtil::AllocLC("text/html"); */
aLinkContent->HandleResolveComplete(*contentType, KCharSet, data);
CleanupStack::PopAndDestroy(contentType);
CleanupStack::PopAndDestroy(data);
CleanupStack::PopAndDestroy(url);
}
示例5: PartL
EXPORT_C CPushMessage* CMultipartBinIterator::PartL()
/** Gets the message part currently referenced by the iterator.
@return Message part
@leave KErrCorrupt The message is too short
@leave KErrNotFound Will leave if message body is empty
@leave TDesC8::AllocLC
@leave CPushMessage::NewL
*/
{
__ASSERT_DEBUG( iCurrentPart < iMultiNumEntries.iValue, User::Panic(KPushPartIndexOutOfRange,0));
TPtrC8 msgBody;
if (!iPushMessage.GetMessageBody(msgBody))
User::Leave(KErrNotFound);
// iCurrentPartStart is pointing to beginning of the message
// index will be used to get past the message headers
TUint index = iCurrentPartStart;
// Move over the headers
TWapBinCodex::TUintvar hdrSize, bodySize;
TWapBinCodex::ExtractUIntvarL(msgBody, index, hdrSize);
index += hdrSize.iOctetSize;
TWapBinCodex::ExtractUIntvarL(msgBody, index, bodySize);
index += bodySize.iOctetSize;
// Now get the data
TUint len = msgBody.Length();
// validate that we have as much data as HEADER indicates
if ( hdrSize.iValue < 0 || // No negative indices
(len < (index + hdrSize.iValue)))
User::Leave(KErrCorrupt);
// Get the Header
HBufC8* header = msgBody.Mid(index, hdrSize.iValue).AllocLC();
index += hdrSize.iValue;
// validate that we have as much data as BODY indicates
if ( bodySize.iValue < 0 || // No negative indices
(len < (index + bodySize.iValue)))
User::Leave(KErrCorrupt);
// Get the Body
HBufC8* body = msgBody.Mid(index, bodySize.iValue).AllocLC();
CPushMessage* pm = CPushMessage::NewL( header, body);
CleanupStack::Pop(2, header); // body, header
return pm;
}
示例6: DecodeContentEncodingL
void CWspHeaderReader::DecodeContentEncodingL(RHeaderField& aHeader) const
{
TPtrC8 rawHeaderData;
aHeader.RawDataL(rawHeaderData);
TInt startPos = 0;
TInt separatorPos = 0;
TInt ii = 0;
// Loop through all the parts separated by the header field token name
do
{
TPtrC8 rawData(rawHeaderData.Mid(startPos));
separatorPos = rawData.Locate((TUint8)(WSP::EContentEncoding + KTopBitMask));
if(separatorPos!=KErrNotFound)
rawData.Set(rawHeaderData.Mid(startPos, separatorPos));
CheckLengthL(rawData, 1);
TInt contentEncodingIndex = KErrNotFound;
switch( rawData[0] )
{
case 128: // This is the token for 'GZip'
{
contentEncodingIndex = WSPStdConstants::EGzip;
} break;
case 129: // This is the token for 'Compress'
{
contentEncodingIndex = WSPStdConstants::ECompress;
} break;
case 130: // This is the token for 'Deflate'
{
contentEncodingIndex = WSPStdConstants::EDeflate;
} break;
default: // Must be token text
{
TWspPrimitiveDecoder wspDecoder(rawData);
// Check that the data is of string type
if( wspDecoder.VarType() == TWspPrimitiveDecoder::EString )
{
// Extract and add the string as a part
AddNewDecoderStringPartL(aHeader, wspDecoder, ii);
}
else
User::Leave(KErrCorrupt);
} break;
}
if(contentEncodingIndex!=KErrNotFound)
SetFStringPartL(aHeader, ii, iStrPool.StringF(contentEncodingIndex, WSPStdConstants::Table));
++ii;
startPos += (separatorPos + 1);
} while( separatorPos != KErrNotFound );
}
示例7: DecodeContentLanguageL
void CWspHeaderReader::DecodeContentLanguageL(RHeaderField& aHeader) const
{
TPtrC8 rawHeaderData;
aHeader.RawDataL(rawHeaderData);
TInt startPos = 0;
TInt separatorPos = 0;
TInt ii = 0;
// Loop through all the parts separated by the header field name
do
{
TPtrC8 rawData(rawHeaderData.Mid(startPos));
separatorPos = rawData.Locate((TUint8)(WSP::EContentLanguage + KTopBitMask));
if(separatorPos!=KErrNotFound)
rawData.Set(rawHeaderData.Mid(startPos, separatorPos));
CheckLengthL(rawData, 1);
// First check for any language ('*') encoded as octet 128
if( rawData[0] == 128 )
SetFStringPartL(aHeader, ii, iStrPool.StringF(WSPLanguages::EAnyLanguage, WSPLanguages::Table));
else
{
// Otherwise the language is encoded as a short int, long int or token text
TWspPrimitiveDecoder wspDecoder(rawData);
switch( wspDecoder.VarType() )
{
case TWspPrimitiveDecoder::E7BitVal: // short int
case TWspPrimitiveDecoder::ELengthVal: // long int
{
TUint32 languageToken = 0;
User::LeaveIfError(wspDecoder.Integer(languageToken));
// Check if the language token is short or long int as long requires an offset
if( languageToken >= 128 )
// Language token is long int so apply the offset
--languageToken;
SetFStringPartL(aHeader, ii, iStrPool.StringF(languageToken, WSPLanguages::Table));
} break;
case TWspPrimitiveDecoder::EString: // token text
{
// Extract the token text and set the part
AddNewDecoderStringPartL(aHeader, wspDecoder, ii);
} break;
default:
User::Leave(KErrCorrupt);
break;
}
}
++ii;
startPos += (separatorPos + 1);
} while( separatorPos != KErrNotFound );
}
示例8: DecodeHeaderL
void CWspDefaultHdrReader::DecodeHeaderL(RHeaderField& aHeader)
{
// Get and store the header field name
TPtrC8 headerField(aHeader.Name().DesC());
// Decode the header as a text-string
TPtrC8 rawHeaderData;
aHeader.RawDataL(rawHeaderData);
TInt startPos = 0;
TInt separatorPos = 0;
TInt ii = 0;
// Loop through all the parts separated by the header field name
do
{
TPtrC8 rawData(rawHeaderData.Mid(startPos));
separatorPos = rawData.FindF(headerField);
if(separatorPos!=KErrNotFound)
rawData.Set(rawHeaderData.Mid(startPos, separatorPos));
// Check that the length of the data is at least 1
if( rawData.Length() < 1 )
User::Leave(KErrCorrupt);
// Check if the data is an empty string which should only have a NULL terminator
// otherwise extract the text-string from the primitive decoder
TUint8 firstByte = rawData[0];
TWspPrimitiveDecoder wspDecoder(rawData);
TPtrC8 buffer;
if( firstByte == 0 )
buffer.Set(KNullDesC8());
else
User::LeaveIfError(wspDecoder.String(buffer));
// Create a header part from the decoded buffer and add the part to the header field
RStringF partStr = iStrPool.OpenFStringL(buffer);
CleanupClosePushL(partStr);
THTTPHdrVal partVal(partStr);
CHeaderFieldPart* part = CHeaderFieldPart::NewL(partVal);
CleanupStack::PushL(part);
aHeader.SetPartL(part, ii);
CleanupStack::Pop(part);
CleanupStack::PopAndDestroy(&partStr);
++ii;
startPos += (separatorPos + headerField.Length() + 1);
} while( separatorPos != KErrNotFound );
}
示例9: ExtractCacheControlTime
EXPORT_C TBool CHTTPResponse::ExtractCacheControlTime(TCacheControlFieldValue aField,
TTime& aTime) const
{
__LOG_ENTER(_L("CHTTPResponse::ExtractCacheControlTime"));
__ASSERT_DEBUG(aField == ECacheCtrlMaxAge || aField == ECacheCtrlMaxStale
|| aField == ECacheCtrlMinFresh, User::Invariant());
TBool result = EFalse;
TPtrC8 cacheControl;
aTime = 0;
TInt index = FindCacheControlFieldValue(aField, cacheControl);
if(index != KErrNotFound)
{
// Have the cache control and the field position
// Now we need to extract the field's delta-secs value
index++;
TInt time = 0;
TPtrC8 integerSource = cacheControl.Mid(index);
if(integerSource[0] >= 0x80) // Short integer value
time = integerSource[0] & 0x7F;
else // Otherwise its multi octet
ExtractMultiOctetInteger(time, integerSource);
TTimeIntervalSeconds timeSeconds(time);
aTime += timeSeconds; // Store the seconds in the time field
result = ETrue;
}
__LOG_RETURN;
return result;
}
示例10: DecodePragmaL
void CWspHeaderReader::DecodePragmaL(RHeaderField& aHeader) const
{
TPtrC8 rawData;
aHeader.RawDataL(rawData);
CheckLengthL(rawData, 1);
// Check for <Octet 128> which indicates "No-Cache" string
if( rawData[0] == 128 )
{
SetFStringPartL(aHeader, 0, iStrPool.StringF(WSPStdConstants::ENoCache, WSPStdConstants::Table));
}
else
{
TWspPrimitiveDecoder wspDecoder(rawData);
if( wspDecoder.VarType() == TWspPrimitiveDecoder::ELengthVal )
{
TInt dataLength = 0;
TInt bytesProcessed = wspDecoder.LengthVal(dataLength);
User::LeaveIfError(bytesProcessed);
TPtrC8 rawParamBlock(rawData.Mid(bytesProcessed));
// Check that there is only one parameter block
if( dataLength != rawParamBlock.Length() )
User::Leave(KErrCorrupt);
CHeaderFieldPart& fieldPart = SetNewFStringPartL(aHeader, 0, KNullDesC8());
bytesProcessed += DecodeGenericSingleParameterL(rawParamBlock, fieldPart);
if( bytesProcessed != rawData.Length() )
User::Leave(KErrCorrupt);
}
}
}
示例11: GetHttpHeaderInfo
TPtrC8 CSocketEngine::GetHttpHeaderInfo(const TDesC8 &aHeaderData,const TDesC8 &aHeaderInfo){
_LIT8(KEnter,"\r\n");
TBuf8<256> bufInfo(aHeaderInfo);
bufInfo.Append(_L8(": "));
TPtrC8 ret;
TPtrC8 ptr;
ptr.Set(aHeaderData);
TInt pos=ptr.FindF(bufInfo);
if(pos>0){
TInt start=pos+bufInfo.Length();
ptr.Set(ptr.Mid(start));
pos=ptr.FindF(KEnter);
if(pos>0){
ptr.Set(ptr.Left(pos));
ret.Set(ptr);
}else if(-1==pos){
pos=ptr.FindF(_L8("\n"));
if(pos>0){
ptr.Set(ptr.Left(pos));
ret.Set(ptr);
}
}
}
return ret;
}
示例12: 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;
}
}
示例13: ObtainContactPointsListL
/**
* Retrieve contact point details from within SIA content body. This
* method looks up the owned CPushMessage message body and gets a
* pointer to it which it then parses to obtain the contact Points
* string only which it sets the iContactList pointer to.
* @leave KErrNotFound Will leave if the contacts list can not be obtained
* @leave KErrCorrupt Will leave if the message body contains corrupted data
*/
void CSIAContentHandler::ObtainContactPointsListL()
{
__LOG_PTR_DEBUG("CSIAContentHandler::ObtainContactPointsListL Called");
TPtrC8 rFieldValue;
TBool gotList = EFalse;
if (iMessage->GetMessageBody(rFieldValue))
{
TPtrC8 messageBodyPtr = rFieldValue;
TWapBinCodex::TUintvar rMultiByte;
TUint startpos = 1;
TWapBinCodex::ExtractUIntvarL(messageBodyPtr, startpos, rMultiByte);
TUint fieldSize = rMultiByte.iOctetSize;
TUint appIdFieldLength = rMultiByte.iValue;
TUint contactPointOffset = fieldSize + appIdFieldLength + startpos;
// now get Uintvar of ContactPointLen
TWapBinCodex::ExtractUIntvarL(messageBodyPtr, contactPointOffset, rMultiByte);
//actual Contact Points field starts after ContactPointLen uintvar
TUint contactPointLenSize = rMultiByte.iOctetSize;
TUint contactPointLen = rMultiByte.iValue;
TUint index = contactPointOffset + contactPointLenSize;
iContactList.Set(messageBodyPtr.Mid(index, contactPointLen));
if (iContactList.Length())
gotList = ETrue;
}
// failed to parse the contact points list
if (!gotList)
{
__LOG_PTR_DEBUG("CSIAContentHandler: Invalid Message Body - unable to parse.");
User::Leave(KErrNotFound);
}
}
示例14: 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
}
}
示例15: IgnoreSpaces
void CVBookmarkConverter::IgnoreSpaces( TPtrC8& aData )
{
TInt last = aData.Length() - 1;
TInt begin;
for ( begin = 0; begin <= last; begin++ )
{
if ( !TChar( aData[begin] ).IsSpace() )
{
break;
}
}
TInt end;
for ( end = last; end >= 0; end-- )
{
if ( !TChar( aData[end] ).IsSpace() )
{
break;
}
}
TInt length = end - begin + 1;
if ( ( begin != 0 || end != last ) && length > 0 )
{
TPtrC8 newData = aData.Mid( begin, length );
aData.Set( newData );
}
}