本文整理汇总了C++中QDataStream::readRawBytes方法的典型用法代码示例。如果您正苦于以下问题:C++ QDataStream::readRawBytes方法的具体用法?C++ QDataStream::readRawBytes怎么用?C++ QDataStream::readRawBytes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDataStream
的用法示例。
在下文中一共展示了QDataStream::readRawBytes方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: restore
void Class::restore(QDataStream & dt, char c, Package * parent)
{
Q_INT32 len;
dt >> len;
char * n = new char[len + 1];
dt.readRawBytes(n, len);
n[len] = 0;
dt >> len;
char * fn = new char[len + 1];
dt.readRawBytes(fn, len);
fn[len] = 0;
dt >> len;
char * d;
if (len == 0)
d = 0;
else {
d = new char[len + 1];
dt.readRawBytes(d, len);
d[len] = 0;
}
Class * cl = new Class(parent, n, ((c == 'c') || (c == 'i')) ? c : (c - 'A' + 'a'));
#ifdef REVERSE
cl->from_lib = TRUE;
#endif
WrapperStr name(n);
parent->declare(n, cl);
if ((c == 'i') || (c == 'c'))
cl->abstractp = TRUE;
cl->filename = fn;
#ifndef REVERSE
cl->description = d;
#endif
delete [] n;
delete [] fn;
if (d) delete [] d;
}
示例2:
Q_UINT32
Reader::getTagAndLength( QDataStream &raw, char tag[5] )
{
tag[4] = 0;
raw.readRawBytes(tag, 4);
Q_UINT32 tagLength = 0;
raw >> tagLength;
return tagLength;
}
示例3: restore
void Package::restore(QDataStream & dt, Package * parent)
{
// '{' already read
Q_INT32 len;
dt >> len;
char * name = new char[len + 1];
dt.readRawBytes(name, len);
name[len] = 0;
dt >> len;
char * path = new char[len + 1];
dt.readRawBytes(path, len);
path[len] = 0;
Package * pack = new Package(parent, path, name);
delete [] name;
delete [] path;
pack->restore_children(dt);
}
示例4: Item
Spawn::Spawn(QDataStream& d, uint16_t id)
: Item(tSpawn, id)
{
// restore Spawn info
d.readRawBytes((char*)this, sizeof(EQPoint));
d.readRawBytes((char*)&m_lastUpdate,
((char*)this + sizeof(Item)) - (char*)&m_lastUpdate);
d.readRawBytes((char*)&m_petOwnerID,
((char*)this + sizeof(Spawn)) - (char*)&m_petOwnerID);
d >> m_name;
d >> m_lastName;
// calculate race/deity team info
calcRaceTeam();
calcDeityTeam();
// don't trust old movement data (minimize walkoffs causing scaling)
setDeltas(0, 0, 0);
setHeading(0, 0);
// even if it had been considered, mark it as not
setConsidered(false);
}
示例5: play
bool QPicture::play( QPainter *painter )
{
if ( pictb.size() == 0 ) // nothing recorded
return TRUE;
pictb.open( IO_ReadOnly ); // open buffer device
QDataStream s;
s.setDevice( &pictb ); // attach data stream to buffer
if ( !formatOk ) { // first time we read it
char mf_id[4]; // picture header tag
s.readRawBytes( mf_id, 4 ); // read actual tag
if ( memcmp(mf_id, mfhdr_tag, 4) != 0 ) { // wrong header id
#if defined(CHECK_RANGE)
qWarning( "QPicture::play: Incorrect header" );
#endif
pictb.close();
return FALSE;
}
int cs_start = sizeof(Q_UINT32); // pos of checksum word
int data_start = cs_start + sizeof(Q_UINT16);
Q_UINT16 cs,ccs;
QByteArray buf = pictb.buffer(); // pointer to data
s >> cs; // read checksum
ccs = qChecksum( buf.data() + data_start, buf.size() - data_start );
if ( ccs != cs ) {
#if defined(CHECK_STATE)
qWarning( "QPicture::play: Invalid checksum %x, %x expected",
ccs, cs );
#endif
pictb.close();
return FALSE;
}
Q_UINT16 major, minor;
s >> major >> minor; // read version number
if ( major > mfhdr_maj ) { // new, incompatible version
#if defined(CHECK_RANGE)
qWarning( "QPicture::play: Incompatible version %d.%d",
major, minor);
#endif
pictb.close();
return FALSE;
}
formatOk = TRUE; // picture seems to be ok
formatMajor = major;
formatMinor = minor;
} else {
示例6: stringData
Map
Reader::parse( QDataStream &raw, uint containerLength, bool first )
{
//DEBUG_BLOCK
/* http://daap.sourceforge.net/docs/index.html
0-3 Content code OSType (unsigned long), description of the contents of this chunk
4-7 Length Length of the contents of this chunk (not the whole chunk)
8- Data The data contained within the chunk */
Map childMap;
uint index = 0;
while( (first ? !raw.atEnd() : ( index < containerLength ) ) )
{
// debug() << "at index " << index << " of a total container size " << containerLength << endl;
char tag[5];
Q_UINT32 tagLength = getTagAndLength( raw, tag );
if( tagLength == 0 )
{
// debug() << "tag " << tag << " has 0 length." << endl;
index += 8;
continue;
}
//#define DEBUGTAG( VAR ) debug() << tag << " has value " << VAR << endl;
#define DEBUGTAG( VAR )
switch( s_codes[tag].type )
{
case CHAR: {
Q_INT8 charData;
raw >> charData; DEBUGTAG( charData )
addElement( childMap, tag, QVariant( static_cast<int>(charData) ) );
}
break;
case SHORT: {
Q_INT16 shortData;
raw >> shortData; DEBUGTAG( shortData )
addElement( childMap, tag, QVariant( static_cast<int>(shortData) ) );
}
break;
case LONG: {
Q_INT32 longData;
raw >> longData; DEBUGTAG( longData )
addElement( childMap, tag, QVariant( longData ) );
}
break;
case LONGLONG: {
Q_INT64 longlongData;
raw >> longlongData; DEBUGTAG( longlongData )
addElement( childMap, tag, QVariant( longlongData ) );
}
break;
case STRING: {
QByteArray stringData(tagLength);
raw.readRawBytes( stringData.data(), tagLength ); DEBUGTAG( QString::fromUtf8( stringData, tagLength ) )
addElement( childMap, tag, QVariant( QString::fromUtf8( stringData, tagLength ) ) );
}
break;
case DATE: {
Q_INT64 dateData;
QDateTime date;
raw >> dateData; DEBUGTAG( dateData )
date.setTime_t(dateData);
addElement( childMap, tag, QVariant( date ) );
}
break;
case DVERSION: {
Q_INT16 major;
Q_INT8 minor;
Q_INT8 patchLevel;
raw >> major >> minor >> patchLevel; DEBUGTAG( patchLevel )
QString version("%1.%2.%3");
version.arg(major, minor, patchLevel);
addElement( childMap, tag, QVariant(version) );
}
break;
case CONTAINER: {
DEBUGTAG( 11 )
addElement( childMap, tag, QVariant( parse( raw, tagLength ) ) );
}
break;
default:
warning() << tag << " doesn't work" << endl;
break;
}
index += tagLength + 8;
}
return childMap;
}