本文整理汇总了C++中Blob::assign方法的典型用法代码示例。如果您正苦于以下问题:C++ Blob::assign方法的具体用法?C++ Blob::assign怎么用?C++ Blob::assign使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Blob
的用法示例。
在下文中一共展示了Blob::assign方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: bignum_error
bool Base58::decode (const char* psz, Blob& vchRet, Alphabet const& alphabet)
{
CAutoBN_CTX pctx;
vchRet.clear ();
CBigNum bn58 = 58;
CBigNum bn = 0;
CBigNum bnChar;
while (isspace (*psz))
psz++;
// Convert big endian string to bignum
for (const char* p = psz; *p; p++)
{
// VFALCO TODO Make this use the inverse table!
// Or better yet ditch this and call raw_decode
//
const char* p1 = strchr (alphabet.chars(), *p);
if (p1 == nullptr)
{
while (isspace (*p))
p++;
if (*p != '\0')
return false;
break;
}
bnChar.setuint (p1 - alphabet.chars());
if (!BN_mul (&bn, &bn, &bn58, pctx))
throw bignum_error ("DecodeBase58 : BN_mul failed");
bn += bnChar;
}
// Get bignum as little endian data
Blob vchTmp = bn.getvch ();
// Trim off sign byte if present
if (vchTmp.size () >= 2 && vchTmp.end ()[-1] == 0 && vchTmp.end ()[-2] >= 0x80)
vchTmp.erase (vchTmp.end () - 1);
// Restore leading zeros
int nLeadingZeros = 0;
for (const char* p = psz; *p == alphabet.chars()[0]; p++)
nLeadingZeros++;
vchRet.assign (nLeadingZeros + vchTmp.size (), 0);
// Convert little endian data to big endian
std::reverse_copy (vchTmp.begin (), vchTmp.end (), vchRet.end () - vchTmp.size ());
return true;
}
示例2: getBlob
void getBlob(const MYSQL_BIND& bind, Blob& ret)
{
if (isNull(bind))
throw NullValue();
switch (bind.buffer_type)
{
case MYSQL_TYPE_STRING:
case MYSQL_TYPE_VAR_STRING:
case MYSQL_TYPE_TINY_BLOB:
case MYSQL_TYPE_BLOB:
case MYSQL_TYPE_MEDIUM_BLOB:
case MYSQL_TYPE_LONG_BLOB:
ret.assign(static_cast<const char*>(bind.buffer),
*bind.length);
break;
default:
log_error("type-error in getBlob, type=" << bind.buffer_type);
throw TypeError("type-error in getBlob");
}
}
示例3: getBlob
void ValueImpl::getBlob(Blob& ret) const
{
if (null)
throw NullValue();
ret.assign(data.data(), data.size());
}
示例4: getBlob
void RowValue::getBlob(Blob& ret) const
{
ret.assign(row[col], len);
}