本文整理汇总了C++中TDes::SetLength方法的典型用法代码示例。如果您正苦于以下问题:C++ TDes::SetLength方法的具体用法?C++ TDes::SetLength怎么用?C++ TDes::SetLength使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TDes
的用法示例。
在下文中一共展示了TDes::SetLength方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetEskFilename
// -----------------------------------------------------------------------------
// Shared by GetBtEskFilename and GetIrdaEskFilename
// -----------------------------------------------------------------------------
static void GetEskFilename( TDes& aBuff, const TDesC& aFileName )
{
TInt maxLen = aBuff.MaxLength();
aBuff.SetLength(maxLen);
::GetModuleFileName(NULL, &(aBuff[0]), maxLen);
aBuff[aBuff.MaxLength() - 1] = 0;
aBuff.SetLength(User::StringLength(aBuff.Ptr()));
aBuff.SetLength(aBuff.LocateReverse('\\') + 1);
aBuff.Append(_L( "z\\private\\101f7989\\ESock\\"));
aBuff.Append(aFileName);
aBuff.ZeroTerminate();
}
示例2: CopyAndExpandDes
TInt StopModeDebug::CopyAndExpandDes(const TDesC& aSrc, TDes& aDest)
{
//check bounds
if(aSrc.Length() * 2 > aDest.MaxLength())
{
return KErrArgument;
}
//get a pointer to the start of the destination descriptor
TUint16* destPtr = (TUint16*)aDest.Ptr();
//get pointers to the start and end of the aSrc descriptor
const TUint8* srcPtr = aSrc.Ptr();
const TUint8* srcEnd = srcPtr + aSrc.Length();
//copy the characters from aSrc into aDest, expanding to make them 16-bit characters
while(srcPtr < srcEnd)
{
*destPtr = (TUint16)*srcPtr;
destPtr++;
srcPtr++;
}
//set aDest's length to reflect the new contents
aDest.SetLength(2*aSrc.Length());
return KErrNone;
}
示例3: GetStringFromConsoleL
// -----------------------------------------------------------------------------
// CNSPTestConsoleApp::GetStringFromConsole
// -----------------------------------------------------------------------------
//
TKeyCode CNSPTestConsoleApp::GetStringFromConsoleL( TDes& aBuffer )
{
TKeyCode input = EKeyNull;
const TInt startPos = iConsole->WhereX();
iConsole->Write( aBuffer );
do {
input = iConsole->Getch();
if ( ( EKeyBackspace == input || EKeyDelete == input ) &&
startPos < iConsole->WhereX() ) // Backspace & Delete
{
iConsole->SetPos( iConsole->WhereX() - 1 );
iConsole->ClearToEndOfLine();
aBuffer.SetLength( 0 < aBuffer.Length() ?
aBuffer.Length() - 1 :
aBuffer.Length() );
}
else{
TChar chr( input );
if ( chr.IsPrint() )
{
aBuffer.Append( chr );
iConsole->Printf( _L("%c"), input );
}
}
}
while ( EKeyEnter != input && EKeyEscape != input );
return input;
}
示例4: SetRandomAlphaNumericString
void CCntItemBuilder::SetRandomAlphaNumericString(TDes& aBuf,TInt aLength)
{
aBuf.SetLength(aLength);
for (TInt ii = 0; ii < aLength; ++ii)
{
aBuf[ii]=RandomAlphaNumbericCharCode();
}
}
示例5: StripExtension
/**
Helper function to strip extension
*/
void CGsaFlexiMergeManyFilesTest::StripExtension(TDes& aFilename)
{
TInt dot = aFilename.Find(_L("."));
if(KErrNotFound != dot)
{
aFilename.SetLength(dot);
}
}
示例6: SetRandomAlphaString
void CCntItemBuilder::SetRandomAlphaString(TDes& aBuf,TInt aLength)
{
aBuf.SetLength(aLength);
for (TInt i=0; i<aLength; ++i)
{
aBuf[i]=RandomAlphaCharCode();
}
}
示例7: StripExtension
void CCmdTestSsmCommand::StripExtension( TDes& aFilename )
{
TInt dot = aFilename.Find( _L(".") );
if( KErrNotFound != dot)
{
aFilename.SetLength( dot );
}
}
示例8: SetRandomAlphaNumericString
//------------------------------------------------------------------------------------------------------------
void CPerfDbCreator::SetRandomAlphaNumericString(TDes& aBuf,TInt aLength, TBool aWithSeed)
{
aBuf.SetLength(aLength);
for (TInt ii=0;ii<aLength;++ii)
{
aBuf[ii]=RandomAlphaNumbericCharCode();
}
if (aWithSeed)
aBuf.Replace(0,8, iTextSeed);
}
示例9: ReadDesc
static void ReadDesc(TDes& aDes, const TDesC& aFilename, RFs& aFs)
{
RFile file;
TInt err = file.Open(aFs, aFilename, EFileRead);
TheTest(err == KErrNone);
CleanupClosePushL(file);
TPtr8 ptr(reinterpret_cast<TUint8*>(const_cast<TUint16*>(aDes.Ptr())), aDes.MaxSize());
err = file.Read(ptr);
TheTest(err == KErrNone);
aDes.SetLength(ptr.Length() / sizeof(TText));
CleanupStack::PopAndDestroy(&file);
}
示例10: TruncateToNumChars
EXPORT_C void TextUtils::TruncateToNumChars(TDes& aBuffer, TInt numChars)
/** Truncates text to a number of characters.
If truncation is required (because aBuffer contains more than numChars
characters), an ellipsis is added to the text as the last character.
@param aBuffer On return, contains the truncated text.
@param numChars The number of characters. */
{
if (aBuffer.Length() <= numChars)
return;
aBuffer.SetLength(numChars-1);
aBuffer.Append(KTextUtilClipEndChar);
}
示例11: AppendText
EXPORT_C void CTestUtils::AppendText(const TDesC& aToken, TDes& aTxt, TInt aMaxTokenLength)
{
TInt totalLen = aTxt.Length() + aMaxTokenLength;
aTxt.Append(aToken);
aTxt.TrimRight();
if (aTxt.Length() < totalLen)
{
aTxt.AppendFill(' ', totalLen - aTxt.Length());
}
aTxt.SetLength(totalLen);
}
示例12: ReplaceFmtSpec
//Replaces:
// 1) "%lld" with "%ld"
// 2) "%s" with "%S"
//These are the differences in format specification between RDebig::Print and OST functions.
//The new format spec length should be less or equal than the old format spec length.
static void ReplaceFmtSpec(TDes& aFormat, const TDesC& aFmtSpec, const TDesC& aNewFmtSpec)
{
TInt fmtLength = aFormat.Length();
const TInt KDiff = aFmtSpec.Length() - aNewFmtSpec.Length();
TPtr ptr((TText*)aFormat.Ptr(), fmtLength, fmtLength);
TInt pos;
while((pos = ptr.Find(aFmtSpec)) >= 0)
{
ptr.Replace(pos, aFmtSpec.Length(), aNewFmtSpec);
fmtLength -= KDiff;
ptr.Set(ptr.MidTPtr(pos));
}
aFormat.SetLength(fmtLength);
}
示例13: AdjustLanguageName
// ---------------------------------------------------------
// Adjust language name
// ---------------------------------------------------------
//
void CGSPenInputModel::AdjustLanguageName(TInt aLangId, TDes& aLangName)
{
switch(aLangId)
{
case ELangPrcChinese:
case ELangHongKongChinese:
case ELangTaiwanChinese:
{
TInt index = aLangName.Find(KLeftBracket);
if( index != KErrNotFound)
{
aLangName.SetLength(index);
}
}
}
}
示例14: GetStringFromConsole
//*******************************************************************************
// Method : CTestAppConsole::GetAddrFromConsole()
// Purpose :
// Parameters :
// Return Value:
//*******************************************************************************
TKeyCode CTestAppConsole::GetStringFromConsole(TDes &aAddr)
{
// Get a line from console
TKeyCode input = EKeyNull;
const TInt start_pos = iConsole->WhereX();
aAddr.Zero();
// loop until descriptor full or EKeyEnter or EKeyEscape entered
do {
// get one character
input = iConsole->Getch();
// process it
if(input == EKeyBackspace || input == EKeyDelete)
{
// backspace or delete
if(iConsole->WhereX() > start_pos)
{
iConsole->SetPos(iConsole->WhereX() - 1);
iConsole->ClearToEndOfLine();
if(aAddr.Length() > 0)
{
aAddr.SetLength(aAddr.Length() - 1);
}
}
}
else
{
// other than backspace or delete
TChar ch(input);
if(ch.IsPrint())
{
aAddr.Append(ch);
iConsole->Printf(_L("%c"), input);
}
}
}
while(aAddr.Length() < aAddr.MaxLength() && input != EKeyEnter && input != EKeyEscape);
DisplayMsg(KTxtLineBreak);
return input;
}
示例15: ColumnText
/**
Copies the content of a text column, identified by aColumnIndex, to the place refered by aDest parameter.
If the destination buffer is not big enough, the function will copy as much data as possible and will
return KErrOverflow.
@param aColumnIndex Column index
@param aDest Refers to the place where the column data will be copied.
@return KErrNone, if the function completes successfully,
otherwise one of the other system-wide error codes.
@panic SqlDb 5 Column index out of bounds.
@panic SqlDb 11 Statement cursor not positioned on a row
*/
TInt CSqlStatementImpl::ColumnText(TInt aColumnIndex, TDes& aDest)
{
__ASSERT_ALWAYS((TUint)aColumnIndex < (TUint)iColumnCnt, __SQLPANIC(ESqlPanicBadColumnIndex));
__ASSERT_ALWAYS(iState == CSqlStatementImpl::EAtRow, __SQLPANIC(ESqlPanicInvalidRow));
iColumnValBufIt.MoveTo(aColumnIndex);
TInt err = KErrNone;
//The text column value has not been transferred to the client side if its length is >= KSqlMaxDesLen characters.
//In this case an additional call to the server is made to get the column value.
if(!iColumnValBufIt.IsPresent())
{
if(iColumnValBufIt.Type() != ESqlText)
{
aDest.Zero();
return err;
}
TPtr8 ptr(reinterpret_cast <TUint8*> (const_cast <TUint16*> (aDest.Ptr())), aDest.MaxLength() * sizeof(TUint16));
err = iSqlStmtSession.ReadColumnValue(aColumnIndex, ptr);
switch(err)
{
case KErrNone:
case KErrOverflow:
aDest.SetLength(ptr.Length() / sizeof(TUint16));
break;
default:
break;
}
}
else
{
TPtrC src = iColumnValBufIt.Text();
TInt len = src.Length();
if(len > aDest.MaxLength())
{
len = aDest.MaxLength();
err = KErrOverflow;
}
aDest.Copy(src.Ptr(), len);
}
return err;
}