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


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

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


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

示例1: 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

示例2: 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

示例3: readDict

bool Index::readDict( QDataStream& stream )
{
	dict.clear();
	docList.clear();
	
	QString key;
	int version, numOfDocs;
	
	stream >> version;
	
	if ( version < 2 )
		return false;
	
	stream >> m_charssplit;
	stream >> m_charsword;
	
	// Read the document list
	stream >> docList;
	
	while ( !stream.atEnd() )
	{
		stream >> key;
		stream >> numOfDocs;
		
		QVector<Document> docs( numOfDocs );
		
		stream >> docs;
		dict.insert( key, new Entry( docs ) );
	}
	
	return dict.size() > 0;
}
开发者ID:EmbolismSoil,项目名称:kchmviewer,代码行数:32,代码来源:helper_search_index.cpp

示例4: read

bool QPixmapIconEngine::read(QDataStream &in)
{
    int num_entries;
    QPixmap pm;
    QString fileName;
    QSize sz;
    uint mode;
    uint state;

    in >> num_entries;
    for (int i=0; i < num_entries; ++i) {
        if (in.atEnd()) {
            pixmaps.clear();
            return false;
        }
        in >> pm;
        in >> fileName;
        in >> sz;
        in >> mode;
        in >> state;
        if (pm.isNull()) {
            addFile(fileName, sz, QIcon::Mode(mode), QIcon::State(state));
        } else {
            QPixmapIconEngineEntry pe(fileName, sz, QIcon::Mode(mode), QIcon::State(state));
            pe.pixmap = pm;
            pixmaps += pe;
        }
    }
    return true;
}
开发者ID:fluxer,项目名称:katie,代码行数:30,代码来源:qicon.cpp

示例5: ReadBytes

void Prg::ReadBytes(QDataStream& stream, int index)
{
    while(!stream.atEnd())
    {
         stream >> _byteCode[index++];
    }
}
开发者ID:fr3d741,项目名称:C64Emulator,代码行数:7,代码来源:Prg.cpp

示例6: _readPts

Cornu::PolylineConstPtr Document::_readPts(QDataStream &stream)
{
    unsigned int sz = 0;
    stream >> sz;
    if(stream.atEnd() || sz > 10000)
        return Cornu::PolylineConstPtr();

    Cornu::VectorC<Vector2d> pt(sz, Cornu::NOT_CIRCULAR);
    for(int i = 0; i < pt.size(); ++i) {
        if(stream.atEnd())
            return Cornu::PolylineConstPtr();
        stream >> pt[i][0] >> pt[i][1];
    }

    return new Cornu::Polyline(pt);
}
开发者ID:F2X,项目名称:cornucopia-lib,代码行数:16,代码来源:Document.cpp

示例7: read_cstring

void read_cstring(QDataStream & stream, QString & v)
{
    quint8 c;
    while (!stream.atEnd()) {
        stream >> c;
        if (c == 0)
            break;
        v.append(c);
    }
}
开发者ID:Dakror,项目名称:voxie,代码行数:10,代码来源:voxel.cpp

示例8: while

static qint32 find_sample_count_v6(QDataStream & abr, AbrInfo *abr_info)
{
    qint64 origin;
    qint32 sample_section_size;
    qint32 sample_section_end;
    qint32 samples = 0;
    qint32 data_start;

    qint32 brush_size;
    qint32 brush_end;

    if (!abr_supported_content(abr_info))
        return 0;

    origin = abr.device()->pos();

    if (!abr_reach_8BIM_section(abr, "samp")) {
        // reset to origin
        abr.device()->seek(origin);
        return 0;
    }

    // long
    abr >> sample_section_size;
    sample_section_end = sample_section_size + abr.device()->pos();

    if(sample_section_end < 0 || sample_section_end > abr.device()->size())
        return 0;

    data_start = abr.device()->pos();

    while ((!abr.atEnd()) && (abr.device()->pos() < sample_section_end)) {
        // read long
        abr >> brush_size;
        brush_end = brush_size;
        // complement to 4
        while (brush_end % 4 != 0) brush_end++;

        qint64 newPos = abr.device()->pos() + brush_end;
        if(newPos > 0 && newPos < abr.device()->size()) {
            abr.device()->seek(newPos);
        }
        else
            return 0;

        samples++;
    }

    // set stream to samples data
    abr.device()->seek(data_start);

    //dbgKrita <<"samples : "<< samples;
    return samples;
}
开发者ID:AninaRJ,项目名称:krita,代码行数:54,代码来源:kis_abr_brush_collection.cpp

示例9: okToProceed

