• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ ZLInputStream类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中ZLInputStream的典型用法代码示例。如果您正苦于以下问题:C++ ZLInputStream类的具体用法?C++ ZLInputStream怎么用?C++ ZLInputStream使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了ZLInputStream类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: detectLanguage

void FormatPlugin::detectLanguage(Book &book, ZLInputStream &stream) {
	std::string language = book.language();
	if (!language.empty()) {
		return;
	}

	PluginCollection &collection = PluginCollection::Instance();
	if (language.empty()) {
		language = collection.DefaultLanguageOption.value();
	}
	if (collection.LanguageAutoDetectOption.value() && stream.open()) {
		static const int BUFSIZE = 65536;
		char *buffer = new char[BUFSIZE];
		const size_t size = stream.read(buffer, BUFSIZE);
		stream.close();
		shared_ptr<ZLLanguageDetector::LanguageInfo> info =
			ZLLanguageDetector().findInfo(buffer, size);
		delete[] buffer;
		if (!info.isNull()) {
			if (!info->Language.empty()) {
				language = info->Language;
			}
		}
	}
	book.setLanguage(language);
}
开发者ID:OpenInkpot-archive,项目名称:fbreader,代码行数:26,代码来源:FormatPlugin.cpp


示例2: readDocumentInternal

void EReaderPlugin::readDocumentInternal(const ZLFile &file, BookModel &model, const PlainTextFormat &format, const std::string &encoding, ZLInputStream &stream) const {
	if (!stream.open())	{
		//TODO maybe anything else opens stream
		return;
	}
	BookReader bookReader(model);
	PmlBookReader pmlBookReader(bookReader, format, encoding);
	bookReader.setMainTextModel();
	pmlBookReader.readDocument(stream);
	EReaderStream &estream = (EReaderStream&)stream;
	const std::map<std::string, EReaderStream::ImageInfo>& imageIds = estream.images();
	for(std::map<std::string, EReaderStream::ImageInfo>::const_iterator it = imageIds.begin(); it != imageIds.end(); ++it) {
		const std::string id = it->first;
		bookReader.addImage(id, new ZLFileImage(ZLFile(file.path(), it->second.Type), it->second.Offset, it->second.Size));
	}
	const std::map<std::string, unsigned short>& footnoteIds = estream.footnotes();
	for(std::map<std::string, unsigned short>::const_iterator it = footnoteIds.begin(); it != footnoteIds.end(); ++it) {
		const std::string id = it->first;
		if (estream.switchStreamDestination(EReaderStream::FOOTNOTE, id)) {
			bookReader.setFootnoteTextModel(id);
			bookReader.addHyperlinkLabel(id);
			pmlBookReader.readDocument(estream);
		}
	}
	stream.close();
}
开发者ID:euroelessar,项目名称:FBReader,代码行数:26,代码来源:EReaderPlugin.cpp


示例3: detectLanguage

bool FormatPlugin::detectLanguage(Book &book, ZLInputStream &stream, const std::string &encoding, bool force) {
	std::string language = book.language();
	if (!force && !language.empty()) {
		return true;
	}

	bool detected = false;

	PluginCollection &collection = PluginCollection::Instance();
	if (collection.isLanguageAutoDetectEnabled() && stream.open()) {
		static const int BUFSIZE = 65536;
		char *buffer = new char[BUFSIZE];
		const std::size_t size = stream.read(buffer, BUFSIZE);
		stream.close();
		shared_ptr<ZLLanguageDetector::LanguageInfo> info =
			ZLLanguageDetector().findInfoForEncoding(encoding, buffer, size, -20000);
		delete[] buffer;
		if (!info.isNull()) {
			detected = true;
			if (!info->Language.empty()) {
				language = info->Language;
			}
		}
	}
	book.setLanguage(language);

	return detected;
}
开发者ID:04k,项目名称:FBReaderJ,代码行数:28,代码来源:FormatPlugin.cpp


示例4: myContainerName

