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


C++ RBuf8::SetLength方法代码示例

本文整理汇总了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;
}
开发者ID:kuailexs,项目名称:symbiandump-os1,代码行数:55,代码来源:asn1peroctetstring.cpp

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


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