bool CoreProtocol::okToProceed( QDataStream &din)
{
	if ( din.atEnd() )
	{
		m_state = NeedMore;
		kDebug(YAHOO_RAW_DEBUG) << " saved message prematurely";
		return false;
	}
	else
		return true;
}
开发者ID:Jtalk,项目名称:kopete-fork-xep0136,代码行数:11,代码来源:coreprotocol.cpp

示例10: decodeData

void Sequence::decodeData(QDataStream &inputStream, quint8 length)
{
    quint32 bytesRead = 0;
    while (!inputStream.atEnd() && bytesRead++ < length) {
        quint8 type = 0;
        inputStream >> type;
        AbstractSyntaxNotationOne *asnType = DataTypeFactory::createType(static_cast<Type::AbstractSyntaxNotationOneType>(type), this);
        bytesRead += asnType->decode(inputStream);

        sequenceData.append(asnType);
    }
}
开发者ID:3Hren,项目名称:QtSnmp,代码行数:12,代码来源:Sequence.cpp

示例11: read

void SessionManager::read()
{
    QFile f(_sessionsPath);
    QDataStream in;
    QVariant tmp;
    Session *session(0);

    // Opening the saving file
    if (!f.open(QIODevice::ReadOnly))
        return;

    in.setDevice(&f);

    // Reading of all sessions
    while (!in.atEnd())
    {
        session = new Session();

        // Retrieving of the access token
        in >> tmp;

        session->setAccessToken(tmp.toString());
        tmp.clear();

        // Retrieving of the client token
        in >> tmp;

        session->setClientToken(tmp.toString());
        tmp.clear();

        // Retrieving of the player's uuid
        in >> tmp;

        session->setUuid(tmp.toString());
        tmp.clear();

        // Retrieving of the player's username
        in >> tmp;

        session->setName(tmp.toString());
        tmp.clear();

        // Retrieving of the player's legacy
        in >> tmp;

        session->setLegacy(tmp.toBool());
        tmp.clear();
    }

    f.close();
}
开发者ID:rigma,项目名称:EMPLauncher,代码行数:51,代码来源:sessionmanager.cpp

示例12: while

void
KCmdLineArgs::loadAppArgs( QDataStream &ds)
{
   s->parsed = true; // don't reparse argc/argv!

   // Remove Qt and KDE options.
   s->removeArgs("qt");
   s->removeArgs("kde");
   s->removeArgs("kuniqueapp");

   KCmdLineArgsList::Iterator args;
   if ( s->argsList ) {
      for(args = s->argsList->begin(); args != s->argsList->end(); ++args)
      {
         (*args)->clear();
      }
   }

   if (ds.atEnd())
      return;

   QByteArray qCwd;
   ds >> qCwd;

   s->mCwd = qCwd;

   uint count;
   ds >> count;

   while(count--)
   {
     QByteArray id;
     ds >> id;
     Q_ASSERT( s->argsList );
     bool found = false;
     for(args = s->argsList->begin(); args != s->argsList->end(); ++args)
     {
       if ((*args)->d->id  == id)
       {
          (*args)->d->load(ds);
          found = true;
          break;
       }
     }
     if (!found) {
         kWarning() << "Argument definitions for" << id << "not found!";
         // The next ds >> id will do nonsensical things...
     }
   }
   s->parsed = true;
}
开发者ID:fluxer,项目名称:kdelibs,代码行数:51,代码来源:kcmdlineargs.cpp

示例13: 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;
}
开发者ID:piotrkubisa,项目名称:keepassb,代码行数:50,代码来源:PwGroupV3.cpp

示例14: ShortLoad

/** Load a QByteArray from a stream with only one leading byte instead of 4. */
void ShortLoad (QDataStream &s, QByteArray &str)
{
  str.detach();
  quint8 len;
  s >> len;			    // read size of string

  if ( len == 0 || s.atEnd() ) {  // end of file reached
    str.resize( 0 );
    return;
  }

  str.resize( len );
  s.readRawData( str.data(), len );
  return;
}
开发者ID:Exadios,项目名称:Cumulus,代码行数:16,代码来源:filetools.cpp

示例15: loadFromStream

void IntegerColumn::loadFromStream(QDataStream &aStream)
{
    init();

    QString aMagicWord;

    while (!aStream.atEnd())
    {
        aStream >> aMagicWord;

        if (aMagicWord=="Default")
        {
            aStream >> mDefaultValue;
        }
        else
        if (aMagicWord=="Decimals")
开发者ID:Gris87,项目名称:ProtocolCreator,代码行数:16,代码来源:integercolumn.cpp


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