本文整理汇总了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);
}
示例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();
}
示例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;
}