本文整理汇总了C++中common::ReadStream::read方法的典型用法代码示例。如果您正苦于以下问题:C++ ReadStream::read方法的具体用法?C++ ReadStream::read怎么用?C++ ReadStream::read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类common::ReadStream
的用法示例。
在下文中一共展示了ReadStream::read方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
Common::String *LureEngine::detectSave(int slotNumber) {
Common::ReadStream *f = this->_saveFileMan->openForLoading(
generateSaveName(slotNumber));
if (f == NULL) return NULL;
Common::String *result = NULL;
// Check for header
char buffer[5];
f->read(&buffer[0], 5);
if (memcmp(&buffer[0], "lure", 5) == 0) {
// Check language version
uint8 language = f->readByte();
uint8 version = f->readByte();
if ((language == getLanguage()) && (version >= LURE_MIN_SAVEGAME_MINOR)) {
// Read in the savegame title
char saveName[MAX_DESC_SIZE];
char *p = saveName;
int decCtr = MAX_DESC_SIZE - 1;
while ((decCtr > 0) && ((*p++ = f->readByte()) != 0)) --decCtr;
*p = '\0';
result = new Common::String(saveName);
}
}
delete f;
return result;
}
示例2: readStream
static int readStream(void *context, char *buffer, int len) {
Common::ReadStream *stream = (Common::ReadStream *) context;
if (!stream)
return -1;
return stream->read(buffer, len);
}
示例3: readStream
static int readStream(void *context, char *buffer, int len) {
Common::ReadStream *stream = static_cast<Common::ReadStream *>(context);
if (!stream)
return -1;
return stream->read(buffer, len);
}
示例4: read
bool SavePartSprite::read(Common::ReadStream &stream) {
SaveHeader header;
header.read(stream);
if (_header != header) {
if (!_trueColor) {
// Header validation failed, trying again with the old version
_header.setVersion(1);
_header.setSize(_header.getSize() - 1);
if (_header != header)
// Nope, isn't it either
return false;
_oldFormat = true;
_header.setVersion(kVersion);
_header.setSize(_header.getSize() + 1);
} else
return false;
}
// The sprite's dimensions have to fit
if (stream.readUint32LE() != _width)
return false;
if (stream.readUint32LE() != _height)
return false;
// If it's in the current format, the true color flag has to be the same too
if (!_oldFormat)
if ((stream.readByte() != 0) != _trueColor)
return false;
// Sprite data
if (stream.read(_dataSprite, _spriteSize) != _spriteSize)
return false;
// Palette data
if (stream.read(_dataPalette, 768) != 768)
return false;
return !stream.err();
}
示例5: readBTree
/*-----------------------------------------------------------------------
* BtPage
*-----------------------------------------------------------------------*/
void BtPage::readBTree(Common::ReadStream &s) {
_header._count = s.readUint16LE();
_header._down = s.readUint16LE();
if (_header._down == kBtValNone) {
// Leaf list
for (int i = 0; i < kBtLeafCount; ++i) {
s.read(_leaf[i]._key, kBtKeySize);
_leaf[i]._pos = s.readUint32LE();
_leaf[i]._size = s.readUint16LE();
}
} else {
// Root index
for (int i = 0; i < kBtInnerCount; ++i) {
s.read(_inner[i]._key, kBtKeySize);
_inner[i]._down = s.readUint16LE();
}
}
}
示例6: loadGame
bool LureEngine::loadGame(uint8 slotNumber) {
Common::ReadStream *f = this->_saveFileMan->openForLoading(
generateSaveName(slotNumber));
if (f == NULL)
return false;
// Check for header
char buffer[5];
f->read(buffer, 5);
if (memcmp(buffer, "lure", 5) != 0) {
warning(FAILED_MSG, slotNumber);
delete f;
return false;
}
// Check language version
uint8 language = f->readByte();
_saveVersion = f->readByte();
if ((language != getLureLanguage()) || (_saveVersion < LURE_MIN_SAVEGAME_MINOR)) {
warning("loadGame: Failed to load slot %d - incorrect version", slotNumber);
delete f;
return false;
}
// Read in and discard the savegame caption
while (f->readByte() != 0)
;
// Load in the data
Resources::getReference().loadFromStream(f);
Game::getReference().loadFromStream(f);
Sound.loadFromStream(f);
Fights.loadFromStream(f);
Room::getReference().loadFromStream(f);
delete f;
return true;
}
示例7: operator
void operator()(std::array<T, N>& t) const {
_s->read(t.data(), N * sizeof(T));
}
示例8: readStream
/**
* Read a given number of bytes from a Stream into a pre-allocated buffer
*/
int FileManager::readStream(Common::ReadStream &stream, void *buf, size_t nbytes) {
return stream.read(buf, nbytes);
}