本文整理汇总了C++中OTData::IsEmpty方法的典型用法代码示例。如果您正苦于以下问题:C++ OTData::IsEmpty方法的具体用法?C++ OTData::IsEmpty怎么用?C++ OTData::IsEmpty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OTData
的用法示例。
在下文中一共展示了OTData::IsEmpty方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Assign
void OTData::Assign(const OTData &theSource)
{
if ((&theSource) == this)
return; // can't assign to self.
if (false == theSource.IsEmpty()) // If something is there...
{
Assign(theSource.m_pData, theSource.m_lSize); // Copy it.
}
else
Release(); // Otherwise if it's empty, then empty this also.
}
示例2: Assign
void OTData::Assign(const OTData& source)
{
// can't assign to self.
if (&source == this) {
return;
}
if (!source.IsEmpty()) {
Assign(source.data_, source.size_);
}
else {
// Otherwise if it's empty, then empty this also.
Release();
}
}
示例3: Windows_StoreSecret
// static
bool OTKeyring::Windows_StoreSecret(const OTString& strUser,
const OTPassword& thePassword,
const std::string& str_display)
{
OT_ASSERT(strUser.Exists());
OT_ASSERT(thePassword.getMemorySize() > 0);
DATA_BLOB input;
input.pbData = const_cast<BYTE*>(
reinterpret_cast<const BYTE*>(thePassword.getMemory()));
input.cbData = static_cast<DWORD>(thePassword.getMemorySize());
// CRYPTPROTECT_PROMPTSTRUCT PromptStruct;
// ZeroMemory(&PromptStruct, sizeof(PromptStruct));
// PromptStruct.cbSize = sizeof(PromptStruct);
// PromptStruct.dwPromptFlags = CRYPTPROTECT_PROMPT_ON_PROTECT;
// PromptStruct.szPrompt = L"This is a user prompt.";
DATA_BLOB output;
BOOL result = CryptProtectData(&input, L"", // description string
nullptr, // optional entropy
nullptr, // reserved
nullptr, //&PromptStruct
0, &output);
if (!result) {
otErr << __FUNCTION__ << ": Failed calling Win32: CryptProtectData \n";
return false;
}
//
// this does a copy
//
// std::string ciphertext;
// ciphertext.assign(reinterpret_cast<std::string::value_type*>(output.pbData),
// output.cbData);
OTData theOutput;
theOutput.Assign(static_cast<void*>(output.pbData),
static_cast<uint32_t>(output.cbData));
LocalFree(output.pbData); // Note: should have a check for nullptr here... ?
// And above...
// Success encrypting to ciphertext (std::string or OTData)
//
// Write it to local storage.
//
if (theOutput.IsEmpty()) {
otErr << __FUNCTION__
<< ": Error: Output of Win32 CryptProtectData was empty.\n";
}
else {
OTASCIIArmor ascData(theOutput);
const OTString strFoldername("win32_data"); // todo hardcoding.
if (ascData.Exists())
return ascData.WriteArmoredFile(strFoldername,
strUser, // this is filename
"WINDOWS KEYRING MASTERKEY");
}
return false;
}