ZLZipEntryCache::ZLZipEntryCache(const std::string &containerName, ZLInputStream &containerStream) : myContainerName(containerName) {
	//ZLLogger::Instance().println("ZipEntryCache", "creating cache for " + containerName);
	myLastModifiedTime = ZLFile(containerName).lastModified();
	if (!containerStream.open()) {
		return;
	}

	ZLZipHeader header;
	while (header.readFrom(containerStream)) {
		Info *infoPtr = 0;
		if (header.Signature == (unsigned long)ZLZipHeader::SignatureLocalFile) {
			std::string entryName(header.NameLength, '\0');
			if ((unsigned int)containerStream.read((char*)entryName.data(), header.NameLength) == header.NameLength) {
				entryName = AndroidUtil::convertNonUtfString(entryName);
				Info &info = myInfoMap[entryName];
				info.Offset = containerStream.offset() + header.ExtraLength;
				info.CompressionMethod = header.CompressionMethod;
				info.CompressedSize = header.CompressedSize;
				info.UncompressedSize = header.UncompressedSize;
				infoPtr = &info;
			}
		}
		ZLZipHeader::skipEntry(containerStream, header);
		if (infoPtr != 0) {
			infoPtr->UncompressedSize = header.UncompressedSize;
		}
	}
	containerStream.close();
}
开发者ID:ALEXGUOQ,项目名称:FBReaderJ,代码行数:29,代码来源:ZLZipEntryCache.cpp


示例5: entryName

ZLZipEntryCache::ZLZipEntryCache(ZLInputStream &baseStream) {
	if (!baseStream.open()) {
		return;
	}

	ZLZipHeader header;
	while (header.readFrom(baseStream)) {
		Info *infoPtr = 0;
		if (header.Signature == ZLZipHeader::SignatureLocalFile) {
			std::string entryName(header.NameLength, '\0');
			if ((unsigned int)baseStream.read((char*)entryName.data(), header.NameLength) == header.NameLength) {
				Info &info = myInfoMap[entryName];
				info.Offset = baseStream.offset() + header.ExtraLength;
				info.CompressionMethod = header.CompressionMethod;
				info.CompressedSize = header.CompressedSize;
				info.UncompressedSize = header.UncompressedSize;
				infoPtr = &info;
			}
		}
		ZLZipHeader::skipEntry(baseStream, header);
		if (infoPtr != 0) {
			infoPtr->UncompressedSize = header.UncompressedSize;
		}
	}
	baseStream.close();
}
开发者ID:ALEXGUOQ,项目名称:FBReader,代码行数:26,代码来源:ZLZipEntryCache.cpp


示例6: detectEncodingAndLanguage

void FormatPlugin::detectEncodingAndLanguage(Book &book, ZLInputStream &stream) {
	std::string language = book.language();
	std::string encoding = book.encoding();
	if (!encoding.empty() && !language.empty()) {
		return;
	}

	PluginCollection &collection = PluginCollection::Instance();
	if (language.empty()) {
		language = collection.DefaultLanguageOption.value();
	}
	if (encoding.empty()) {
		encoding = collection.DefaultEncodingOption.value();
	}
	if (collection.LanguageAutoDetectOption.value() && stream.open()) {
		static const int BUFSIZE = 65536;
		char *buffer = new char[BUFSIZE];
		const size_t size = stream.read(buffer, BUFSIZE);
		stream.close();
		shared_ptr<ZLLanguageDetector::LanguageInfo> info =
			ZLLanguageDetector().findInfo(buffer, size);
		delete[] buffer;
		if (!info.isNull()) {
			if (!info->Language.empty()) {
				language = info->Language;
			}
			encoding = info->Encoding;
			if ((encoding == "US-ASCII") || (encoding == "ISO-8859-1")) {
				encoding = "windows-1252";
			}
		}
	}
	book.setEncoding(encoding);
	book.setLanguage(language);
}
开发者ID:OpenInkpot-archive,项目名称:fbreader,代码行数:35,代码来源:FormatPlugin.cpp


示例7: readFrom

bool ZLZipHeader::readFrom(ZLInputStream &stream) {
	size_t startOffset = stream.offset();
	Signature = readLong(stream);
	switch (Signature) {
		default:
			return false;
		case SignatureLocalFile:
			Version = readShort(stream);
			Flags = readShort(stream);
			CompressionMethod = readShort(stream);
			ModificationTime = readShort(stream);
			ModificationDate = readShort(stream);
			CRC32 = readLong(stream);
			CompressedSize = readLong(stream);
			UncompressedSize = readLong(stream);
			if (CompressionMethod == 0 && CompressedSize != UncompressedSize) {
				ZLLogger::Instance().println("zip", "Different compressed & uncompressed size for stored entry; the uncompressed one will be used.");
				CompressedSize = UncompressedSize;
			}
			NameLength = readShort(stream);
			ExtraLength = readShort(stream);
			return stream.offset() == startOffset + 30 && NameLength != 0;
		case SignatureData:
			CRC32 = readLong(stream);
			CompressedSize = readLong(stream);
			UncompressedSize = readLong(stream);
			NameLength = 0;
			ExtraLength = 0;
			return stream.offset() == startOffset + 16;
	}
}
开发者ID:raghavkc,项目名称:fbreaderj2,代码行数:31,代码来源:ZLZipHeader.cpp


