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


C++ OTData::Release方法代码示例

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


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

示例1: GetData

// This function will base64 DECODE the string contents
// and return them as binary in theData
bool OTASCIIArmor::GetData(OTData & theData, bool bLineBreaks) const //linebreaks=true
{	
	return GetAndUnpackData(theData, bLineBreaks);
	
	
	
	size_t		outSize	= 0;
	uint8_t *	pData	= NULL;
	
	theData.Release();
	
	if (GetLength() < 1)
		return true;
	
	pData = OT_base64_decode(Get(), &outSize, (bLineBreaks ? 1 : 0));
	
	if (pData)
	{
		theData.Assign(pData, outSize);
		delete [] pData; pData=NULL;
		return true;
	}
	else 
	{
		OTLog::Error("Error while base64_decoding in OTASCIIArmor::GetData.\n");
		return false;
	}
}
开发者ID:DOUGLASMENDES,项目名称:Open-Transactions,代码行数:30,代码来源:OTASCIIArmor.cpp

示例2: GetData

// Base64-decode
bool OTASCIIArmor::GetData(OTData& theData,
                           bool bLineBreaks) const // linebreaks=true
{
    theData.Release();

    if (GetLength() < 1) return true;

    size_t outSize = 0;
    uint8_t* pData = App::Me().Crypto().Util().Base64Decode(Get(), &outSize, bLineBreaks);

    // Some versions of OpenSSL will handle input without line breaks when bLineBreaks is true,
    // other versions of OpenSSL will return a zero-length output.
    //
    // Functions which call this method do not always know the correct value for bLineBreaks, since
    // the input may be too short to warrant a line break.
    //
    // To make this funciton less fragile, if the first attempt does not result in the expected
    // output, try again with the opposite value set for bLineBreaks.
    if (!pData||(0==outSize)) {
        pData = App::Me().Crypto().Util().Base64Decode(Get(), &outSize, !bLineBreaks);
        if (!pData||(0==outSize)) {
            otErr << __FUNCTION__ << "Base64Decode fail\n";
            return false;
        }
    }
    theData.Assign(pData, outSize);
    delete[] pData;
    return true;
}
开发者ID:Kodachi75,项目名称:opentxs,代码行数:30,代码来源:OTASCIIArmor.cpp

示例3: GetAndUnpackData

// This function will base64 DECODE the string contents
// and return them as binary in theData
// Additionally it will decompress and unpack the data!
//
bool OTASCIIArmor::GetAndUnpackData(OTData & theData, bool bLineBreaks) const //linebreaks=true
{	
	size_t		outSize	= 0;
	uint8_t *	pData	= NULL;
	
	theData.Release();
	
	if (GetLength() < 1)
		return true;
	
	// --------------------------------------------------------------
	//
	pData = OT_base64_decode(Get(), &outSize, (bLineBreaks ? 1 : 0));
	
	if (pData)
	{
		// --------------------------------------------------------
		
		OTDB::OTPacker * pPacker = OTASCIIArmor::GetPacker(); // No need to check for failure, since this already ASSERTS. No need to cleanup either.
		
		OTDB::PackedBuffer * pBuffer = pPacker->CreateBuffer(); // Need to clean this up.
		OT_ASSERT(NULL != pBuffer);
		OTCleanup<OTDB::PackedBuffer> theBufferAngel(*pBuffer); // make sure buffer is deleted.
		
		pBuffer->SetData(static_cast<const unsigned char*>(pData), outSize);
		delete [] pData; pData=NULL; 
		// -----------------------------
		
		OTDB::Blob * pBlob = dynamic_cast<OTDB::Blob *>(OTDB::CreateObject(OTDB::STORED_OBJ_BLOB));
		OT_ASSERT(NULL != pBlob);
		OTCleanup<OTDB::Blob> theBlobAngel(*pBlob); // clean up this blob.
		
		bool bUnpacked = pPacker->Unpack(*pBuffer, *pBlob);
		
		// ----------------------
		
		if (false == bUnpacked)
		{
			OTLog::Error("Failed unpacking data in OTASCIIArmor::GetAndUnpackData.\n");
			delete [] pData; pData=NULL;
			return false;
		}
		
		// --------------------------------------------------------
		
		theData.Assign(pBlob->m_memBuffer.data(), pBlob->m_memBuffer.size());
		delete [] pData; pData=NULL;
		return true;
	}
	else 
	{
		OTLog::Error("Error while base64_decoding in OTASCIIArmor::GetAndUnpackData.\n");
		return false;
	}
}
开发者ID:DOUGLASMENDES,项目名称:Open-Transactions,代码行数:59,代码来源:OTASCIIArmor.cpp


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