本文整理汇总了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;
}
}
示例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;
}
示例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;
}
}