示例8: readDocument

void TxtReader::readDocument(ZLInputStream &stream) {
	if (!stream.open()) {
		return;
	}
	startDocumentHandler();
	myCore->readDocument(stream);
	endDocumentHandler();
	stream.close();
}
开发者ID:37Jayden,项目名称:bho,代码行数:9,代码来源:TxtReader.cpp


示例9: readDocumentInternal

void PalmDocPlugin::readDocumentInternal(const ZLFile &file, BookModel &model, const PlainTextFormat &format, const std::string &encoding, ZLInputStream &stream) const {
	stream.open();
	bool readAsPalmDoc = ((PalmDocStream&)stream).hasExtraSections();
	stream.close();
	if (readAsPalmDoc) {
		MobipocketHtmlBookReader(file, model, format, encoding).readDocument(stream);
	} else {
		SimplePdbPlugin::readDocumentInternal(file, model, format, encoding, stream);
	}
}
开发者ID:euroelessar,项目名称:FBReader,代码行数:10,代码来源:PalmDocPlugin.cpp


示例10: readFrom

bool ZLZipHeader::readFrom(ZLInputStream &stream) {
	std::size_t startOffset = stream.offset();
	Signature = readLong(stream);
	switch (Signature) {
		default:
			return stream.offset() == startOffset + 4;
		case SignatureCentralDirectory:
		{
			Version = readLong(stream);
			Flags = readShort(stream);
			CompressionMethod = readShort(stream);
			ModificationTime = readShort(stream);
			ModificationDate = readShort(stream);
			CRC32 = readLong(stream);
			CompressedSize = readLong(stream);
			UncompressedSize = readLong(stream);
			if (CompressionMethod == 0 && CompressedSize != UncompressedSize) {
				ZLLogger::Instance().println("zip", "Different compressed & uncompressed size for stored entry; the uncompressed one will be used.");
				CompressedSize = UncompressedSize;
			}
			NameLength = readShort(stream);
			ExtraLength = readShort(stream);
			const unsigned short toSkip = readShort(stream);
			stream.seek(12 + NameLength + ExtraLength + toSkip, false);
			return stream.offset() == startOffset + 42 + NameLength + ExtraLength + toSkip;
		}
		case SignatureLocalFile:
			Version = readShort(stream);
			Flags = readShort(stream);
			CompressionMethod = readShort(stream);
			ModificationTime = readShort(stream);
			ModificationDate = readShort(stream);
			CRC32 = readLong(stream);
			CompressedSize = readLong(stream);
			UncompressedSize = readLong(stream);
			if (CompressionMethod == 0 && CompressedSize != UncompressedSize) {
				ZLLogger::Instance().println("zip", "Different compressed & uncompressed size for stored entry; the uncompressed one will be used.");
				CompressedSize = UncompressedSize;
			}
			NameLength = readShort(stream);
			ExtraLength = readShort(stream);
			return stream.offset() == startOffset + 30 && NameLength != 0;
		case SignatureEndOfCentralDirectory:
		{
			stream.seek(16, false);
			const unsigned short toSkip = readShort(stream);
			stream.seek(toSkip, false);
			UncompressedSize = 0;
			return stream.offset() == startOffset + 18 + toSkip;
		}
		case SignatureData:
			CRC32 = readLong(stream);
			CompressedSize = readLong(stream);
			UncompressedSize = readLong(stream);
			NameLength = 0;
			ExtraLength = 0;
			return stream.offset() == startOffset + 16;
	}
}
开发者ID:MastAvalons,项目名称:FBReaderJ,代码行数:59,代码来源:ZLZipHeader.cpp


示例11: skipEntry

