当前位置: 首页>>代码示例>>C++>>正文


C++ TDes::Ptr方法代码示例

本文整理汇总了C++中TDes::Ptr方法的典型用法代码示例。如果您正苦于以下问题:C++ TDes::Ptr方法的具体用法?C++ TDes::Ptr怎么用?C++ TDes::Ptr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TDes的用法示例。


在下文中一共展示了TDes::Ptr方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: 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;
	}
开发者ID:kuailexs,项目名称:symbiandump-os1,代码行数:27,代码来源:d_stopmode.cpp

示例2: ClipLineOnLeft

EXPORT_C void AknPhoneNumberTextUtils::ClipLineOnLeft( 
    TPtrC& aLine, TDes& aOriginalBuffer, TInt aWidth, const CFont& aFont )
    {
    // Main work of this routine is to make a TPtr of the input TPtrC, then we can clip using existing
    // utils.
 
    // But first check if the line points to the provided modifiable buffer
    TText* linePtr = (TText*)aLine.Ptr();
    TInt lineLen = aLine.Length();
    TText* pastEndOfLine = linePtr + lineLen; // pointer arithmetic

    TText* modBufPtr = (TText*)aOriginalBuffer.Ptr();
    TInt len = aOriginalBuffer.Length(); // length actually with text in it (not maxlength)
    TText* pastEndOfModBufPtr = modBufPtr + len; // pointer arithmetic

    // This Panics if the input aLine is not encompassed within the modifiable buffer ->Programmer error
    __ASSERT_ALWAYS( (modBufPtr <= linePtr && pastEndOfLine <= pastEndOfModBufPtr ), Panic( EAknPanicInconsistentDescriptors ) );

    // Set the TPtr now to extend from the start of the original buffer to the end of the input aLine
    TInt enlargedLength = (pastEndOfLine - modBufPtr);//  Pointer arithmetic; 
    TPtr ptr( modBufPtr, enlargedLength, enlargedLength );

    // Should have a safe modifiable buffer now.
    AknTextUtils::ClipToFit( ptr, aFont, aWidth, AknTextUtils::EClipFromBeginning );
    aLine.Set( ptr );
    }
开发者ID:cdaffara,项目名称:symbiandump-mw1,代码行数:26,代码来源:AknPhoneNumberTextUtils.cpp

示例3: RemoveRichtextFormating

EXPORT_C void CTestUtils::RemoveRichtextFormating(TDes& aSourceLine)
	{
	TUint8* ptr = (TUint8*)aSourceLine.Ptr();
	TUint8* start = ptr;

	TInt totalLength = aSourceLine.Length()*2;
	do {
		if(*ptr==CEditableText::EParagraphDelimiter || *ptr==CEditableText::ELineBreak || *ptr==CEditableText::EPageBreak)
			*ptr=0x0A;
		} while((++ptr-start)<totalLength);
	}
开发者ID:cdaffara,项目名称:symbiandump-mw2,代码行数:11,代码来源:MsvTestUtilsBase.cpp

示例4: 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();
}
开发者ID:fedor4ever,项目名称:packaging,代码行数:15,代码来源:EcmtPanPlugin.cpp

示例5: 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);
	}
开发者ID:cdaffara,项目名称:symbiandump-os2,代码行数:13,代码来源:t_sql.cpp

示例6: 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);
	}
开发者ID:cdaffara,项目名称:symbiandump-os2,代码行数:19,代码来源:SqlUtil.cpp

示例7: iFs

// ==========================================================================
// METHOD:  Constructor
//
// DESIGN:  
// ==========================================================================
CLogFileHandler::CLogFileHandler( RFs& aFs,
                                  TDes& aFormatBuffer, 
                                  TDes8& aOutputBuffer,
                                  const TDesC& aDirectoryName,
                                  const TDesC& aFileName ) : 
    iFs( aFs ),                                  
    iFormatBuffer( aFormatBuffer ),
    iFormatBuffer8( const_cast<TUint8*>(reinterpret_cast<const TUint8*>(aFormatBuffer.Ptr())), 0, aFormatBuffer.MaxLength()*2 ),
    iOutputBuffer( aOutputBuffer ),
    iDirectoryName( aDirectoryName ),
    iFileName( aFileName ),
    iTryToOpenFile( ETrue ),
    iFileIsOpen( EFalse ),
    iFirstTime( ETrue )
    {
    } // END CLogFileHandler
开发者ID:cdaffara,项目名称:symbiandump-ossapps,代码行数:21,代码来源:DebugLog.cpp

示例8: 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;
	}
开发者ID:cdaffara,项目名称:symbiandump-os2,代码行数:55,代码来源:SqlStatementImpl.cpp

示例9: Read

// ---------------------------------------------------------
//
// ---------------------------------------------------------
//
TInt TMmsFileText::Read( TDes& aDes )
/**
Reads single line text record into the specified descriptor.

The read operation begins at the current file position, and ends when
a line delimiter character is read or the caller's buffer is full or
the file ends;

If the line is longer than fits into user's buffer, of if the file does
not end with a terminator, KErrTooBig is returned.
The purpose is to inform the caller that a terminator should not be added
to the line when it is written elsewhere.

Next time the reading continues from the current position so that a long
line may be read in chunks and terminator added when the end of the line
has been reached.

If Read() is called when the current position is the end of the file (that 
is, after the last line delimiter in the file), KErrEof is returned, and the 
length of the buffer is set to zero.

@param aDes On return, contains the single record read from the file. Any 
            previous contents are overwritten.

@return KErrNone if successful, otherwise one of the other system-wide error 
        codes. KErrTooBig indicates that the line does not end with a
        terminator. Buffer is too short to hold the whole line or the line
        is the last line in the file and the file does not end with a 
        terminator character.
*/
	{
	TText* pD = ( TText* )aDes.Ptr();
	TInt len = aDes.MaxLength();
	TInt newLen = 0;
	TInt r = KErrNone;
    TBool terminate = EFalse;
	while ( newLen < len )
		{
		if ( iNext >= iEnd )
			{
			r = FillBuffer();
			if ( r != KErrNone && r != KErrEof )
			    {
				return r;
			    }
			if ( r == KErrEof )
				{
				aDes.SetLength( newLen );
				return ( newLen ? KErrTooBig : KErrEof );
				}
			continue;
			}
		terminate = newLen;
		r = CheckForTerminator( terminate );
		if ( r != KErrNone || terminate)
			{
			aDes.SetLength( newLen );
			return r;
			}
		*pD++ = ( *iNext++ );
		newLen++;
		}
	aDes.SetLength( newLen );
	terminate = newLen;
	r=CheckForTerminator( terminate );
	if ( r != KErrNone || terminate )
	    {
		return r;
	    }
// don't skip the rest of the line - return the rest the next time.
	return KErrTooBig;
	}
开发者ID:cdaffara,项目名称:symbiandump-ossapps,代码行数:76,代码来源:mmsattachmenthandler.cpp


注:本文中的TDes::Ptr方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。