本文整理汇总了C++中common::ReadStream类的典型用法代码示例。如果您正苦于以下问题:C++ ReadStream类的具体用法?C++ ReadStream怎么用?C++ ReadStream使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ReadStream类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
示例2:
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 == getLureLanguage()) && (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;
}
示例3: readBG
void Parser::readBG(Common::ReadStream &in, Background &curBG) {
curBG._verbIndex = in.readUint16BE();
curBG._nounIndex = in.readUint16BE();
curBG._commentIndex = in.readSint16BE();
curBG._matchFl = (in.readByte() != 0);
curBG._roomState = in.readByte();
curBG._bonusIndex = in.readByte();
}
示例4: readBG
void Parser::readBG(Common::ReadStream &in, background_t &curBG) {
curBG.verbIndex = in.readUint16BE();
curBG.nounIndex = in.readUint16BE();
curBG.commentIndex = in.readSint16BE();
curBG.matchFl = (in.readByte() != 0);
curBG.roomState = in.readByte();
curBG.bonusIndex = in.readByte();
}
示例5: read
bool SavePartVars::read(Common::ReadStream &stream) {
if (!_header.verify(stream))
return false;
if (stream.read(_data, _size) != _size)
return false;
return !stream.err();
}
示例6: readString
/**
* Extracts a string from a data stream
* @param df data stream
*/
Common::String readString(Common::ReadStream &df) {
Common::String var;
uint8 len = df.readByte();
for (int i = 0; i < len; i++) {
char c;
c = df.readByte();
var += c;
}
return var;
}
示例7: loadString
/**
* Load a NULL-terminated string from the given stream.
*/
static Common::String loadString(Common::ReadStream &in, uint maxSize = 999) {
Common::String result;
while (!in.eos() && (result.size() < maxSize)) {
char ch = (char)in.readByte();
if (ch == '\0')
break;
result += ch;
}
return result;
}
示例8: DataBlockPtr
DataBlockPtr AdlEngine_v2::readDataBlockPtr(Common::ReadStream &f) const {
byte track = f.readByte();
byte sector = f.readByte();
byte offset = f.readByte();
byte size = f.readByte();
if (f.eos() || f.err())
error("Error reading DataBlockPtr");
if (track == 0 && sector == 0 && offset == 0 && size == 0)
return DataBlockPtr();
return _disk->getDataBlock(track, sector, offset, size);
}
示例9: readString
Common::String XARCMember::readString(Common::ReadStream &stream) {
Common::String str;
// Read until we find a 0
char c = 1;
while (c != 0) {
c = stream.readByte();
if (stream.eos()) {
c = 0;
} else {
str += c;
}
}
return str;
}
示例10: loadIntroSong
void SoundHandler::loadIntroSong(Common::ReadStream &in) {
for (int varnt = 0; varnt < _vm->_numVariant; varnt++) {
uint16 numBuf = in.readUint16BE();
if (varnt == _vm->_gameVariant)
_DOSIntroSong = _vm->_text->getTextData(numBuf);
}
}
示例11:
static void deDPCM8Stereo(int16 *out, Common::ReadStream &audioStream, uint32 numBytes, uint8 &sampleL, uint8 &sampleR) {
for (uint32 i = 0; i < numBytes; ++i) {
const uint8 delta = audioStream.readByte();
deDPCM8Nibble(out++, sampleL, delta >> 4);
deDPCM8Nibble(out++, sampleR, delta & 0xf);
}
}
示例12: saveOrLoadCommonArray
static void saveOrLoadCommonArray(Common::ReadStream &stream, A &array) {
uint count = stream.readUint16LE();
if (count == array.size()) {
for (uint i = 0; i < count; ++i) {
saveOrLoad(stream, array[i]);
}
}
}
示例13: drawOval
void Design::drawOval(Graphics::ManagedSurface *surface, Common::ReadStream &in,
Patterns &patterns, byte fillType, byte borderThickness, byte borderFillType) {
int16 y1 = in.readSint16BE();
int16 x1 = in.readSint16BE();
int16 y2 = in.readSint16BE();
int16 x2 = in.readSint16BE();
PlotData pd(surface, &patterns, fillType, 1, this);
if (fillType <= patterns.size())
Graphics::drawEllipse(x1, y1, x2-1, y2-1, kColorBlack, true, drawPixel, &pd);
pd.fillType = borderFillType;
pd.thickness = borderThickness;
if (borderThickness > 0 && borderFillType <= patterns.size())
Graphics::drawEllipse(x1, y1, x2-1, y2-1, kColorBlack, false, drawPixel, &pd);
}
示例14: loadCmdList
/**
* Load _cmdList from Hugo.dat
*/
void Parser::loadCmdList(Common::ReadStream &in) {
cmd tmpCmd;
memset(&tmpCmd, 0, sizeof(tmpCmd));
for (int varnt = 0; varnt < _vm->_numVariant; varnt++) {
uint16 numElem = in.readUint16BE();
if (varnt == _vm->_gameVariant) {
_cmdListSize = numElem;
_cmdList = (cmd **)malloc(sizeof(cmd *) * _cmdListSize);
}
for (int16 i = 0; i < numElem; i++) {
uint16 numSubElem = in.readUint16BE();
if (varnt == _vm->_gameVariant)
_cmdList[i] = (cmd *)malloc(sizeof(cmd) * numSubElem);
for (int16 j = 0; j < numSubElem; j++)
readCmd(in, (varnt == _vm->_gameVariant) ? _cmdList[i][j] : tmpCmd);
}
}
}
示例15: readCmd
/**
* Read a cmd structure from Hugo.dat
*/
void Parser::readCmd(Common::ReadStream &in, cmd &curCmd) {
curCmd.verbIndex = in.readUint16BE();
curCmd.reqIndex = in.readUint16BE();
curCmd.textDataNoCarryIndex = in.readUint16BE();
curCmd.reqState = in.readByte();
curCmd.newState = in.readByte();
curCmd.textDataWrongIndex = in.readUint16BE();
curCmd.textDataDoneIndex = in.readUint16BE();
curCmd.actIndex = in.readUint16BE();
}