本文整理汇总了C++中std::shared_ptr::AllowsRandomAccess方法的典型用法代码示例。如果您正苦于以下问题:C++ shared_ptr::AllowsRandomAccess方法的具体用法?C++ shared_ptr::AllowsRandomAccess怎么用?C++ shared_ptr::AllowsRandomAccess使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::shared_ptr
的用法示例。
在下文中一共展示了shared_ptr::AllowsRandomAccess方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
bool FileVEILOperationsImpl::StreamStartsWithCmsHeader(std::shared_ptr<IDataReader> stream, std::shared_ptr<ICmsHeaderBase>& pVal)
{
tscrypto::tsCryptoData contents;
std::shared_ptr<ICmsHeaderBase> header;
std::shared_ptr<tsmod::IObject> iunk;
int len;
int headerLen = 0;
int64_t fileLength;
if (stream == NULL)
return false;
fileLength = stream->DataLength();
if (fileLength > 20480)
len = 20480;
else
len = (int)fileLength;
stream->ReadData(len, contents);
if (contents.size() != (uint32_t)len)
{
return false;
}
if (!ExtractHeaderFromStream(contents.c_str(), len, &headerLen, iunk) ||
!(header = std::dynamic_pointer_cast<ICmsHeader>(iunk)) ||
headerLen == 0)
{
return false;
}
if (stream->AllowsRandomAccess())
{
stream->GoToPosition(headerLen);
}
pVal = header;
return true;
}
示例2: EncryptSignStream
bool FileVEILOperationsImpl::EncryptSignStream(std::shared_ptr<IDataReader> inputData, std::shared_ptr<IDataWriter> outputData, std::shared_ptr<ICmsHeader> Header, CompressionType comp, TS_ALG_ID algorithm,
TS_ALG_ID hashAlgorithm, bool SignHeader, bool bindData, CMSFileFormatIds DataFormat, bool randomIvec, SymmetricPaddingType paddingType, int blockSize)
{
TSDECLARE_FUNCTIONExt(true);
std::shared_ptr<ICmsHeaderBase> header2;
std::shared_ptr<ICmsHeader> header7;
std::shared_ptr<IKeyGenCallback> callback;
int64_t fileSize = 0;
if (Header == NULL)
{
LogError("The CKM Header is missing.");
return TSRETURN_ERROR(("Bad Header"), false);
}
if (!Header->DuplicateHeader(header2))
{
LogError("The specified CKM Header is incomplete or invalid.");
return TSRETURN_ERROR(("Bad Header"), false);
}
if (!(header7 = std::dynamic_pointer_cast<ICmsHeader>(header2)))
{
LogError("The specified CKM Header is incomplete or invalid.");
return TSRETURN_ERROR(("Bad Header"), false);
}
//
// Now get the length of the source file
//
if (inputData->AllowsRandomAccess())
fileSize = inputData->DataLength();
else
fileSize = -1;
if (!PrepareHeader(header7, comp, algorithm, hashAlgorithm, SignHeader, bindData, DataFormat, randomIvec, paddingType, blockSize, fileSize))
{
LogError("The specified CKM Header could not be prepared for key generation.");
return TSRETURN_ERROR(("Bad Header"), false);
}
// CkmDevOnly << "Header after prepare" << endl << indent << TSHeaderToString(header7) << endl << outdent;
#ifdef HAVE_BSTR
// TODO: Implement Linux mime support here - libmagic
{
tscrypto::tsCryptoData tmp;
CryptoUtf16 tmpBstr(inputData->DataName());
LPWSTR mime = NULL;
if (inputData->PeekData(4096, tmp))
{
if (FindMimeFromData(NULL, tmpBstr.c_str(), tmp.rawData(), (DWORD)tmp.size(), NULL, 3 /*FMFD_ENABLEMIMESNIFFING | FMFD_URLASFILENAME*/, &mime, 0) >= 0)
{
if (mime != NULL && mime[0] != 0)
{
header7->SetMimeType(CryptoUtf16(mime).toUtf8());
}
}
}
}
#endif // HAVE_BSTR
std::shared_ptr<ICryptoHelper> helper;
if (!m_session && header7->NeedsSession())
{
if (!!m_sessionCallback)
{
if (!(m_sessionCallback->GetSessionForHeader(true, header2, 0, m_session)))
{
LogError("No session.");
return TSRETURN_ERROR(("Returns ~~"), false);
}
}
}
if (!m_session)
{
LogError("Unable to retrieve the cryptographic helper object from the CKM Runtime.");
return TSRETURN_ERROR(("Returns ~~"), false);
}
else
{
if (!(helper = CreateCryptoHelper(m_session)))
{
LogError("Unable to generate the working key and encrypted data - Unable to create the helper.");
return TSRETURN_ERROR(("Unable to generate the working key and encrypted data."), false);
}
}
helper->SetOperationStatusCallback(m_status);
helper->SetTaskInformation(m_currentTask, m_taskCount);
if (!!m_keyGenCallback)
helper->SetKeyGenCallback(m_keyGenCallback);
if (!header7->SetDataName(inputData->DataName().c_str()))
{
LOG(DebugInfo1, "WARNING: Unable to save the original file name. Continuing to process the file.\n");
}
//.........这里部分代码省略.........