本文整理汇总了C++中QDataStream::setByteOrder方法的典型用法代码示例。如果您正苦于以下问题:C++ QDataStream::setByteOrder方法的具体用法?C++ QDataStream::setByteOrder怎么用?C++ QDataStream::setByteOrder使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDataStream
的用法示例。
在下文中一共展示了QDataStream::setByteOrder方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
qint16 readQInt16asLittleEndian(QDataStream &stream)
{
QDataStream::ByteOrder bo = stream.byteOrder();
stream.setByteOrder(QDataStream::LittleEndian);
quint16 res;
stream >> res;
stream.setByteOrder(bo);
return res;
}
示例2: writeFile
bool KTNEFWriter::writeFile(QDataStream &stream)
{
stream.setByteOrder(QDataStream::LittleEndian);
// Start by writing the opening TNEF stuff
stream << TNEF_SIGNATURE;
// Store the PR_ATTACH_NUM value for the first attachment
// ( must be stored even if *no* attachments are stored )
stream << mData->mFirstAttachNum;
// Now do some writing
bool ok = true;
int bytesWritten = 0;
ok &= writeProperty(stream, bytesWritten, attTNEFVERSION);
ok &= writeProperty(stream, bytesWritten, attOEMCODEPAGE);
ok &= writeProperty(stream, bytesWritten, attMSGCLASS);
ok &= writeProperty(stream, bytesWritten, attMSGPRIORITY);
ok &= writeProperty(stream, bytesWritten, attSUBJECT);
ok &= writeProperty(stream, bytesWritten, attDATESENT);
ok &= writeProperty(stream, bytesWritten, attDATESTART);
ok &= writeProperty(stream, bytesWritten, attDATEEND);
// ok &= writeProperty( stream, bytesWritten, attAIDOWNER );
ok &= writeProperty(stream, bytesWritten, attREQUESTRES);
ok &= writeProperty(stream, bytesWritten, attFROM);
ok &= writeProperty(stream, bytesWritten, attDATERECD);
ok &= writeProperty(stream, bytesWritten, attMSGSTATUS);
ok &= writeProperty(stream, bytesWritten, attBODY);
return ok;
}
示例3: loadFromStream
bool Parser::loadFromStream( QDataStream &stream )
{
stream.setByteOrder( QDataStream::LittleEndian );
Header *header = new Header( stream );
if ( ! header->isValid() ) {
kWarning() << "Failed to parse header, perhaps not an EMF file";
delete header;
return false;
}
mOutput->init( header );
#if DEBUG_EMFPARSER
kDebug(31000) << "========================================================== Starting EMF";
#endif
int numRecords = header->recordCount();
for ( int i = 1; i < numRecords; ++i ) {
// kDebug(33100) << "Record" << i << "of" << numRecords;
if ( ! readRecord( stream ) ) {
break;
}
}
mOutput->cleanup( header );
delete header;
return true;
}
示例4: stream
bool PwDatabaseV3::readDatabase(const QByteArray& dbBytes) {
QDataStream stream (dbBytes);
stream.setByteOrder(QDataStream::LittleEndian);
PwHeaderV3::ErrorCode headerErrCode = header.read(stream);
if (headerErrCode != PwHeaderV3::SUCCESS) {
LOG("%s: %d", PwHeaderV3::getErrorMessage(headerErrCode).toUtf8().constData(), headerErrCode);
emit dbLoadError(PwHeaderV3::getErrorMessage(headerErrCode), headerErrCode);
return false;
}
/* Calculate the encryption key */
setPhaseProgressBounds(UNLOCK_PROGRESS_KEY_TRANSFORM);
PwDatabase::ErrorCode dbErr = transformKey(header.getMasterSeed(), header.getTransformSeed(),
header.getTransformRounds(), combinedKey, masterKey);
if (dbErr != PwDatabase::SUCCESS) {
LOG("Cannot decrypt database - transformKey: %d", dbErr);
emit dbLoadError(tr("Cannot decrypt database", "A generic error message"), dbErr);
return false;
}
/* Decrypt data */
setPhaseProgressBounds(UNLOCK_PROGRESS_DECRYPTION);
int dataSize = dbBytes.size() - header.HEADER_SIZE;
// DB header not needed for decryption
QByteArray dbBytesWithoutHeader = dbBytes.right(dataSize);
QByteArray decryptedData(dataSize, 0);
ErrorCode err = decryptData(dbBytesWithoutHeader, decryptedData);
Util::safeClear(dbBytesWithoutHeader);
if (err != SUCCESS) {
if (err == DECRYPTED_PADDING_ERROR || err == DECRYPTED_CHECKSUM_MISMATCH) {
LOG("Cannot decrypt database - decryptData: %d", err);
emit invalidPasswordOrKey();
} else {
// err == CANNOT_DECRYPT_DB
// err == CONTENT_HASHING_ERROR
// err == something else
LOG("Cannot decrypt database - decryptData: %d", err);
emit dbLoadError(tr("Cannot decrypt database", "An error message"), err);
}
return false;
}
/* Reading and parsing data*/
setPhaseProgressBounds(UNLOCK_PROGRESS_PARSE_DATA);
QDataStream decryptedDataStream(decryptedData);
decryptedDataStream.setByteOrder(QDataStream::LittleEndian);
err = readContent(decryptedDataStream);
Util::safeClear(decryptedData);
if (err != SUCCESS) {
emit dbLoadError(tr("Cannot parse database", "An error message. Parsing refers to the analysis/understanding of file content (do not confuse with reading it)."), err);
return false;
}
return true;
}
示例5: dump
void ClassicTileInfo::dump(QDataStream& stream) {
stream.setByteOrder(QDataStream::LittleEndian);
for(int tile = 0; tile < _tileCount; ++tile) {
stream << tiles[tile].frames;
}
for(int tile = 0; tile < _tileCount; ++tile) {
stream << tiles[tile].behavior;
}
for(int side = 0; side < 4; ++side) {
for(int tile = 0; tile < _tileCount; ++tile) {
stream << tiles[tile].style[side];
}
}
}
示例6: saveFeatures
void saveFeatures(QDataStream &outstream, const QString &extractorName,
const QStringList &extractorArgs, const int &extractorSize,
const QVector<LabelledData> &data)
{
outstream.setVersion(QDataStream::Qt_4_6);
outstream.setByteOrder(QDataStream::BigEndian);
int size = sizeof(nnreal);
outstream << size;
outstream << extractorName;
outstream << extractorArgs;
outstream << extractorSize;
outstream << data;
}
示例7: on_pushButton_clicked
void chmEditer::on_pushButton_clicked()
{
//
chmHeader hd;
QString fileName = QFileDialog::getOpenFileName(this,
tr("Открыть chm"), ".", tr("Chm Files (*.chm)"));
// fileName = "D:\\ferz\\chm1\\TestPrj.chm";
QFile f;
f.setFileName(fileName);
if (f.open(QIODevice::ReadOnly))
{
QDataStream stream;
stream.setDevice(&f);
stream.setByteOrder(QDataStream::LittleEndian);
char *tmp1;
tmp1 = new char[4];
stream.readRawData(tmp1,4);
hd.header = tmp1;
delete tmp1;
stream>> hd.version;
stream>> hd.lenght;
stream.skipRawData(4);
stream>>hd.timestamp;
stream>>hd.languageID;
tmp1 = new char[10];
stream.readRawData(tmp1,10);
hd.GUID1 = tmp1;
delete tmp1;
tmp1 = new char[10];
stream.readRawData(tmp1,10);
hd.GUID2 = tmp1;
delete tmp1;
qDebug()<<hd.GUID1;
ui->textEdit->append("<b>Заголовок</b>: "+hd.header);
ui->textEdit->append("<b>Версия</b>: "+QString("%1").arg(hd.version));
ui->textEdit->append("<b>полный размер заголовка</b> : "+QString("%1").arg(hd.lenght));
ui->textEdit->append("<b>Язык</b> : "+QString("%1").arg(hd.languageID,0, 16));
}
示例8: load
bool ClassicTileInfo::load(QDataStream& stream, int size) {
if(tiles) {
delete[] tiles;
}
_tileCount = size;
stream.setByteOrder(QDataStream::LittleEndian);
tiles = new Tile[_tileCount];
/*for(unsigned int i = 0; i != _tileCount; ++i) {
stream >> tiles[i].frames;
}*/
for(unsigned int i = 0; i != _tileCount; ++i) {
stream >> tiles[i].behavior;
}
for(unsigned int side = 0; side < 4; ++side) {
for(unsigned int tile = 0; tile != _tileCount; ++tile) {
stream >> tiles[tile].style[side];
}
}
return true;
}
示例9: loadFOX
bool CPatchFile::loadFOX(QDataStream &stream, QVector<QRgb> &palette) {
stream.setByteOrder(QDataStream::LittleEndian);
// Read the file header
char magic[4];
stream.readRawData(magic, 4);
if (magic[0] != 'F' || magic[1] != 'S' || magic[2] != 'H' || magic[3] != 'X') {
m_error = BadMagicError;
return false;
}
stream >> version;
qint32 numShapes, generator, encryption, reserved1, reserved2;
stream >> numShapes;
stream >> generator;
stream >> encryption;
stream >> reserved1 >> reserved2;
if (encryption > 0) {
m_error = FileIsEncryptedError;
return false;
}
// Go on to reading every shape now
shapes.resize(numShapes);
for (int shapeIdx = 0; shapeIdx < numShapes; shapeIdx++) {
CShape &shape = shapes[shapeIdx];
quint16 flags, numFrames, numSteps;
stream >> flags;
stream >> shape.replacedIndex;
stream >> numFrames >> numSteps;
shape.flags = (CShape::Flags)flags;
// V3 and above has SHAPEEXT
if (version >= 3) {
quint16 shapeExtSize;
stream >> shapeExtSize;
// what else...?
stream.skipRawData(shapeExtSize - 2);
}
// Frames come now
shape.frames.resize(numFrames);
for (int frameIdx = 0; frameIdx < numFrames; frameIdx++) {
CFrame &frame = shape.frames[frameIdx];
quint16 frameFormat, frameWidth, frameHeight;
quint32 imageDataSize;
stream >> frameFormat;
stream >> frameWidth >> frameHeight;
stream >> frame.posX >> frame.posY;
stream >> frame.furrePosX >> frame.furrePosY;
stream >> imageDataSize;
frame.format = (CFrame::FormatType)frameFormat;
// Deal with FRAMEEXT
if (version >= 3) {
quint16 frameExtSize;
stream >> frameExtSize;
// opacity and compressionType are always present.
stream >> frame.opacity;
quint8 compressionType;
stream >> compressionType;
frame.compression = (CFrame::CompressionType)compressionType;
stream.skipRawData(frameExtSize - 4);
} else {