void ZLZipHeader::skipEntry(ZLInputStream &stream, const ZLZipHeader &header) {
	if (header.Flags & 0x08) {
		stream.seek(header.ExtraLength);
		ZLZDecompressor decompressor((size_t)-1);
		while (decompressor.decompress(stream, 0, 2048) == 2048) {
		}
		stream.seek(16);
	} else {
		stream.seek(header.ExtraLength + header.CompressedSize);
	}
}
开发者ID:xufooo,项目名称:fbreader-e2-test,代码行数:11,代码来源:ZLZipHeader.cpp


示例12: readDocument

void TxtReader::readDocument(ZLInputStream &stream) {
	if (!stream.open()) {
		return;
	}

	startDocumentHandler();

	const size_t BUFSIZE = 2048;
	char *buffer = new char[BUFSIZE];
	std::string str;
	size_t length;
	do {
		length = stream.read(buffer, BUFSIZE);
		char *start = buffer;
		const char *end = buffer + length;
		for (char *ptr = start; ptr != end; ++ptr) {
			if (*ptr == '\n' || *ptr == '\r') {
				bool skipNewLine = false;
				if (*ptr == '\r' && (ptr + 1) != end && *(ptr + 1) == '\n') {
					skipNewLine = true;
					*ptr = '\n';
				}
				if (start != ptr) {
					str.erase();
					myConverter->convert(str, start, ptr + 1);
					characterDataHandler(str);
				}
				if (skipNewLine) {
					++ptr;
				}
				start = ptr + 1;
				newLineHandler();
			} else if (isspace((unsigned char)*ptr)) {
				if (*ptr != '\t') {
					*ptr = ' ';
				}
			} else {
			}
		}
		if (start != end) {
			str.erase();
			myConverter->convert(str, start, end);
			characterDataHandler(str);
		}
	} while (length == BUFSIZE);
	delete[] buffer;

	endDocumentHandler();

	stream.close();
}
开发者ID:chenhbzl,项目名称:BooxApp,代码行数:51,代码来源:TxtReader.cpp


示例13: parse

void StyleSheetParser::parse(ZLInputStream &stream) {
	if (stream.open()) {
		char *buffer = new char[1024];
		while (true) {
			int len = stream.read(buffer, 1024);
			if (len == 0) {
				break;
			}
			parse(buffer, len);
		}
		delete[] buffer;
		stream.close();
	}
}
开发者ID:euroelessar,项目名称:FBReader,代码行数:14,代码来源:StyleSheetParser.cpp


示例14:

ZLTarHeaderCache::ZLTarHeaderCache(ZLInputStream &baseStream) {
	if (!baseStream.open()) {
		return;
	}

	ZLTarHeader header;
	while (header.read(baseStream)) {
		if (header.IsRegularFile) {
			myHeaderMap[header.Name] = header;
		}
		baseStream.seek((header.Size + 0x1ff) & -0x200, false);
		header.erase();
	}
	baseStream.close();
}
开发者ID:maxyz,项目名称:FBReader,代码行数:15,代码来源:ZLTar.cpp


示例15: readFrom

bool ZLZipHeader::readFrom(ZLInputStream &stream) {
	size_t startOffset = stream.offset();
	Signature = readLong(stream);
	Version = readShort(stream);
	Flags = readShort(stream);
	CompressionMethod = readShort(stream);
	ModificationTime = readShort(stream);
	ModificationDate = readShort(stream);
	CRC32 = readLong(stream);
	CompressedSize = readLong(stream);
	UncompressedSize = readLong(stream);
	NameLength = readShort(stream);
	ExtraLength = readShort(stream);
	return (Signature == 0x04034B50) && (stream.offset() == startOffset + 30) && (NameLength != 0);
}
开发者ID:xufooo,项目名称:fbreader-e2-test,代码行数:15,代码来源:ZLZipHeader.cpp


示例16: decompress

size_t HuffDecompressor::decompress(ZLInputStream &stream, char *targetBuffer, size_t compressedSize, size_t maxUncompressedSize) {
	if (compressedSize == 0 || myErrorCode == ERROR_CORRUPTED_FILE) {
		return 0;
	}
	if (targetBuffer != 0) {
		unsigned char *sourceBuffer = new unsigned char[compressedSize];
		myTargetBuffer = targetBuffer;
		myTargetBufferEnd = targetBuffer + maxUncompressedSize;
		myTargetBufferPtr = targetBuffer;
		if (stream.read((char*)sourceBuffer, compressedSize) == compressedSize) {
			const size_t trailSize = sizeOfTrailingEntries(sourceBuffer, compressedSize);
			if (trailSize < compressedSize) {
				bitsDecompress(BitReader(sourceBuffer, compressedSize - trailSize));
			} else {
				myErrorCode = ERROR_CORRUPTED_FILE;
			}
		}
		delete[] sourceBuffer;
	} else {
		myTargetBuffer = 0;
		myTargetBufferEnd = 0;
		myTargetBufferPtr = 0;
	}

	return myTargetBufferPtr - myTargetBuffer;
}
开发者ID:Ca5th,项目名称:FBReaderJ,代码行数:26,代码来源:HuffDecompressor.cpp


