本文整理汇总了C++中TDes16类的典型用法代码示例。如果您正苦于以下问题:C++ TDes16类的具体用法?C++ TDes16怎么用?C++ TDes16使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TDes16类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: totalConverted
// -----------------------------------------------------------------------------
// JPLangUtil::ConvertFullHiragnaToFullKatakana
// Converts Full-width Hiragana and Special Character text found in
// aUnicodeSource to their Full-width counterparts and places the
// resulting text into aUnicodeTarget.
// -----------------------------------------------------------------------------
//
EXPORT_C TInt JPLangUtil::ConvertFullHiragnaToFullKatakana
( const TDesC16& aUnicodeSource, TDes16& aUnicodeTarget )
{
TInt totalConverted( 0 );
const TInt length( aUnicodeSource.Length() );
const TInt maxLength( aUnicodeTarget.MaxLength() );
if( length > maxLength )
{
return KErrTooBig;
}
const TUint comp = KFullWidthKatakanaSmallA - KFullWidthHiraganaSmallA;
aUnicodeTarget.Zero();
for( TInt i( 0 ); i < length; ++i )
{
const TText uniChar( aUnicodeSource[i] );
TText uniChar2(0);
if (i + 1 < length)
{
uniChar2 = aUnicodeSource[i+1];
}
// First check if this is this Full Width Katakana
if (KFullWidthHiraganaSmallA <= uniChar && uniChar <= KFullWidthHiraganaVU)
{
if (uniChar == KFullWidthHiraganaU
&& uniChar2 == KFullWidthHiraganaVoicedSound)
{
aUnicodeTarget.Append(KFullWidthKatakanaSmallVU);
totalConverted++;
i++;
}
else
{
TUint katakana = uniChar + comp;
if (IsKatakana(katakana))
{
aUnicodeTarget.Append(katakana);
totalConverted++;
}
}
}
else
{
aUnicodeTarget.Append(uniChar);
totalConverted++;
}
}
// Now handle special characters
// This logic may be moved into this function to avoid another loop over
// the text
totalConverted +=
UnicodeTextUtil::ConvertSpecialCharactersInPlace( EFullToHalfWidth,
aUnicodeTarget );
return totalConverted;
}
示例3: Value
void CBatmonContainer::Value(TUint8 aUnit,TUint16 aAddress,TDes16& aValue) const
{
TRAPD(err,HWNetmon::ValueL(aUnit,aAddress,aValue,HWNetmon::EExt|HWNetmon::ESigned));
if(err!=KErrNone)
{
aValue.Zero();
aValue.Append('?');
}
}
示例4: Externalize
TInt TEnvVar::Externalize(TDes16& aBuffer)
{
if (iName==0)
return 0;
aBuffer.Append(*iName);
aBuffer.Append(TChar(0));
aBuffer.Append(*iValue);
aBuffer.Append(TChar(0));
return 1;
}
示例5: ReadDes
EXPORT_C TInt CLANLinkCommon::ReadDes(const TDesC& aField, TDes16& aValue)
{
// Emulate reading of following parameters only:
// LAN_BEARER\LAN_BEARER_LDD_FILENAME
// LAN_BEARER\LAN_BEARER_LDD_NAME
// LAN_BEARER\LAN_BEARER_PDD_FILENAME
// LAN_BEARER\LAN_BEARER_PDD_NAME
_LIT(KLanBearer, "LANBearer\\");
const TInt KLanBearerTokenSize = 10;
TPtrC field(aField.Left(KLanBearerTokenSize)); // "LANBearer"
if (field.Compare(KLanBearer()) == 0)
{
_LIT(KLanBearerLddFilename, "LDDFilename");
_LIT(KLanBearerLddName, "LDDName");
_LIT(KLanBearerPddFilename, "PDDFilename");
_LIT(KLanBearerPddName, "PDDName");
field.Set(aField.Mid(KLanBearerTokenSize)); // skip "LANBearer\\"
if (field.CompareF(KLanBearerLddFilename) == 0)
{
aValue.Copy(LinkProvision().LddFilename());
}
else
if (field.CompareF(KLanBearerLddName) == 0)
{
aValue.Copy(LinkProvision().LddName());
}
else
if (field.CompareF(KLanBearerPddFilename) == 0)
{
aValue.Copy(LinkProvision().PddFilename());
}
else
if (field.CompareF(KLanBearerPddName) == 0)
{
aValue.Copy(LinkProvision().PddName());
}
else
{
return KErrNotSupported;
}
return KErrNone;
}
else
{
return KErrNotSupported;
}
}
示例6: DoReadDes
TInt CDummyNifAgentRef::DoReadDes(const TDesC& aField, TDes16& aValue,const RMessagePtr2* /*aMessage*/)
{
TInt result = KErrNotFound;
if (ipIniFileReader !=0)
{
TPtrC value;
if (ipIniFileReader->FindVar(iData.KCommDbSectionName,aField,value))
{
aValue.Copy(value);
result=KErrNone;
}
}
//use hardcoded only if the ini file read or search failed
if (KErrNotFound==result)
{
result=KErrNone;
//
if (TPtrC(KCDTypeNameRecordName)==aField)
aValue=iData.KPppCommdbName;
else if (iData.KModemPortString==aField)
aValue=iData.KPppPortString;
else if (iData.KModemCsyString==aField)
aValue=iData.KPppCsyString;
else
result=KErrNotFound;
}
//
LOG_ERR_PRINTF4(_L("--------------- Config param used: %S = %S (err %d)"),&aField,&aValue,result);
//
return result;
}
示例7: ConvertASCIIInPlace
// -----------------------------------------------------------------------------
// UnicodeTextUtil::ConvertASCIIInPlace
// Converts all ASCII *in-place* from either Half to Full-width or vice versa,
// depending on the direction specified by aDirection.
// Returns: The total number of characters converted.
// -----------------------------------------------------------------------------
//
TInt UnicodeTextUtil::ConvertASCIIInPlace( TConvDirection aDirection,
TDes16& aUnicodeText )
{
TInt totalConverted( 0 );
TText lowerBound( ( aDirection == EHalfToFullWidth ) ?
KHalfWidthASCIILowerBound :
KFullWidthASCIILowerBound );
TText upperBound( ( aDirection == EHalfToFullWidth ) ?
KHalfWidthASCIIUpperBound :
KFullWidthASCIIUpperBound );
TInt offset( ( aDirection == EHalfToFullWidth ) ?
KHalfToFullWidthASCIIOffset :
-KHalfToFullWidthASCIIOffset );
for( TInt i( 0 ); i < aUnicodeText.Length(); ++i )
{
const TText uniChar( aUnicodeText[i] );
if( uniChar >= lowerBound && uniChar <= upperBound )
{
TText convertedChar( static_cast<TText>( uniChar + offset ) );
aUnicodeText[i] = convertedChar;
totalConverted++;
}
}
return totalConverted;
}
示例8: 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;
}
示例9: 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++;
}
}
示例10: Tbuf16ToChar
/**
* 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;
}
示例11: WcharToTbuf16
EXPORT_C int WcharToTbuf16(const wchar_t* aSrc, TDes16& aDes)
{
unsigned int ilen = 0;
if ( !aSrc )
{
return EInvalidPointer;
}
else
{
ilen = wcslen(aSrc);
if(ilen > aDes.MaxLength())
{
return EInsufficientMemory;
}
}
aDes.Copy((const TUint16*)aSrc, ilen);
return ESuccess;
}
示例12:
void CT_KOI8R::Merge_Big(TDesC8& aSource, TDes16& aTarget)
{
TInt length = aSource.Length();
TInt i = 0;
for(i=0;i<length-1;i++)
{
TInt64 temp = *(aSource.Ptr()+(i))*16*16 + *(aSource.Ptr()+i+1);
aTarget.Append(temp);
i++;
}
}
示例13: FileNameGen
/** Generates a file name of the form FFFFF*<aPos>.TXT (aLong.3)
@param aBuffer The filename will be returned here
@param aLong Defines the longitude of the file name
@param aPos Defines the number that will be attached to the filename
*/
void FileNameGen(TDes16& aBuffer, TInt aLong, TInt aPos)
{
TInt padding;
TInt i=0;
TBuf16<10> tempbuf;
_LIT(KNumber,"%d");
tempbuf.Format(KNumber,aPos);
padding=aLong-tempbuf.Size()/2;
aBuffer=_L("");
while(i<padding)
{
aBuffer.Append('F');
i++;
}
aBuffer.Append(tempbuf);
_LIT(KExtension1, ".TXT");
aBuffer.Append(KExtension1);
}
示例14: Unicode_Big
//translate from unicode big endian TDesC8 to TDes16
void CT_TURKISHLOCKING::Unicode_Big(TDesC8& aSource, TDes16& aTarget)
{
TInt length = aSource.Length();
TInt i = 0;
for(i=0;i<length-1;i++)
{
TInt32 temp = *(aSource.Ptr()+(i))*16*16 + *(aSource.Ptr()+i+1);
aTarget.Append(temp);
i++;
}
}
示例15: WstringToTbuf16
EXPORT_C int WstringToTbuf16(wstring& aSrc, TDes16& aDes)
{
int retval = ESuccess;
const wchar_t* wcharString = aSrc.c_str();
if (L'\0' == wcharString[0])
{
return EStringNoData;
}
int len= wcslen(wcharString);
if ((wcslen(wcharString)) > aDes.MaxLength())
if (len > aDes.MaxLength())
{
return EInsufficientMemory;
}
aDes.Copy((const TUint16*)wcharString);
return retval;
}