当前位置: 首页>>代码示例>>C++>>正文


C++ QDataStream::readRawData方法代码示例

本文整理汇总了C++中QDataStream::readRawData方法的典型用法代码示例。如果您正苦于以下问题:C++ QDataStream::readRawData方法的具体用法?C++ QDataStream::readRawData怎么用?C++ QDataStream::readRawData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QDataStream的用法示例。


在下文中一共展示了QDataStream::readRawData方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: locker

void SoD00V::ReadHeader(QDataStream &datastr){
	QMutexLocker locker(&readmutex);
	char tmp[4];
	for(int i=0;i<252;i++){
		char c=0;
		datastr.readRawData(&c,1);
		Set_description(Description()+ QChar(c));
	}
	datastr.readRawData(tmp,2);
	datastr.readRawData(tmp,1);
	Set_NADC( tmp[0]);
	datastr.readRawData(tmp,1);
	char nmon=tmp[0]*4;
	if(nmon>63){
		nmon=63;
		Set_Warning();
		error("Data header contains wrong data about monitor detectors count.");
	}
	for(int i=0; i<63; i++){
		uint cnt=0;
		datastr.readRawData((char*)&cnt,4);
		double val=cnt;
		if(i<nmon)
			ApplyConstant("M#"+QString::number(i),val);
	}
	m_events_header=0;
	datastr.readRawData((char*)&m_events_header,4);
}
开发者ID:alexkernphysiker,项目名称:Irina-qt,代码行数:28,代码来源:KINR.cpp

示例2: sendStreamData

//read form fp,and write to tcpSocket
void sendStreamData(QTcpSocket* tcpSocket,QDataStream &in,long long streamLength){
    char *buffer;
    buffer = new (std::nothrow) char[STREAMBLOCKSIZE];
    if(!buffer){
        std::cerr << "can not allocat memeory" << std::endl;
        return;
    }
    if(streamLength==0){
        while(!in.atEnd()){
            unsigned short len = in.readRawData(buffer,STREAMBLOCKSIZE);
            if(tcpSocket->bytesToWrite()>16384 && !tcpSocket->waitForBytesWritten())
                return;
            tcpSocket->write((char*)&len,sizeof(unsigned short));
            if(len!=0)
                tcpSocket->write(buffer,len);
            if(len!=STREAMBLOCKSIZE){
                len=STREAMBLOCKSIZE;
                tcpSocket->write((char*)&len,sizeof(unsigned short));
                //break;
            }
        }
    }
    else{
        while(streamLength>0){
            unsigned short len = in.readRawData(buffer,STREAMBLOCKSIZE);
            if(tcpSocket->bytesToWrite()>16384 && !tcpSocket->waitForBytesWritten())
                return;
            tcpSocket->write(buffer,len);
            streamLength -= len;
        }
    }
    delete[] buffer;
}
开发者ID:simplesslife,项目名称:qt-socket,代码行数:34,代码来源:ground.cpp

示例3: p_objc

QString AbrStructParser::p_objc(QDataStream &buf){
    // here we lost some data definitly 
    // objnamelen is always 1 and objname is empty string
    quint32 objnamelen;
    buf >> objnamelen;
    
    char * objname = new char[objnamelen*2+1];
    buf.readRawData(objname,objnamelen*2);
    objname[ objnamelen * 2 ] = '\0';
    
    Q_ASSERT(objnamelen == 1);
    
    quint32 objtypelen;
    buf >> objtypelen;
    if (objtypelen == 0){
        objtypelen = 4;
    }
    
    char * typeName = new char[objtypelen+1];
    buf.readRawData(typeName,objtypelen);
    typeName [objtypelen] = '\0';
    
    quint32 value;
    buf >> value;
    //return QString::fromLatin1( objname ) + ' ' + QString::fromLatin1(typeName) + ' ' + QString::number(value);
    return QString::fromLatin1(typeName) + ' ' + QString::number(value);
}
开发者ID:KDE,项目名称:calligra-history,代码行数:27,代码来源:abr_struct_parser.cpp

示例4: ready

void TempConnection::ready()
{
        QDataStream in ( m_socket );
        in.setVersion ( QDataStream::Qt_4_5 );
        if ( m_hdr == NULL ) {
                if ( m_socket->bytesAvailable() < ( int ) sizeof ( p_header ) ) {
                        return;
                }
                m_hdr = new p_header;
                in.readRawData ( ( char* ) m_hdr, sizeof ( p_header ) );
                //check the packet
                if ( strcmp ( ( const char* ) m_hdr->ident.data, "CERB" ) != 0 ) {
                        // bad packet, do something here
                        return;
                }
                //check the version
                if ( !is_proto_current ( m_hdr->ver ) ) {
                        // the version is not the same, do something here
                }
        }
        if ( m_socket->bytesAvailable() < m_hdr->length ) {
                return;
        }

        if ( m_hdr->command == NET_INITIATE_CONNECTION ) {
                uchar client_type;
                in >> client_type;
                emit newClient ( this, static_cast<CLIENT_ID> ( client_type ) );
        } else {
开发者ID:jlgo172003,项目名称:Cerberus,代码行数:29,代码来源:temp_connection.cpp

示例5: 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);
}
开发者ID:CasparLi,项目名称:Mu,代码行数:33,代码来源:knmusictagm4a.cpp