示例17: decompress

size_t DocDecompressor::decompress(ZLInputStream &stream, char *targetBuffer, size_t compressedSize, size_t maxUncompressedSize) {
	const unsigned char *sourceBuffer = new unsigned char[compressedSize];
	const unsigned char *sourceBufferEnd = sourceBuffer + compressedSize;
	const unsigned char *sourcePtr = sourceBuffer;

	unsigned char *targetBufferEnd = (unsigned char*)targetBuffer + maxUncompressedSize;
	unsigned char *targetPtr = (unsigned char*)targetBuffer;

	if (stream.read((char*)sourceBuffer, compressedSize) == compressedSize) {
		unsigned char token;
		unsigned short copyLength, N, shift;
		unsigned char *shifted;

		while ((sourcePtr < sourceBufferEnd) && (targetPtr < targetBufferEnd)) {
			token = *(sourcePtr++);
			switch (TOKEN_CODE[token]) {
				case 0:
					*(targetPtr++) = token;
					break;
				case 1:
					if ((sourcePtr + token > sourceBufferEnd) || (targetPtr + token > targetBufferEnd)) {
						goto endOfLoop;
					}
					memcpy(targetPtr, sourcePtr, token);
					sourcePtr += token;
					targetPtr += token;
					break;
				case 2:
					if (targetPtr + 2 > targetBufferEnd) {
						goto endOfLoop;
					}
					*(targetPtr++) = ' ';
					*(targetPtr++) = token ^ 0x80;
					break;
				case 3:
					if (sourcePtr + 1 > sourceBufferEnd) {
						goto endOfLoop;
					}
					N = 256 * token + *(sourcePtr++);
					copyLength = (N & 7) + 3;
					if (targetPtr + copyLength > targetBufferEnd) {
						goto endOfLoop;
					}
					shift = (N & 0x3fff) / 8;
					shifted = targetPtr - shift;
					if ((char*)shifted >= targetBuffer) {
						for (short i = 0; i < copyLength; i++) {
							*(targetPtr++) = *(shifted++);
						}
					}
					break;
			}
		}
	}
endOfLoop:

	delete[] sourceBuffer;
	return targetPtr - (unsigned char*)targetBuffer;
}
开发者ID:2php,项目名称:FBReaderJ,代码行数:59,代码来源:DocDecompressor.cpp


示例18: readUnsignedWord

static unsigned short readUnsignedWord(ZLInputStream &stream) {
	unsigned char buffer[2];
	stream.read((char*)buffer, 2);
	unsigned short result = buffer[1];
	result = result << 8;
	result += buffer[0];
	return result;
}
开发者ID:euroelessar,项目名称:FBReader,代码行数:8,代码来源:CHMFile.cpp


示例19: readUnsignedLongLE

void PdbUtil::readUnsignedLongLE(ZLInputStream &stream, unsigned long &N) {
	unsigned char data[4];
	stream.read((char*)data, 4);
	N = (((unsigned long)data[3]) << 24) +
			(((unsigned long)data[2]) << 16) +
			(((unsigned long)data[1]) << 8) +
			(unsigned long)data[0];
}
开发者ID:euroelessar,项目名称:FBReader,代码行数:8,代码来源:PdbReader.cpp


示例20: readUnsignedShort

void PdbUtil::readUnsignedShort(ZLInputStream &stream, unsigned short &N) {
	unsigned char data[2];
	stream.read((char*)data, 2);
	N = (((unsigned short)data[0]) << 8) + data[1];
	/*
	stream.read((char*)&N + 1, 1);
	stream.read((char*)&N, 1);
	*/
}
开发者ID:TodorGrin,项目名称:boox-opensource,代码行数:9,代码来源:PdbReader.cpp



注:本文中的ZLInputStream类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ ZLTextWordCursor类代码示例发布时间:2022-05-31
下一篇:
C++ ZIterator类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap