本文整理汇总了C++中TDesC::Mid方法的典型用法代码示例。如果您正苦于以下问题:C++ TDesC::Mid方法的具体用法?C++ TDesC::Mid怎么用?C++ TDesC::Mid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TDesC
的用法示例。
在下文中一共展示了TDesC::Mid方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Trim
EXPORT_C TPtrC TEFparser::Trim(const TDesC& aBuf)
{
TInt startPos = 0;
TInt endPos = 0;
TInt i = 0, j = 0;
for(i = 0; i < aBuf.Length() ; i ++)
{
TPtrC tmpChar = aBuf.Mid(i,1);
if(tmpChar != KSpace && tmpChar != KTab && tmpChar != KReturn && tmpChar != KNewline )
{
startPos = i;
break;
}
}
for(j = aBuf.Length()-1; j >= 0 ; j --)
{
TPtrC tmpChar1 = aBuf.Mid(j,1);
if(tmpChar1 != KSpace && tmpChar1 != KTab && tmpChar1 != KReturn && tmpChar1 != KNewline )
{
endPos = j;
break;
}
}
if(endPos < startPos)
{
endPos = aBuf.Length();
}
// TInt len = aBuf.Length() - (startPos + endPos);
return aBuf.Mid(startPos, endPos - startPos + 1);
}
示例2: OperationEvent
//From MOperationObserver
void CHandleLoginOrExit::OperationEvent(TInt aEventType,const TDesC& aEventData,TInt aType)
{
UtilityTools::WriteLogsL(_L("CHandleLoginOrExit::OperationEvent aEventType = %d,aType = %d"),aEventType,aType);
if(aEventType==EHttpNoError)
{
if(aType==EHttpLogin)
{
if(aEventData.Mid(8,8).Compare(_L("10000099"))==0)
{
this->CheckGateWay(aEventData.Mid(101,1));
this->CheckAppUpdate(aEventData.Mid(98,1));
this->CheckContentUpdate(aEventData.Mid(99,1));
this->CheckRegisterPhone(aEventData.Mid(97,1));
this->CheckSystemInfo(aEventData);
}
else
{
iObserver.HandleResponseEvent(EHttpContentError,aType);
return;
}
}
}
else
{
iBuf=HBufC::NewL(aEventData.Length());
iBuf->Des().Copy(aEventData);
}
iObserver.HandleResponseEvent(aEventType,aType);
UtilityTools::WriteLogsL(_L("CHandleLoginOrExit::OperationEvent"));
}
示例3: AddTextItem
void CContentInfoDialog::AddTextItem(const TDesC& aText)
{
TInt textPos = 0;
while(textPos < aText.Length())
{
TInt charNum = iMainEngine.ScreenLayout().Font()->TextCount(aText.Mid(textPos),iLineWidth);
const TDesC& tmpDes = aText.Mid(textPos,charNum);
iDesArray->AppendL(tmpDes);
textPos += charNum;
}
InitScrollBar();
}
示例4: UpdateNextCharsL
// -----------------------------------------------------------------------------
// For Devanagari AS
// (other items were commented in a header).
// -----------------------------------------------------------------------------
//
inline void UpdateNextCharsL( HBufC*& aNextChars, const TDesC& aItemString )
{
TChar searchChar = aItemString[0];
//Check if this is an Indic special ligature
if ( IsIndicConsonant(searchChar) && aItemString.Length() > 2
&& IsSpecialIndicLigature(aItemString)
&& KErrNotFound == (*aNextChars).Find(aItemString.Mid(0,3)) )
{
//Check if we have enough space for 3 more characters
if( aNextChars->Des().Length() >= aNextChars->Des().MaxLength()-3 )
{
aNextChars = aNextChars->ReAllocL( aNextChars->Des().MaxLength()+10 );
}
aNextChars->Des().Append( aItemString.Mid(0,3) );
}
else
{
//check if this is an Indic combined Char
if ( IsIndicCombinedChar(searchChar) )
{
searchChar = RemoveIndicNukta( searchChar );
}
//Now update the nextChars string
TInt strLength = aNextChars->Length();
for ( TInt i(0); i < strLength ; ++i )
{
if ( IsSpecialIndicLigature( (*aNextChars).Mid( i ) ) )
{
//As aItemString is not a special ligature (checked above)
//we can move directly to the 3rd character from here
i+=2;
}
else if ( searchChar.GetUpperCase() == (*aNextChars)[i] ||
searchChar.GetLowerCase() == (*aNextChars)[i] )
{
//already exists - do nothing
return;
}
//else continue the loop
}
//So this character is not yet in the list of nextChars.
if ( aNextChars->Des().Length() == aNextChars->Des().MaxLength() )
{
aNextChars = aNextChars->ReAllocL( aNextChars->Des().MaxLength()+10 );
}
aNextChars->Des().Append( searchChar );
}
}
示例5: AddTextItem
void CSelectGroup::AddTextItem(const TDesC& aText)
{
TInt textPos = 0;
while(textPos < aText.Length())
{
TInt charNum = iMainEngine.ScreenLayout().Font()->TextCount(aText.Mid(textPos),iLineWidth);
const TDesC& tmpDes = aText.Mid(textPos,charNum);
CSelectBox* selectBox=CSelectBox::NewL(iMainEngine,ESelectText);
selectBox->SetText(tmpDes);
iSelectArray.Append(selectBox);
textPos += charNum;
}
LayoutScrollBar();
}
示例6: CheckDiskSpace
TInt CFileEngine::CheckDiskSpace(const TDesC& aSourceFile,const TDesC& aDestFile)
{
RFile file;
TInt rv =0;
TInt nFileLen=0;
rv = file.Open(iFs, aSourceFile, EFileWrite|EFileShareAny);
if (KErrNone != rv)
{
return 2;
}
file.Size(nFileLen);
nFileLen=nFileLen/1024;
TInt64 nDriverSize=GetFreeSpace(aDestFile.Mid(0,1));
if((TInt64)nFileLen>nDriverSize)
{
//存储空间不足
file.Close();
return 1;
}
file.Close();
return 0;
}
示例7: Write
TInt CVtConsoleOutputController::Write(const TDesC& aDes)
{
TInt err = KErrNone;
if (iMode == ConsoleMode::EBinary)
{
// staight collapse to 8 bit, no cleverness
TBuf8<256> buf;
TInt offset = 0;
while ((offset < aDes.Length()) && (err == KErrNone))
{
buf.Copy(aDes.Mid(offset, Min(aDes.Length() - offset, buf.MaxLength())));
offset += buf.Length();
err = iOutput.Output(buf);
}
}
else
{
// In text mode we do a UTF-16 -> UTF-8 conversion
TRAP(err, iOutputBuf.CopyAsUtf8L(aDes));
if (err == KErrNone)
{
err = iOutput.Output(iOutputBuf);
if (err == KErrNone)
{
iCursorTracker->Write(aDes);
}
}
}
return err;
}
示例8: PrintHex
EXPORT_C void CTestUtils::PrintHex(const TDesC& aDes)
{
TBuf<256> temp;
TInt pos = 0;
const TInt len = aDes.Length();
while (pos < len)
{
temp.Zero();
TPtrC ptr = aDes.Mid(pos, Min(KNumberOfHex, len - pos));
const TInt ptrLen = ptr.Length();
for (TInt i = 0; i < ptrLen; i++)
{
temp.AppendFormat(_L("%2.2x "), ptr[i]);
}
if (ptrLen < KNumberOfHex)
{
temp.AppendFill(' ', (KNumberOfHex - ptrLen) * 3);
}
temp.Append(ptr);
Printf(temp);
pos += KNumberOfHex;
}
}
示例9: Replace
EXPORT_C void TConsoleLine::Replace(TInt aFrom, const TDesC& aDes)
{
// a) Hide the cursor.
// b) Move the cursor to aFrom.
// c) Overwrite chars up to iBufPos.
// d) Insert remaining chars (if any).
// e) Make the cursor visible again.
aFrom += iPromptLength;
ASSERT(iBufPos >= aFrom);
iConsole.SetCursorVisible(EFalse);
iConsole.SetCursorPosAbs(iConsole.PosFrom(iStartPos, aFrom));
const TInt desLength = aDes.Length();
const TInt numOverwriteChars = iBufPos - aFrom;
TInt lengthAdjust = 0;
if (numOverwriteChars > 0)
{
iBuf.Replace(aFrom, numOverwriteChars, aDes.Left(numOverwriteChars));
if (desLength < numOverwriteChars)
{
lengthAdjust = numOverwriteChars - desLength;
iBuf.AppendFill(' ', lengthAdjust);
iBufPos -= lengthAdjust;
}
}
const TInt numInsertChars = desLength - numOverwriteChars;
if (numInsertChars > 0)
{
iBuf.Insert(iBufPos, aDes.Mid(numOverwriteChars));
iBufPos += numInsertChars;
}
iConsole.Write(iBuf.Mid(aFrom));
iBuf.SetLength(iBuf.Length() - lengthAdjust);
iConsole.SetCursorPosAbs(iConsole.PosFrom(iStartPos, aFrom + aDes.Length()));
iConsole.SetCursorVisible(ETrue);
}
示例10: GetExtNameFromFileName
void GetExtNameFromFileName(const TDesC& aFileName, TDes& aExtName)
{
TInt order = aFileName.LocateReverse('.');
TInt sourceLength = aFileName.Length() - order -1;
aExtName = aFileName.Mid(order +1, sourceLength);
aExtName.LowerCase();
}
示例11: ConvertSEIDs
TBool CT_DataRGavdp::ConvertSEIDs(TDesC &aSEIDsStr, RArray<TUint>& aSEIDs)
{
TBool ret = ETrue;
TLex lex(aSEIDsStr);
TInt tempSEID;
if (lex.Val(tempSEID) == KErrNone)
{
aSEIDs.Append(tempSEID);
}
else
{
TInt location = aSEIDsStr.Match(_L("*,*"));
if( location != KErrNotFound )
{
//Converting Left part of the data
TPtrC tempStr = aSEIDsStr.Left(location);
ret = ConvertSEIDs(tempStr, aSEIDs);
if(ret)
{
//Converting right data can be with another ","
tempStr.Set(aSEIDsStr.Mid(location + 1));
ret = ConvertSEIDs(tempStr, aSEIDs);
}
}
else
{
ret = EFalse;
}
}
return ret;
}
示例12: WrapPhoneNumberToArrayL
EXPORT_C TBool AknPhoneNumberTextUtils::WrapPhoneNumberToArrayL(
const TDesC& aPhoneNumberToWrap,
TInt aLineWidthInPixels,
TInt aMaxLines,
const CFont& aFont,
CArrayFix<TPtrC>& aWrappedArray )
{
TBool retVal( EFalse ); // Not truncated
HBufC* reversedText = aPhoneNumberToWrap.AllocLC();
TPtr revPtr = reversedText->Des();
ReverseDescriptor( revPtr );
CArrayFix<TInt>* lineWidthArray = new (ELeave) CArrayFixFlat<TInt>(KLineArrayGranularity);
CleanupStack::PushL( lineWidthArray );
lineWidthArray->AppendL( aLineWidthInPixels, aMaxLines );
// Perform the wrap on the reversed text
AknTextUtils::WrapToArrayL( revPtr, *lineWidthArray, aFont, aWrappedArray );
// Now rearrange the TPtrCs to point to the original array
TInt totalLen = reversedText->Length();
TInt count = aWrappedArray.Count();
TInt usedLen = 0; // Accumulates the length actually used
for ( TInt index = 0; index < count; index++)
{
TPtrC& currentPtr = aWrappedArray.At(index);
// The TPtrCs have to be moved. The reversing is taken into effect, but not purely reversed
// because their otherwise they would have negative lengths. That is, {a,b} does not go to
// { final - a, final - b }, but rather to {final - b, final - a}; they are flipped, to get
// their start points before the end points
//
// Now, representing the start position by pos, and the end by pos+len-1 we have the TPtrC at
// {pos, pos+len-1} inclusive, in reversed array.
// The TPtrC must be modified to point to {total_len-1 - (pos+len-1), total_len-1 - pos}
// in the unreversed array:
TInt len = currentPtr.Length();
usedLen += len;
TInt pos = currentPtr.Ptr() - reversedText->Ptr(); // pointer arithmetic
TInt newPos = totalLen - pos - len;
// If the TPtr is zero length then it must get special treatment, as the normal
// calculations give an end point before the start point! i.e. {pos, pos-1}
// We handle this by NOT flipping in this case.
// { pos, pos-1 } -> {totalLen-1-pos, totalLen-1 - (pos-1)}
// Note that a zero length wrapped line is completely possible amoung a bunch of other
// lines with characters on them, as the line lengths may be of wildly different lengths.
if ( len == 0 )
newPos--;
currentPtr.Set( aPhoneNumberToWrap.Mid(newPos, len) );
}
// If the accumulated length is less than that in the entire input descriptor, then text does not fit
if ( usedLen < totalLen )
retVal = ETrue;
CleanupStack::PopAndDestroy(2); // lineWidthArray first, and then reversedText
return retVal;
}
示例13: parser
int
TcpipComm::Open(CConsoleBase *cons, TDes &name, TDesC &destination,
TRequestStatus &st)
{
int r;
TInetAddr addr;
TPtrC servername;
int port = 0;
if((r = iServ.Connect()) != KErrNone)
return r;
if((r = iSock.Open(iServ,KAfInet,KSockStream,KProtocolInetTcp)) != KErrNone)
return r;
//////////////
// Parse the destination, which is of the form ip.adress:port
for(r = 0; r < destination.Length(); r++)
if(destination[r] == ':')
break;
servername.Set(destination.Left(r)); // Wont include ':'
TLex parser(destination.Mid(r+1));
parser.Val(port);
addr.SetPort(port);
if(addr.Input(servername) != KErrNone) // Its a real hostname, wont resolv
return 1;
iSock.Connect(addr, st);
TPckgBuf<int> one(1);
iSock.SetOpt(KSoTcpNoDelay, KSolInetTcp, one);
return 0;
}
示例14: GetIniFileInfo
EXPORT_C TInt TEFparser::GetIniFileInfo(TDesC& aBuf,
TPtrC& aIniFileName,
TPtrC& aIniSectionName)
{
TInt pos =0;
TInt startPos = 0, endPos = 0;
TPtrC temp = aBuf.Mid(pos);
endPos = temp.Find(KIniExtension);
endPos += 4;
if (endPos != KErrNotFound)
{
TInt len = endPos - startPos;
TPtrC iniFileName = temp.Mid(startPos, len);
aIniFileName.Set(iniFileName);
TPtrC iniSectionName = temp.Mid(iniFileName.Length());
aIniSectionName.Set(Trim(iniSectionName));
return KErrNone;
}
else
{
return KErrNotFound;
}
}
示例15: ParseNthElement
EXPORT_C TPtrC TEFparser::ParseNthElement(const TDesC& aBuf, TInt aWordPos)
{
TInt startPos = KErrNotFound, endPos = KErrNotFound;
TInt wordCounter =0 ;
TBool inWord = EFalse;
TInt i =0;
for(i = 0; i < aBuf.Length() ; i ++)
{
TPtrC tmpChar = aBuf.Mid(i,1);
if(tmpChar == KSpace || tmpChar == KTab || tmpChar == KReturn || tmpChar == KNewline )
{
if(inWord)
{
if(wordCounter == aWordPos)
{
endPos =i-1;
break;
}
inWord = EFalse;
}
}
else
{
if(inWord == EFalse)
{
wordCounter ++;
inWord = ETrue;
if(wordCounter == aWordPos)
{
startPos =i;
}
}
}
}
if(startPos < 0 || endPos < 0)
{
endPos = aBuf.Length();
return aBuf.Mid(startPos,(endPos-startPos));
}
else
{
return aBuf.Mid(startPos,(endPos-startPos+1));
}
}