本文整理汇总了C++中QDataStream::skipRawData方法的典型用法代码示例。如果您正苦于以下问题:C++ QDataStream::skipRawData方法的具体用法?C++ QDataStream::skipRawData怎么用?C++ QDataStream::skipRawData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDataStream
的用法示例。
在下文中一共展示了QDataStream::skipRawData方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: while
/** Loads group fields from the stream. Returns true on success, false in case of error. */
bool PwGroupV3::readFromStream(QDataStream& stream) {
quint16 fieldType;
qint32 fieldSize;
while (!stream.atEnd()) {
stream >> fieldType >> fieldSize;
switch(fieldType) {
case FIELD_RESERVED:
stream.skipRawData(fieldSize);
break;
case FIELD_GROUP_ID:
this->setId(PwStreamUtilsV3::readInt32(stream));
break;
case FIELD_NAME:
this->setName(PwStreamUtilsV3::readString(stream, fieldSize));
break;
case FIELD_CREATION_TIME:
this->setCreationTime(PwStreamUtilsV3::readTimestamp(stream));
break;
case FIELD_LAST_MODIFIED_TIME:
this->setLastModificationTime(PwStreamUtilsV3::readTimestamp(stream));
break;
case FIELD_LAST_ACCESS_TIME:
this->setLastAccessTime(PwStreamUtilsV3::readTimestamp(stream));
break;
case FIELD_EXPIRATION_TIME:
this->setExpiryTime(PwStreamUtilsV3::readTimestamp(stream));
break;
case FIELD_ICON_ID:
this->setIconId(PwStreamUtilsV3::readInt32(stream));
break;
case FIELD_GROUP_LEVEL:
this->setLevel(PwStreamUtilsV3::readUInt16(stream));
break;
case FIELD_GROUP_FLAGS:
this->setFlags(PwStreamUtilsV3::readInt32(stream));
break;
case FIELD_END:
// group fields finished
stream.skipRawData(fieldSize);
// a "Backup" group in the root is equivalent of V4's "Recycle Bin"
if ((this->getLevel() == 0) && (BACKUP_GROUP_NAME == this->getName())) {
this->setDeleted(true);
}
return true;
}
}
// something went wrong, there was no FIELD_END marker
return false;
}
示例2: clearBox
inline bool KNMusicTagM4a::getBox(QDataStream &musicDataStream,
KNMusicTagM4a::M4ABox &box,
bool ignoreContent)
{
//Clear the box data.
clearBox(box);
//Set the box properties to independet box.
box.independence=true;
//Get the size of the box, reduce the 8 bytes size of itself and the name.
musicDataStream>>box.size;
box.size-=8;
//Generate the name field.
char nameField[5]={0};
//Get the name of the box.
if(musicDataStream.readRawData(nameField, 4)==-1)
{
//If you cannot read the data, then it's failed to read the box.
return false;
}
//Save the box name.
box.name=nameField;
//Get the content, or else we will simply get back.
if(ignoreContent)
{
box.independence=false;
//Skip the box size data.
return musicDataStream.skipRawData(box.size);
}
//Allocate memory to store the box data.
box.data=new char[box.size];
//Read the new data.
return musicDataStream.readRawData(box.data, box.size);
}
示例3: p_desc
QString AbrStructParser::p_desc(QDataStream &buf){
// convert 4 bytes as big-endian unsigned long
quint32 size;
// 22 + 4
buf >> size;
buf.skipRawData(22);
return QString::number( size );
}
示例4: readFromDataStream
void LYTTextBox::readFromDataStream(QDataStream &in) {
qint64 saveStartPos = in.device()->pos();
LYTPane::readFromDataStream(in);
// the lengths are stored in bytes (not characters) and count the
// zero terminator, and strings are UTF-16 (I think) so we need
// to take it off here
in >> (quint16&)bufferLength;
bufferLength >>= 1;
bufferLength--;
quint16 stringLength;
in >> (quint16&)stringLength;
stringLength >>= 1;
stringLength--;
// read the material and font names
quint16 materialNum, fontNum;
in >> (quint16&)materialNum;
in >> (quint16&)fontNum;
materialName = m_layout.materials.getNameOfIndex(materialNum);
fontName = m_layout.m_fontRefs.at(fontNum);
in >> (quint8&)alignment;
in >> (quint8&)alignmentOverride;
in.skipRawData(2); // padding
quint32 stringOffset;
in >> (quint32&)stringOffset;
ReadRGBA8Color(colour1, in);
ReadRGBA8Color(colour2, in);
in >> (float&)fontSizeX;
in >> (float&)fontSizeY;
in >> (float&)charSpace;
in >> (float&)lineSpace;
// read the textbox contents
// subtract 8 to account for BinaryBlockHeader or whatever it's called
in.device()->seek(saveStartPos + stringOffset - 8);
ushort *rawText = new ushort[stringLength];
for (int i = 0; i < stringLength; i++)
in >> (quint16&)rawText[i];
text.setUtf16(rawText, stringLength);
delete[] rawText;
}
示例5: 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));
}
示例6: if
bool KNMusicTagApev2::parseTag(QFile &musicFile,
QDataStream &musicDataStream,
KNMusicAnalysisItem &analysisItem)
{
//Check the file size first.
if(musicFile.size()<APEv2HeaderSize)
{
return false;
}
//There're several positions we have to check:
// * The beginning of the file. (APEv2)
// * The end of the file. (APEv1, APEv2)
// * If there's ID3v1 tag, check the position before ID3v1. (APEv1, APEv2)
//Generate a header structure.
APEHeader header;
//Initial the tag start position.
bool foundHeader=false;
//Check the beginning of the file.
if(checkHeader(0,
musicDataStream,
header))
{
//Tag start right after the tag. So we don't need to move the position
//of the data stream.
//Set the header found flag.
foundHeader=true;
}
//Check the end of the file.
else if(checkHeader(musicFile.size()-APEv2HeaderSize,
musicDataStream,
header))
{
//Move the data stream to the right position. It should be: (APEv1)
//...........xxxx ... xxxxAPETAGEXxxxx ... xxx|(EOF)
//(File data)| | |
// Tag Start Header Start End of File
//For APEv2, before the tag start it has another header. Ignore it.
//Reset the device to start.
musicDataStream.device()->reset();
//Skip the file data.
musicDataStream.skipRawData(musicFile.size()-header.size);
//Set the header found flag.
foundHeader=true;
}
//Check the position before ID3v1. Some file may have both ID3v1 and APEv1/
//APEv2.
else if(musicFile.size()>=ID3v1nAPEv2 && //File size first.
checkHeader(musicFile.size()-ID3v1nAPEv2,
musicDataStream,
header))
{
//Move the data stream to the right position. It should be: (APEv1)
//...........xxxx ... xxxxAPETAGEXxxxx ... xxxTAGxxx ... xxx|(EOF)
//(File data)| | | |
// Tag Start Header Start ID3v1 End of File
//For APEv2, before the tag start it has another header. Ignore it.
//Reset the device to start.
musicDataStream.device()->reset();
//Skip the file data.
musicDataStream.skipRawData(musicFile.size()-ID3v1Size-header.size);
//Set the header found flag.
foundHeader=true;
}
//Check if we have found the header. If we didn't find any header, then
//failed to parse the APEv1/APEv2.
if(!foundHeader)
{
return false;
}
//Read the tag from the file.
char *rawTagData=new char[header.size];
musicDataStream.readRawData(rawTagData, header.size);
//Parse the raw tag data list.
QList<APETagItem> tagList;
parseRawData(rawTagData, header, tagList);
//Recover the memory.
delete[] rawTagData;
//Write the tag list to analysis item.
//Get the detail info.
KNMusicDetailInfo &detailInfo=analysisItem.detailInfo;
//Parse each tag list.
for(auto i=tagList.constBegin(); i!=tagList.constEnd(); ++i)
{
//Get the frame index from the hash list.
int frameIndex=m_keyIndex.value((*i).key, -1);
//If we cannot map the key to the index, then ignore the current frame.
if(frameIndex==-1)
{
continue;
}
switch(frameIndex)
{
case TrackNumber:
{
//Get the track string data.
QString trackText=QString((*i).value);
//Find the '/' char.
int splitterIndex=trackText.indexOf('/');
//If we cannot find the splitter,
if(splitterIndex==-1)
//.........这里部分代码省略.........
示例7: 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 {
示例8: parseTag
bool KNMusicTagWav::parseTag(QFile &musicFile,
QDataStream &musicDataStream,
KNMusicAnalysisItem &analysisItem)
{
//Check file size.
if(musicFile.size()<12)
{
//It cannot be a wav format file, until a valid one.
return false;
}
//Gernerate the header cache.
char rawHeader[12];
//Read the header.
musicDataStream.readRawData(rawHeader, 12);
//Check the riff header and the wave header.
if(memcmp(rawHeader, m_riffHeader, 4)!=0 ||
memcmp(rawHeader+8, m_waveHeader, 4)!=0)
{
//This is not a wav file.
return false;
}
/*
* WAV file is a combination of several chunks.
* Read all the chunks, and find LIST and id32 chunk.
*/
//Get the music file size.
qint64 fileSize=musicFile.size();
//Generate the chunk header cache.
char chunkHeader[8];
//Initial the chunk found flag.
bool listFound=false, id32Found=false;
//We have to prepare the list here and write the data after parse all the
//data, we want the id32 chunk has a higher priority than list chunk.
//Prepare the wav item list for list chunk.
QList<WAVItem> listData;
//Generate the raw frame linked list for id32 chunk.
QLinkedList<ID3v2Frame> frames;
//Generate the id3v2 frame function set for id32 chunk.
ID3v2FunctionSet functionSet;
//Start finding the chunk.
while(musicDataStream.device()->pos()<fileSize && !listFound && !id32Found)
{
//Read chunk head.
musicDataStream.readRawData(chunkHeader, 8);
//Calculate the chunk size.
quint32 chunkSize=KNMusicUtil::inverseCharToInt32(chunkHeader+4);
//Check if it's list chunk
if(memcmp(chunkHeader, m_listChunk, 4)==0)
{
//Set list chunk found flag to true.
listFound=true;
//Generate chunk size cache.
char *listRawData=new char[chunkSize];
//Read the raw data.
musicDataStream.readRawData(listRawData, chunkSize);
//Parse list chunk.
parseListChunk(listRawData, chunkSize, listData);
//Recover memory.
delete[] listRawData;
}
//Check if it's id32 chunk.
else if(memcmp(chunkHeader, m_id32Chunk, 4)==0)
{
//Generate ID3v2 header cache.
char rawHeader[10];
//Generate ID3v2 header structure.
ID3v2Header header;
//Read ID3v2 header data.
musicDataStream.readRawData(rawHeader, 10);
//Parse the ID3v2 header.
//and then Check is chunk size smaller than tag size.
if(!parseID3v2Header(rawHeader, header) ||
chunkSize<(header.size+10))
{
//If we cannot parse it, skip the whole chunk.
musicDataStream.skipRawData(chunkSize-10);
//Continue to next chunk.
continue;
}
//Generate the raw tag data field.
char *rawTagData=new char[header.size];
//Read the raw tag data.
musicDataStream.readRawData(rawTagData, header.size);
//Get the function set according to the minor version of the header.
getId3v2FunctionSet(header.major, functionSet);
//Parse the raw data.
parseID3v2RawData(rawTagData, header, functionSet, frames);
//Recover the memory.
delete[] rawTagData;
//Set the id32 chunk find flag to true.
id32Found=true;
}
//For all the other chunks.
else
{
//Skip the data.
musicDataStream.skipRawData(chunkSize);
}
}
//Check if the list data is not empty, first.
//.........这里部分代码省略.........
示例9: if
QSharedPointer<AttributesInfo> AttributesInfo::parse(QDataStream &data, ConstantPool const &cp)
{
quint16 attributeIndex;
data >> attributeIndex;
quint32 attributeDataLength;
data >> attributeDataLength;
QSharedPointer<ConstantPoolInfo_Utf8> attributeName = cp.get<ConstantPoolInfo_Utf8>(attributeIndex);
AttributesInfo *info;
if (attributeName->string() == "ConstantValue")
{
info = new AttributesInfo_ConstantValue(data);
}
else if (attributeName->string() == "Code")
{
info = new AttributesInfo_Code(data, cp);
}
else if (attributeName->string() == "Exceptions")
{
info = new AttributesInfo_Exceptions(data);
}
else if (attributeName->string() == "InnerClasses")
{
data.skipRawData(attributeDataLength);
info = new AttributesInfo_InnerClasses(data);
}
else if (attributeName->string() == "Synthetic")
{
info = new AttributesInfo_Synthetic();
}
else if (attributeName->string() == "SourceFile")
{
info = new AttributesInfo_SourceFile(data);
}
else if (attributeName->string() == "LineNumberTable")
{
data.skipRawData(attributeDataLength);
info = new AttributesInfo_LineNumberTable();
}
else if (attributeName->string() == "LocalVariableTable")
{
data.skipRawData(attributeDataLength);
info = new AttributesInfo_LocalVariableTable();
}
else if (attributeName->string() == "Deprecated")
{
info = new AttributesInfo_Deprecated();
}
else if (attributeName->string() == "StackMapTable")
{
data.skipRawData(attributeDataLength);
info = new AttributesInfo_StackMapTable();
}
else if (attributeName->string() == "Signature")
{
info = new AttributesInfo_Signature(data);
}
else
{
data.skipRawData(attributeDataLength);
info = NULL;
qWarning("unknown attribute name: %s", attributeName->string().toUtf8().constData());
}
return QSharedPointer<AttributesInfo>(info);
}
示例10: on_actionView_PLY_File_triggered
//---------------------------------------------------------------------
// TODO factor code out of here and into its own class for loading and
// saving PLY files (additional code in stereo/multiviewstereo.cpp)
//
void MainWindow::on_actionView_PLY_File_triggered() {
QString initialDir = userSettings.contains("InitialPLYDir")
? userSettings.value("InitialPLYDir").toString()
: QDir::homePath();
// TODO sheets would be nice for Mac users :)
QString fname = QFileDialog::getOpenFileName(this,
tr("Open File"),
initialDir,
"PLY Files (*.ply)");
if(!fname.isNull()) {
QFile file(fname);
if(file.open(QFile::ReadOnly)) {
userSettings.setValue("InitialPLYDir", QDir(fname).absolutePath());
QTextStream textStream(&file);
// For now we'll ignore the header and assume a certain format
QString line;
bool hasNormal = false;
bool hasColor = false;
bool isBinary = false;
unsigned int numVertices = 0;
unsigned int numFaces = 0;
static QRegExp typeTest("n[xyz]");
static QRegExp normalTest("n[xyz]");
static QRegExp colorTest("diffuse_(red|blue|green)");
static QRegExp elementTest("element (vertex|face) (\\d+)");
while((line = textStream.readLine().trimmed()) != "end_header") {
if(line.startsWith("property")) {
if( line.contains(normalTest) )
hasNormal = true;
if( line.contains(colorTest) )
hasColor = true;
} else if(elementTest.indexIn(line) != -1) {
if(elementTest.cap(1) == "face")
numFaces = elementTest.cap(2).toUInt();
else if(elementTest.cap(1) == "vertex")
numVertices = elementTest.cap(2).toUInt();
} else if(line.startsWith("format")) {
isBinary = line.contains("binary");
}
}
QDataStream dataStream;
if(isBinary) {
qint64 pos = textStream.pos();
file.close();
file.open(QFile::ReadOnly);
dataStream.setDevice(&file);
dataStream.skipRawData(pos);
}
//
// Read in the verticies
//
GLfloat d[9] = {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f};
std::vector<GLfloat> vertices(numVertices * 9);
std::vector<GLfloat>::iterator vertexIter = vertices.begin();
if(isBinary) {
uint len = 12 + (hasNormal ? 12 : 0) + (hasColor ? 3 : 0);
// TODO more efficient to read in larger chunk of data
for(unsigned int vertex = 0; vertex < numVertices && !textStream.atEnd(); ++vertex) {
dataStream.readRawData(reinterpret_cast<char *>(d), len);
if(!hasNormal)
d[3] = d[4] = d[5] = 0;
if(!hasColor)
d[6] = d[7] = d[8] = 1;
if(dataStream.status() != QDataStream::ReadPastEnd)
vertexIter = std::copy(d, d + 9, vertexIter);
}
} else {
for(unsigned int vertex = 0; vertex < numVertices && !textStream.atEnd(); ++vertex) {
textStream >> d[0] >> d[1] >> d[2];
if(hasNormal)
textStream >> d[3] >> d[4] >> d[5];
else
d[3] = d[4] = d[5] = 0.0f;
if(hasColor) {
textStream >> d[6] >> d[7] >> d[8];
d[6] /= 255.0;
d[7] /= 255.0;
d[8] /= 255.0;
} else {
d[6] = d[7] = d[8] = 0.5f;
//d[6] = qrand() / (1.0*RAND_MAX);
//d[7] = qrand() / (1.0*RAND_MAX);
//.........这里部分代码省略.........