当前位置: 首页>>代码示例>>C++>>正文


C++ SeekableReadStream::pos方法代码示例

本文整理汇总了C++中SeekableReadStream::pos方法的典型用法代码示例。如果您正苦于以下问题:C++ SeekableReadStream::pos方法的具体用法?C++ SeekableReadStream::pos怎么用?C++ SeekableReadStream::pos使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SeekableReadStream的用法示例。


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

示例1: printDataHex

void printDataHex(SeekableReadStream &stream, size_t size) {
	size_t pos = stream.pos();

	size = MIN<size_t>(stream.size() - pos, size);

	if (size == 0)
		return;

	uint32 offset = 0;
	byte rowData[16];

	while (size > 0) {
		// At max 16 bytes printed per row
		uint32 n = MIN<size_t>(size, 16);
		if (stream.read(rowData, n) != n)
			throw Exception(kReadError);

		// Print an offset
		std::fprintf(stderr, "%08X  ", offset);

		// 2 "blobs" of each 8 bytes per row
		for (uint32 i = 0; i < 2; i++) {
			for (uint32 j = 0; j < 8; j++) {
				uint32 m = i * 8 + j;

				if (m < n)
					// Print the data
					std::fprintf(stderr, "%02X ", rowData[m]);
				else
					// Last row, data count not aligned to 16
					std::fprintf(stderr, "   ");
			}

			// Separate the blobs by an extra space
			std::fprintf(stderr, " ");
		}

		std::fprintf(stderr, "|");

		// If the data byte is a printable character, print it. If not, substitute a '.'
		for (uint32 i = 0; i < n; i++)
			std::fprintf(stderr, "%c", std::isprint(rowData[i]) ? rowData[i] : '.');

		std::fprintf(stderr, "|\n");

		size   -= n;
		offset += n;
	}

	// Seek back
	stream.seek(pos);
}
开发者ID:clone2727,项目名称:xoreos,代码行数:52,代码来源:strutil.cpp

示例2: nextChunk

void StreamTokenizer::nextChunk(SeekableReadStream &stream) {
	skipChunk(stream);

	byte c = stream.readByte();

	if (stream.eos() || stream.err())
		return;

	if (!isIn(c, _chunkEnds))
		stream.seek(-1, SEEK_CUR);
	else
		if (stream.pos() == stream.size())
			// This actually the last character, read one more byte to properly set the EOS state
			stream.readByte();
}
开发者ID:jjardon,项目名称:eos,代码行数:15,代码来源:streamtokenizer.cpp

示例3: getResourceString

String NEResources::getResourceString(SeekableReadStream &exe, uint32 offset) {
    uint32 curPos = exe.pos();

    if (!exe.seek(offset)) {
        exe.seek(curPos);
        return "";
    }

    uint8 length = exe.readByte();

    String string;
    for (uint16 i = 0; i < length; i++)
        string += (char)exe.readByte();

    exe.seek(curPos);
    return string;
}
开发者ID:joonhochoi,项目名称:scummvm-kor,代码行数:17,代码来源:winexe_ne.cpp


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