本文整理汇总了C++中TDes16::Ptr方法的典型用法代码示例。如果您正苦于以下问题:C++ TDes16::Ptr方法的具体用法?C++ TDes16::Ptr怎么用?C++ TDes16::Ptr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TDes16
的用法示例。
在下文中一共展示了TDes16::Ptr方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Get
/** Reads a descriptor setting.
@param aKey Key of setting to be read.
@param aValue Returns the value of the setting if it is a descriptor.
@return
KErrNone if successful,
KErrNotFound if the setting does not exist,
KErrArgument if the setting exists but is not a descriptor,
KErrOverflow if the descriptor is too small to receive the value in the repository,
plus other system-wide error codes.
@post Transactions fail only on those "other system-wide error codes".
@capability Dependent Caller must satisfy the read access policy of that key in the repository.
*/
EXPORT_C TInt CRepository::Get(TUint32 aKey, TDes16& aValue)
{
TPtr8 ptr8((TUint8*)aValue.Ptr(), 0, aValue.MaxSize());
TInt ret=Get(aKey,ptr8);
if (ret==KErrNone)
aValue.SetLength(ptr8.Length()/2);
return ret;
}
示例2: Read
/**
Reads data from the stream buffer into the specified descriptor.
On return, contains the data read from the stream buffer
@param aDes The target descriptor for the data read from the stream buffer
@param aLength The maximum number of bytes to be read
@return KErrNone If all bytes read successfully.
@return KErrCorrupt If reading fails.
@return KErrEof If end of file is reached.
@return ... Any one of the system-wide error codes for other errors.
*/
EXPORT_C TInt RZipFileMemberReaderStream::Read(TDes16& aDes, TInt aLength)
{
TUint32 numBytesRead = 0;
TInt err = Read(CONST_CAST(TByte*,(const TByte*)aDes.Ptr()), 2*aLength, &numBytesRead);
if (err != KErrNone)
{
aDes.SetLength( (err==KErrEof) ? numBytesRead>>2 : 0 );
return err;
}
示例3: ConstructL
void CEnvironment::ConstructL(TUint aCount, TDes16& aBuffer)
//
// Set up the environment from a descriptor. If this leaves then
// the CEnvironment destructor will be able to clean up properly.
//
{
// always allocate at least one slot - makes life easier elsewhere
TInt bytes = (aCount+1)*sizeof(TEnvVar);
iVars=(TEnvVar*) User::AllocL(bytes);
Mem::FillZ(iVars,bytes);
iCount=aCount+1;
const TText16* data=aBuffer.Ptr();
for (TUint i=0; i<aCount; ++i)
iVars[i].ConstructL(data);
}
示例4: if
/**
* Converts a descriptor of type TBuf16 to character stream
*
* @param aSrc is the descriptor to be converted , aDes is the
* reference to the character sream where the result of conversion
* is stored , n_size specifies the conversion size of the string
* @return Status code (0 is ESuccess, -1 is EInsufficientMemory,
* -2 is EInvalidSize , -4 is EInvalidPointer, -8 is EInvalidWCSSequence)
*/
EXPORT_C int Tbuf16ToChar(TDes16& aSrc, char* aDes, int& n_size)
{
unsigned int ilen = aSrc.Length();
int retval = ESuccess;
wchar_t *temp16String = NULL;
int minusone = -1;
if (0 == ilen)
{
return EDescriptorNoData;
}
else if(!aDes)
{
return EInvalidPointer;
}
else if(n_size < ilen*2+1)
{
n_size = ilen*2;
return EInvalidSize;
}
temp16String = new wchar_t [ilen+1];
if (!temp16String)
{
return EInsufficientSystemMemory;
}
wmemcpy(temp16String, (const wchar_t *)aSrc.Ptr(), ilen);
temp16String[ilen] = L'\0';
if(minusone != wcstombs(aDes, (const wchar_t*)temp16String, ilen*2))
{
aDes[ilen*2] = '\0';
}
else
{
retval = EInvalidWCSSequence;
}
delete []temp16String;
return retval;
}
示例5: ReadL
void CMemSpyMemStreamReader::ReadL( TDes16& aDes )
{
// The kernel driver only ever writes narrow descriptors.
// However, we can expand them to be UCS2
const TInt length = ReadInt32L();
// Need to check the remaining text is actually present...
IsAvailableL( length );
// Set final length in descriptor
aDes.SetLength( length );
// Read each char
TUint16* dest = const_cast< TUint16* >( aDes.Ptr() );
for( TInt i=0; i<length; i++ )
{
*dest++ = *iCurrent++;
}
}
示例6:
/**
* Converts a descriptor of type RBuf16 to Wstring
*
* @param aSrc is the descriptor to be converted , aDes is the
* reference to the Wstring array where the result of conversion
* is stored
* @return Status code (0 is ESuccess, -1 is EInsufficientMemory,
* -2 is EInvalidSize , -4 is EInvalidPointer , -5 is EDescriptorNoData)
*/
EXPORT_C int Rbuf16ToWstring(TDes16& aSrc, wstring& aDes)
{
unsigned int ilen = aSrc.Length();
if (0 == ilen)
{
return EDescriptorNoData;
}
wchar_t* buf = new wchar_t[ilen+1];
if(!buf)
{
return EInsufficientSystemMemory;
}
wmemcpy (buf,(wchar_t *)aSrc.Ptr(), ilen);
buf[ilen]=L'\0';
aDes.assign(buf);
delete[] buf;
return ESuccess;
}