本文整理汇总了C++中MojString::base64Encode方法的典型用法代码示例。如果您正苦于以下问题:C++ MojString::base64Encode方法的具体用法?C++ MojString::base64Encode怎么用?C++ MojString::base64Encode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MojString
的用法示例。
在下文中一共展示了MojString::base64Encode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: id
MojErr MojDbIdGenerator::id(MojObject& idOut)
{
// an id consists of a timestamp (in microsecs) concatenated with a 32-bit random number.
// The goal is to have a very low likelihood of id collision among multiple devices owned
// by the same user (so they can can share an id-space) while still keeping them sequential
// to minimize db fragmentation.
MojThreadGuard guard(m_mutex);
MojUInt32 randNum;
MojErr err = MojRandom(&m_randBuf, &randNum);
MojErrCheck(err);
guard.unlock();
MojTime time;
err = MojGetCurrentTime(time);
MojErrCheck(err);
MojBuffer buf;
MojDataWriter writer(buf);
err = writer.writeInt64(time.microsecs());
MojErrCheck(err);
err = writer.writeUInt32(randNum);
MojErrCheck(err);
MojVector<MojByte> byteVec;
err = buf.toByteVec(byteVec);
MojErrCheck(err);
MojString str;
err = str.base64Encode(byteVec, false);
MojErrCheck(err);
idOut = str;
return MojErrNone;
}
示例2:
MojErr MojDbQuery::Page::toObject(MojObject& objOut) const
{
MojString str;
MojErr err = str.base64Encode(m_key.byteVec(), false);
MojErrCheck(err);
objOut = str;
return MojErrNone;
}