示例6: readBinaryArray

QVariant readBinaryArray(QDataStream& in, int& position) {
    quint32 arrayLength;
    quint32 encoding;
    quint32 compressedLength;

    in >> arrayLength;
    in >> encoding;
    in >> compressedLength;
    position += sizeof(quint32) * 3;

    QVector<T> values;
    if ((int)QSysInfo::ByteOrder == (int)in.byteOrder()) {
        values.resize(arrayLength);
        QByteArray arrayData;
        if (encoding == FBX_PROPERTY_COMPRESSED_FLAG) {
            // preface encoded data with uncompressed length
            QByteArray compressed(sizeof(quint32) + compressedLength, 0);
            *((quint32*)compressed.data()) = qToBigEndian<quint32>(arrayLength * sizeof(T));
            in.readRawData(compressed.data() + sizeof(quint32), compressedLength);
            position += compressedLength;
            arrayData = qUncompress(compressed);
            if (arrayData.isEmpty() ||
                (unsigned int)arrayData.size() != (sizeof(T) * arrayLength)) { // answers empty byte array if corrupt
                throw QString("corrupt fbx file");
            }
        } else {
            arrayData.resize(sizeof(T) * arrayLength);
            position += sizeof(T) * arrayLength;
            in.readRawData(arrayData.data(), arrayData.size());
        }

        if (arrayData.size() > 0) {
            memcpy(&values[0], arrayData.constData(), arrayData.size());
        }
    } else {
        values.reserve(arrayLength);
        if (encoding == FBX_PROPERTY_COMPRESSED_FLAG) {
            // preface encoded data with uncompressed length
            QByteArray compressed(sizeof(quint32) + compressedLength, 0);
            *((quint32*)compressed.data()) = qToBigEndian<quint32>(arrayLength * sizeof(T));
            in.readRawData(compressed.data() + sizeof(quint32), compressedLength);
            position += compressedLength;
            QByteArray uncompressed = qUncompress(compressed);
            if (uncompressed.isEmpty()) { // answers empty byte array if corrupt
                throw QString("corrupt fbx file");
            }
            QDataStream uncompressedIn(uncompressed);
            uncompressedIn.setByteOrder(QDataStream::LittleEndian);
            uncompressedIn.setVersion(QDataStream::Qt_4_5); // for single/double precision switch
            for (quint32 i = 0; i < arrayLength; i++) {
                T value;
                uncompressedIn >> value;
                values.append(value);
            }
        } else {
            for (quint32 i = 0; i < arrayLength; i++) {
开发者ID:ZappoMan,项目名称:hifi,代码行数:56,代码来源:FBXReader_Node.cpp

示例7: readUtf8

QString readUtf8(QDataStream& stream){
    int size;
    stream.readRawData((char*)&size,sizeof(int));
    if (size==0)
        return "";
    char* utf8 = new char[size];
    stream.readRawData(utf8,size);
    QString value = QString::fromUtf8(utf8,size);
    delete [] utf8;
    return value;
}
开发者ID:vasilenkomike,项目名称:TrackYourTime,代码行数:11,代码来源:cexternaltrackers.cpp

示例8: readRing

bool FeatureConnector::readRing(QDataStream& stream, std::vector<Coordinate2d> &ring ) {
    quint32 numberOfCoords;

    if (stream.readRawData((char *)&numberOfCoords, 4) <= 0)
        return ERROR1(ERR_COULD_NOT_OPEN_READING_1,"data file");
    vector<XYZ> pnts(numberOfCoords);
    stream.readRawData((char *)&pnts[0],numberOfCoords*3*8);
    ring.resize(numberOfCoords);
    for(quint32 i=0; i < numberOfCoords; ++i) {
        ring[i] = Coordinate2d(pnts[i].x, pnts[i].y);
    }

   return true;
}
开发者ID:JeroenBrinkman,项目名称:IlwisConnectors,代码行数:14,代码来源:featureconnector.cpp

示例9: compressed

template<class T> QVariant readArray(QDataStream& in) {
    quint32 arrayLength;
    quint32 encoding;
    quint32 compressedLength;
    
    in >> arrayLength;
    in >> encoding;
    in >> compressedLength;
    
    QVector<T> values;
    const int DEFLATE_ENCODING = 1;
    if (encoding == DEFLATE_ENCODING) {
        // preface encoded data with uncompressed length
        QByteArray compressed(sizeof(quint32) + compressedLength, 0);
        *((quint32*)compressed.data()) = qToBigEndian<quint32>(arrayLength * sizeof(T));
        in.readRawData(compressed.data() + sizeof(quint32), compressedLength);
        QByteArray uncompressed = qUncompress(compressed);
        QDataStream uncompressedIn(uncompressed);
        uncompressedIn.setByteOrder(QDataStream::LittleEndian);
        uncompressedIn.setVersion(QDataStream::Qt_4_5); // for single/double precision switch
        for (int i = 0; i < arrayLength; i++) {
            T value;
            uncompressedIn >> value;
            values.append(value);
        }
    } else {
开发者ID:heracek,项目名称:hifi,代码行数:26,代码来源:FBXReader.cpp

示例10: readString

QString readString(QDataStream &stream)
{
	QString res = "";
	while(true || !stream.atEnd())
	{
		char data[2];
		stream.readRawData(data, 2);
		
		if (data[0] == 0x00)
			break;
	
		if(data[0] != 0x00)
            res += QChar::fromLatin1(data[0]);
        /*
         * короче не знает он что такое этот фром аски, пробовал инклюды разные и доставлял либы, не помогло
         * sea-kg: беда... метод в ку5 морально устарел... может попробовать res += QChar::fromLatin1(data[0]) ???
         * или res += QChar(QLatin1Char(data[0]).unicode());
         * http://qt-project.org/doc/qt-5.0/qtcore/qchar.html
         * Static Public Method
         * QChar 	fromAscii(char c) (deprecated)
         * Converts the ASCII character c to it's equivalent QChar. This is mainly useful for non-internationalized software.
         * An alternative is to use QLatin1Char.
         */
    }
	return res;
}
开发者ID:forensictool,项目名称:coex,代码行数:26,代码来源:reader.cpp

示例11: readChat

void Connection::readChat(QDataStream& s)
{
    int a,b;
    s>>a;
    qDebug()<<"Hei "<<a;
    char* buf = new char[2*a+1];
    s.readRawData(buf,2*a);
    buf[2*a]=0;
    QString chatName=QString::fromRawData((QChar*)buf,a);
    s>>b;
    buf = new char[2*b+1];
    s.readRawData(buf,2*b);
    buf[2*b]=0;
    QString chatMsg=QString::fromRawData((QChar*)buf,b);
    engine.chatList.append(ChatMessage(QDateTime::currentDateTime(),chatName,chatMsg));

}
开发者ID:sisu,项目名称:taisto,代码行数:17,代码来源:connection.cpp

示例12: p_untf

QString AbrStructParser::p_untf(QDataStream &buf){
    char * type = new char[5];
    buf.readRawData(type, 4);
    type[4] = '\0';
    double value;
    buf >> value;
    return QString::fromLatin1(type) + ' ' + QString::number(value);
}
开发者ID:KDE,项目名称:calligra-history,代码行数:8,代码来源:abr_struct_parser.cpp

示例13: 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));
    }
开发者ID:Alexandr-Galko,项目名称:chmfile,代码行数:42,代码来源:chmediter.cpp

示例14: while

static bool abr_reach_8BIM_section(QDataStream & abr, const QString name)
{
    char tag[4];
    char tagname[5];
    qint32 section_size = 0;
    int r;

    // find 8BIMname section
    while (!abr.atEnd()) {
        r = abr.readRawData(tag, 4);

        if (r != 4) {
            warnKrita << "Error: Cannot read 8BIM tag ";
            return false;
        }

        if (strncmp(tag, "8BIM", 4)) {
            warnKrita << "Error: Start tag not 8BIM but " << (int)tag[0] << (int)tag[1] << (int)tag[2] << (int)tag[3] << " at position " << abr.device()->pos();
            return false;
        }

        r = abr.readRawData(tagname, 4);

        if (r != 4) {
            warnKrita << "Error: Cannot read 8BIM tag name";
            return false;
        }
        tagname[4] = '\0';

        QString s1 = QString::fromLatin1(tagname, 4);

        if (!s1.compare(name)) {
            return true;
        }

        // long
        abr >> section_size;
        abr.device()->seek(abr.device()->pos() + section_size);
    }
    return true;
}
开发者ID:AninaRJ,项目名称:krita,代码行数:41,代码来源:kis_abr_brush_collection.cpp

示例15: msg_RoleInfo

void Summoners::msg_RoleInfo(QDataStream &oStream)
{
    qint32 len;
    char name[128] = {'\0'};	//假设名字最长128字符

    oStream >> len;
    oStream.readRawData(name, len);
    oStream >> player.level >> player.exp >> player.hp >> player.dc;
    player.name = name;

    DisplayPlayerInfo();
}
开发者ID:simon0xia,项目名称:Summoners,代码行数:12,代码来源:summoners.cpp


注:本文中的QDataStream::readRawData方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。