本文整理汇总了C++中BookModel::internalHyperlinks方法的典型用法代码示例。如果您正苦于以下问题:C++ BookModel::internalHyperlinks方法的具体用法?C++ BookModel::internalHyperlinks怎么用?C++ BookModel::internalHyperlinks使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BookModel
的用法示例。
在下文中一共展示了BookModel::internalHyperlinks方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: initInternalHyperlinks
static bool initInternalHyperlinks(JNIEnv *env, jobject javaModel, BookModel &model) {
ZLCachedMemoryAllocator allocator(131072, Library::Instance().cacheDirectory(), "nlinks");
ZLUnicodeUtil::Ucs2String ucs2id;
ZLUnicodeUtil::Ucs2String ucs2modelId;
const std::map<std::string,BookModel::Label> &links = model.internalHyperlinks();
std::map<std::string,BookModel::Label>::const_iterator it = links.begin();
for (; it != links.end(); ++it) {
const std::string &id = it->first;
const BookModel::Label &label = it->second;
if (label.Model.isNull()) {
continue;
}
ZLUnicodeUtil::utf8ToUcs2(ucs2id, id);
ZLUnicodeUtil::utf8ToUcs2(ucs2modelId, label.Model->id());
const std::size_t idLen = ucs2id.size() * 2;
const std::size_t modelIdLen = ucs2modelId.size() * 2;
char *ptr = allocator.allocate(idLen + modelIdLen + 8);
ZLCachedMemoryAllocator::writeUInt16(ptr, ucs2id.size());
ptr += 2;
std::memcpy(ptr, &ucs2id.front(), idLen);
ptr += idLen;
ZLCachedMemoryAllocator::writeUInt16(ptr, ucs2modelId.size());
ptr += 2;
std::memcpy(ptr, &ucs2modelId.front(), modelIdLen);
ptr += modelIdLen;
ZLCachedMemoryAllocator::writeUInt32(ptr, label.ParagraphNumber);
}
allocator.flush();
jstring linksDirectoryName = env->NewStringUTF(allocator.directoryName().c_str());
jstring linksFileExtension = env->NewStringUTF(allocator.fileExtension().c_str());
jint linksBlocksNumber = allocator.blocksNumber();
AndroidUtil::Method_NativeBookModel_initInternalHyperlinks->call(javaModel, linksDirectoryName, linksFileExtension, linksBlocksNumber);
env->DeleteLocalRef(linksDirectoryName);
env->DeleteLocalRef(linksFileExtension);
return !env->ExceptionCheck();
}