本文整理汇总了C++中RBuf8::SetLength方法的典型用法代码示例。如果您正苦于以下问题:C++ RBuf8::SetLength方法的具体用法?C++ RBuf8::SetLength怎么用?C++ RBuf8::SetLength使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RBuf8
的用法示例。
在下文中一共展示了RBuf8::SetLength方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void CAsn1PerOctetString::DecodeL(const TDesC8& aBuf,
const TInt aStartBit,
const TBool aLengthIsVariable,
const TBool aLengthIsConstrained,
const TInt aMinLength,
const TInt aMaxLength,
const TBool aIsExtensible,
const TBool /*aIsPadded*/,
TBool& aIsExtended,
TInt& aBitsDecoded,
RBuf8& aDecodedBuf)
{
TInt currentBitPos=aStartBit;
TInt bitDecoded=0;
aBitsDecoded=0;
aIsExtended=EFalse;
TInt stringLen=0;
CAsn1PerUtil::DecodeStringEBitAndLengthL(aBuf,
currentBitPos,
aLengthIsVariable,
aLengthIsConstrained,
aMinLength,
aMaxLength,
aIsExtensible,
aIsExtended,
bitDecoded,
stringLen);
currentBitPos+=bitDecoded;
aBitsDecoded+=bitDecoded;
bitDecoded=0;
//check if the input buffer is long enough
if (currentBitPos+stringLen*8>aBuf.Length()*8)
{
User::Leave(KErrUnderflow);
}
//Finally, decode the string content for cases
aDecodedBuf.ReAllocL(stringLen);
aDecodedBuf.SetLength(stringLen);
aDecodedBuf.FillZ();
TInt stringBitLength=stringLen*8;
//Copy the String to the Dest Buffer .
TInt destBitNum=8;
TInt destOctetNum=0;
//Copy ...
CAsn1PerUtil::CopyDataTrunkL(aBuf, currentBitPos, stringBitLength, aDecodedBuf, destOctetNum, destBitNum);
aBitsDecoded+=stringBitLength;
}
示例2: CreateVerifyFileX
//.........这里部分代码省略.........
file.Close();
return(r);
}
TInt i;
if (aPattern)
{
// ascending pattern
for (i = 0; i < KCreateFileBufSize; i++)
{
wBuf[i] = (TUint8) i;
}
}
else
{
// descending pattern
for (i = 0; i < KCreateFileBufSize; i++)
{
wBuf[i] = (TUint8) ((KCreateFileBufSize - 1) - i);
}
}
TInt pos;
TInt chunkSize;
TInt sectorCount = 0;
for (pos = 0; pos < aSize; pos += chunkSize)
{
wBuf[0]=(TUint8)i; // Insert sector count
chunkSize = Min((aSize-pos), KCreateFileBufSize);
r = file.Write(pos, wBuf, chunkSize);
if (r != KErrNone)
{
LogError(r, KWrite, aFileName, pos, chunkSize, __LINE__);
file.Close();
wBuf.Close();
return(r);
}
sectorCount++;
}
// Flush it
r=file.Flush();
if (r!=KErrNone)
{
LogError( r, KFlush, aFileName, 0, 0, __LINE__);
file.Close();
wBuf.Close();
return(r);
}
// Test still works if this is commented out just doesn't verify
// Read back and verify it
RBuf8 rBuf;
r = rBuf.CreateMax(KCreateFileBufSize);
if(r != KErrNone)
{
LogError( r, KMemory, aFileName, 0, 0, __LINE__);
file.Close();
wBuf.Close();
rBuf.Close();
return(KErrGeneral);
}
for (pos = 0;pos < aSize; pos += chunkSize)
{
chunkSize = Min((aSize-pos), KCreateFileBufSize);
r = file.Read(pos, rBuf, chunkSize);
if (r != KErrNone)
{
LogError(r, KRead, aFileName, pos, 0, __LINE__);
file.Close();
wBuf.Close();
rBuf.Close();
return(r);
}
wBuf[0] = (TUint8) i; // Insert sector count
wBuf.SetLength(chunkSize);
r = rBuf.Compare(wBuf);
if (r != 0)
{
LogError(r, KDataCompare, aFileName, 0, 0, __LINE__);
file.Close();
wBuf.Close();
rBuf.Close();
return(KErrGeneral);
}
}
//
file.Close();
wBuf.Close();
rBuf.Close();
return(KErrNone);
}