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


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

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


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

示例1: loadComsolData

bool Wizard::loadComsolData(QTextStream& stream, QString* error)
{
    int nodes = 0;
    int expre = 0;
    if(!readTo(stream, "% Nodes:")) {*error = QString("\"% Nodes:\" tag missing"); return false;}
    stream >> nodes;
    if(nodes <= 0) {*error = QString("Nodes number incorrect"); return false;}
    if(!readTo(stream, "% Expressions:")) {*error = QString("\"% Expressions:\" tag missing"); return false;}
    stream >> expre;
    if(expre < 6 || (expre % 3 != 0)) {*error = QString("Expressions number incorrect"); return false;}
    expre /= 3;

    if(!readTo(stream, "% x")) {*error = QString("\"% x\" tag missing"); return false;}

    double t[3];
    for(int e = 0; e < expre; e++)
    {
        for(int d = 0; d < 3; d++)
        {
            if(!readTo(stream, "@ t=")) {*error = QString("\"@ t=\" tag missing - node %1, coordinate %2").arg(e).arg(d); return false;}
            stream >> t[d];
            if(stream.atEnd()) {*error = QString("Unexpected end of file"); return false;}
        }
        if(t[0] != t[1] || t[1] != t[2]) {*error = QString("Time indicators differ - node %1").arg(e); return false;}
        if(e == 0 && t[0] > 0.0) {*error = QString("Nonzero start time"); return false;}
    }
    double step = t[0] / (expre - 1);
    if(step <= 0.0) {*error = QString("Incorrect step"); return false;}

    trajectories.stepTime = step;
    trajectories.maxSteps = expre;
    trajectories.setNumber(nodes);
    for(int n = 0; n < nodes; n++)
    {
        int nn;
        stream >> nn;
        if(nn != n+1) {*error = QString("Index mismatch at line %1, index %2").arg(n+1).arg(nn); return false;}

        trajectories.setNumber(n, expre);
        for(int e = 0; e < expre; e++)
        {
            for(int d = 0; d < 3; d++)
            {
                stream >> t[d];
                if(stream.atEnd()) {*error = QString("Unexpected end of coordinates").arg(expre); return false;}
                if(stream.status() != 0 || !(t[d] == t[d]))
                {
                    trajectories.resetNumber(n, e);
                    d = 3; e = expre;
                    readTo(stream, "\n");
                }
            }
            trajectories.setCoordinates(n, e, t);
        }
    }
    return true;
}
开发者ID:piotr-szczypinski,项目名称:ParticlesWizard,代码行数:57,代码来源:wizard.cpp

示例2: loadShader

/**
 * @brief initShader Initiate a shader.
 * @return the compiled shader program or 0 if the shader file does not exist
 */
GLuint loadShader(string shader_name)
{
    QOpenGLFunctions* qf = new QOpenGLFunctions(QOpenGLContext::currentContext());
    char* error;

    QFile* file = new QFile((":/shader/" + shader_name + ".vsh").c_str());
    if (!file->open(QIODevice::ReadOnly | QIODevice::Text))
        return 0;

    string code = "";
    QTextStream* in = new QTextStream(file);
    while (!in->atEnd()) {
        QString line = in->readLine();
        code = code + line.toStdString() + "\n";
    }
    file->close();

    GLuint vs = qf->glCreateShader(GL_VERTEX_SHADER);
    const char* v_str = code.c_str();
    qf->glShaderSource(vs, 1, &v_str, NULL);
    qf->glCompileShader(vs);
    qf->glGetShaderInfoLog(vs, NULL, NULL, error);
    cout << error << "\n";

    code = "";

    delete file;
    delete in;
    file = new QFile((":/shader/" + shader_name + ".fsh").c_str());
    if (!file->open(QIODevice::ReadOnly | QIODevice::Text))
        return 0;

    in = new QTextStream(file);
    while (!in->atEnd()) {
        QString line = in->readLine();
        code = code + line.toStdString() + "\n";
    }
    file->close();

    GLuint fs = qf->glCreateShader(GL_FRAGMENT_SHADER);
    const char *f_str = code.c_str();
    qf->glShaderSource(fs, 1, &f_str, NULL);
    qf->glCompileShader(fs);
    qf->glGetShaderInfoLog(fs, NULL, NULL, error);
    cout << error << endl;

    GLuint program = qf->glCreateProgram();
    qf->glAttachShader(program, vs);
    qf->glAttachShader(program, fs);
    qf->glLinkProgram(program);
    qf->glGetProgramInfoLog(program, NULL, NULL, error);
    cout << error << endl;
    qf->glUseProgram(program);

    return program;
}
开发者ID:CG-Group-Spin-It-TU-Berlin-Sommer-2015,项目名称:cg-project-spin-it,代码行数:60,代码来源:shader.cpp

示例3: loadservers

bool loginfrm::loadservers()
{
	cmbdb->clear();
	dbserver.clear();
	dbname_local.clear();
	uids.clear();
	pwd.clear();
	port.clear();
	QStringList tmp;
	QFile file ( QDir::homePath() +"/.first4/local.first4.conf" );
	if ( file.open ( QIODevice::ReadOnly ) )
	{
		QString streamline;
		QTextStream stream ( &file );
		while(stream.readLine() != "[SERVERS]" && !stream.atEnd()) ;
		do {
			streamline = stream.readLine();
			if(streamline != "")
			{
				if(streamline.section(":", 0, 0) == "SQLITE")
				{
					streamline = streamline.section(":", 1, 10);
			    	uids.append("");
		    		pwd.append("");
			    	dbserver.append("");
		    		dbname_local.append(streamline);
			    	port.append("");
					cmbdb->addItem(streamline + " (SQLite3)");
				}
				else
				{
					streamline = streamline.section(":", 1, 10);
			    	uids.append(streamline.section("@",0,0).section(":",0,0));
		    		pwd.append(streamline.section("@",0,0).section(":",1,1));
			    	dbserver.append(streamline.section("@",1,1).section("/",0,0));
		    		dbname_local.append(streamline.section("@",1,1).section("/",1,1).section(":",0,0));
			    	port.append(streamline.section("@",1,1).section("/",1,1).section(":",1,1));
		    		cmbdb->addItem(streamline.section("@",0,0).section(":",0,0) + "@"+ streamline.section("@",1,1).section("/",0,0) +"/"+streamline.section("@",1,1).section("/",1,1).section(":",0,0) + " (MySQL)");
				}
			}
		} while (streamline != "" && !stream.atEnd());
		file.close();
	}
    
    if(cmbdb->count()==0)
    	return FALSE;
    else
    	return TRUE;
}
开发者ID:BackupTheBerlios,项目名称:first4-svn,代码行数:49,代码来源:loginfrm.cpp

示例4: setContent

/*!
    \internal
    Parses configuration from \a stream.
*/
void QLoggingSettingsParser::setContent(QTextStream &stream)
{
    _rules.clear();
    while (!stream.atEnd()) {
        QString line = stream.readLine();

        // Remove all whitespace from line
        line = line.simplified();
        line.remove(QLatin1Char(' '));

        // comment
        if (line.startsWith(QLatin1Char(';')))
            continue;

        if (line.startsWith(QLatin1Char('[')) && line.endsWith(QLatin1Char(']'))) {
            // new section
            _section = line.mid(1, line.size() - 2);
            continue;
        }

        if (_section == QLatin1String("Rules")) {
            int equalPos = line.indexOf(QLatin1Char('='));
            if ((equalPos != -1)
                    && (line.lastIndexOf(QLatin1Char('=')) == equalPos)) {
                const QString pattern = line.left(equalPos);
                const QStringRef value = line.midRef(equalPos + 1);
                bool enabled = (value.compare(QLatin1String("true"),
                                              Qt::CaseInsensitive) == 0);
                _rules.append(QLoggingRule(pattern, enabled));
            }
        }
    }
}
开发者ID:giucam,项目名称:qtbase,代码行数:37,代码来源:qloggingregistry.cpp

示例5: importFromTxt

bool Deck::importFromTxt(QString fileName)
{
    const QChar sep('\t');
    QTextStream s;
    QFile file(fileName);

    file.open(QIODevice::ReadOnly | QIODevice::Text);

    if(!file.isOpen())
        return false;

    s.setDevice(&file);
    s.setCodec("UTF-8");

    QStringList sl;
    QString l = s.readLine();
    while (!s.atEnd()) {
        sl = l.split(sep);

        if(sl.size()>1) {
            Card *card = new Card();

            card->updateFront(sl[0]);
            card->updateBack(sl[1]);

            addCard(card);
        }

        l = s.readLine();
    };
    
    return true;
}
开发者ID:m-o-s-t-a-f-a,项目名称:dana,代码行数:33,代码来源:deck.cpp

示例6: load

bool Document::load(QTextStream &stream)
{
    m_shapeList.clear();

    while (!stream.atEnd()) {
        QString shapeType, shapeName, colorName;
        int left, top, width, height;
        stream >> shapeType >> shapeName >> colorName >> left >> top >> width >> height;
        if (stream.status() != QTextStream::Ok)
            return false;
        bool ok;
        Shape::Type type = Shape::stringToType(shapeType, &ok);
        if (!ok)
            return false;
        QColor color(colorName);
        if (!color.isValid())
            return false;

        Shape shape(type);
        shape.m_name = shapeName;
        shape.m_color = color;
        shape.m_rect = QRect(left, top, width, height);

        m_shapeList.append(shape);
    }

    m_currentIndex = m_shapeList.isEmpty() ? -1 : 0;

    return true;
}
开发者ID:cdaffara,项目名称:symbiandump-mw3,代码行数:30,代码来源:document.cpp

示例7: parseData

static void parseData(QTextStream &textStream, unsigned int &channels, LogFileData *data, double &minValue, double &maxValue)
{
	while((!textStream.atEnd()) && (textStream.status() == QTextStream::Ok))
	{
		const QString line = textStream.readLine().simplified();
		if(!line.isEmpty())
		{
			const QStringList tokens = line.split(QChar(0x20), QString::SkipEmptyParts);
			if(((unsigned int) tokens.count()) == (channels * 3))
			{
				QStringList::ConstIterator iter = tokens.constBegin();
				for(unsigned int c = 0; c < channels; c++)
				{
					data[c].original.append((iter++)->toDouble());
					data[c].minimal .append((iter++)->toDouble());
					data[c].smoothed.append((iter++)->toDouble());

					minValue = qMin(minValue, data[c].original.back());
					minValue = qMin(minValue, data[c].minimal .back());
					minValue = qMin(minValue, data[c].smoothed.back());

					maxValue = qMax(maxValue, data[c].original.back());
					maxValue = qMax(maxValue, data[c].minimal .back());
					maxValue = qMax(maxValue, data[c].smoothed.back());
				}
			}
		}
	}
}
开发者ID:ArthurMarz,项目名称:DynamicAudioNormalizer,代码行数:29,代码来源:Main.cpp

示例8: processResults

// Returns 0 if success, 1 if a model error, 2 if an emit error.
int TestCFSM::processResults(QTextStream &in)
{
    while(!in.atEnd())
    {
        QString line = in.readLine();
        // Blank lines and comments.
        if((line.size() == 0) || (line[0] == QChar('#')))
            continue;
        else if(line == "results:")
            continue;
        else if((line[0] == QChar('0')) || line[0] == QChar('1') ||
                (line[0] == QChar('2')))
        {
            QString lineRelname  = getRelname(line);
            int     desiredState = getLineState(line);
            int     modelState   = getCheckedStateInt(line);
            if(desiredState != modelState)
            {
                // Test failed!
                return (1);
            }
        }
        else
        {
            QTextStream console(stdout);
            console << "ERROR: Scenario file is broken; parsing died on line:"
                    << endl
                    << line << endl;
            // Don't try to recover.
            QApplication::exit(1);
        }
    }
    return (0);
}
开发者ID:shinnok,项目名称:tarsnap-gui,代码行数:35,代码来源:testCFSM.cpp

示例9: searchLinkedConfigs

void Configs::searchLinkedConfigs()
{
    QFile linkedOvpn (AppFunc::getAppSavePath() + QLatin1String ("/configs.txt"));

    if (linkedOvpn.exists()) {
        if (!linkedOvpn.open(QIODevice::ReadOnly | QIODevice::Text)) {
            return;
        }
        // Offen einlesen
        QTextStream in (&linkedOvpn);
        while (!in.atEnd()) {
            QString line = in.readLine();            
            if (!this->isConfigInList(line)) {
                // Add to list
                QFile linkFileExists (line.trimmed());
                if (linkFileExists.exists()) {
                    int _id (this->id++);
                    QString configName = line.trimmed().right(line.trimmed().size() - line.trimmed().lastIndexOf("/") - 1);
                    configName = configName.left(configName.size()-5);
                    OpenVpn* myObj = new OpenVpn();
                    myObj->setConfigStable(false);
                    myObj->setConfigLinked(true);
                    myObj->setConfigName(configName);
                    myObj->setConfigPath(line.trimmed().left(line.lastIndexOf("/")));
                    myObj->setId(_id);
                    // An die Liste anfügen
                    this->myList.append(qMakePair(_id, myObj));
                }
            }
        }
        linkedOvpn.close();
    }
}
开发者ID:iBeacons,项目名称:NTUMEMSOpenVPN,代码行数:33,代码来源:configs.cpp

示例10: readResults

void SwiftReader::readResults(QTextStream& stream)
{
    QString line;
    int lineNum = 0;
    while (!stream.atEnd())
    {
        line = stream.readLine();
        ++lineNum;
        if (lineParser.exactMatch(line))
        {
            QStringList decimals = lineParser.capturedTexts();
            Orbit d;
            bool ok = true;
            #define HANDLE_ERROR(index) \
                if (!ok) { \
                std::ostringstream os; \
                os << "Could not decode decimal " << decimals.at(index).toAscii().data(); \
                throw std::runtime_error(os.str()); \
                }
            d.time = decimals.at(1).toDouble(&ok); HANDLE_ERROR(1);
            d.particleID = decimals.at(2).toDouble(&ok); HANDLE_ERROR(2);
            d.axis = decimals.at(3).toDouble(&ok) * 25559; HANDLE_ERROR(3);
            d.e = decimals.at(4).toDouble(&ok); HANDLE_ERROR(4);
            d.i = decimals.at(5).toDouble(&ok); HANDLE_ERROR(5);
            d.Omega = decimals.at(6).toDouble(&ok); HANDLE_ERROR(6);
            d.w = decimals.at(7).toDouble(&ok); HANDLE_ERROR(7);
            d.f = decimals.at(8).toDouble(&ok); HANDLE_ERROR(8);
            d.hasOrbEls = true;
            data[d.particleID].push_back(d);
        }
    }
}
开发者ID:dtamayo,项目名称:OGRE,代码行数:32,代码来源:SwiftReader.cpp

示例11: readFile

QStringList* Helper::readFile(QString aFileName)
{
  // read the data line by line
  QFile *file = new QFile(aFileName);
  QStringList *data = new QStringList();
  if (file->open(QIODevice::ReadOnly) ) {
    // file opened successfully
    QTextStream *tstream = new QTextStream(file);
    while (!tstream->atEnd()) {
      data->append(tstream->readLine());
    }
    file->close();

    // ignore whitespaces
    for (int i = 0; i < data->length(); i++) {
      if (data->value(i) == "") {
        data->removeAt(i);
      }
    }
  }
  else {
    QString msg = tr("Could not open %1.. Please make sure it is existent and readable.").arg(aFileName);
    AlertWindow *alertWin = new AlertWindow("ERROR", msg);
    alertWin->show();
  }

  return data;
}
开发者ID:MichaelKohler,项目名称:BackupSoft,代码行数:28,代码来源:helper.cpp

示例12: getScript

QString ConnectionData::getScript(const QString &type)
{
        QFile scrtiptFile (this->GetDir() + QLatin1String("/scripts.conf"));

        if (scrtiptFile.exists()) {
            // Öffnen und auslesen
            if (!scrtiptFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
                Message::error(QObject::tr("Can't read scriptconfig file!"), QObject::tr("An error occured"), FrmMain::instance());
                return QLatin1String ("");
            }

            // Datei offen
            QTextStream sin (&scrtiptFile);
            while (!sin.atEnd()){
                QString line (sin.readLine());
                if (line.trimmed().left(3).toUpper() == type.toUpper() + QLatin1String(":")) {
                    scrtiptFile.close();
                    return line.right(line.size() - 3);
                }
            }
            scrtiptFile.close();
        }

        return QLatin1String("");
    }
开发者ID:LiTianjue,项目名称:openvpn-client,代码行数:25,代码来源:connectiondata.cpp

示例13: processLines

void modCalcDayLength::processLines( QTextStream &istream ) {
    QFile fOut( OutputFileBatch->url().toLocalFile() );
    fOut.open(QIODevice::WriteOnly);
    QTextStream ostream(&fOut);

    //Write header
    ostream << "# " << i18nc("%1 is a location on earth", "Almanac for %1", geoBatch->fullName())
    << QString("  [%1, %2]").arg(geoBatch->lng()->toDMSString()).arg(geoBatch->lat()->toDMSString()) << endl
    << "# " << i18n("computed by KStars") << endl
    << "#" << endl
    << "# Date      SRise  STran  SSet     SRiseAz      STranAlt      SSetAz     DayLen    MRise  MTran  MSet      MRiseAz      MTranAlt      MSetAz     LunarPhase" << endl
    << "#" << endl;

    QString line;
    QDate d;

    while ( ! istream.atEnd() ) {
        line = istream.readLine();
        line = line.trimmed();

        //Parse the line as a date, then compute Almanac values
        d = QDate::fromString( line );
        if ( d.isValid() ) {
            updateAlmanac( d, geoBatch );
            ostream << d.toString( Qt::ISODate ) << "  "
            << srTimeString << "  " << stTimeString << "  " << ssTimeString << "  "
            << srAzString << "  " << stAltString << "  " << ssAzString << "  "
            << daylengthString << "    "
            << mrTimeString << "  " << mtTimeString << "  " << msTimeString << "  "
            << mrAzString << "  " << mtAltString << "  " << msAzString << "  "
            << lunarphaseString << endl;
        }
    }
}
开发者ID:Bugsbane,项目名称:kstars,代码行数:34,代码来源:modcalcdaylength.cpp

示例14: ReadRow

bool FormattedTouchstone::ReadRow(FormattedNetworkData &network, QTextStream &snpFile, FormattedComplexMatrix2D &dataRow, double &frequencyPoint) {
    // Begin to read data values
    double wordsToRead = pow(double(network.numberOfPorts()), 2) * 2 + 1;
    QStringList allWords;
    while (wordsToRead > 0 && !snpFile.atEnd()) {
        QStringList words;
        ReadLine(snpFile, words);
        wordsToRead -= words.size();
        allWords.append(words);
    }

    // Check to see if all data was read
    if (wordsToRead != 0)
        return false;

    // Process data
    frequencyPoint = allWords[0].toDouble();
    QStringList::iterator wordIndex = allWords.begin() + 1;
    dataRow.resize(network.numberOfPorts());
    for (FormattedComplexMatrix2D::iterator rowIndex = dataRow.begin(); rowIndex != dataRow.end(); rowIndex++) {
        (*rowIndex).resize(network.numberOfPorts());
        FormattedComplexRowVector::iterator columnIndex = (*rowIndex).begin();
        for (; columnIndex != (*rowIndex).end(); columnIndex++) {
            *columnIndex = (*ReadDatum)(wordIndex->toDouble(), (wordIndex + 1)->toDouble());
            wordIndex += 2;
        }
    }
    return true;
}
开发者ID:Terrabits,项目名称:RsaToolbox,代码行数:29,代码来源:FormattedTouchstone.cpp

示例15: m_loadFile

void MainWindow::m_loadFile(QString fileName)
{
    QFile file(fileName);
    file.open(QIODevice::ReadOnly);
    QTextStream *in;
    in = new QTextStream(&file);
    delete m_doubleData;
    delete m_data;
    int tempLength = 0;

    while(!in->atEnd())
    {
        in->readLine();
        tempLength ++;
    }
    m_doubleData = new double[tempLength];
    m_data = new int[tempLength];

    delete in;
    file.close();

    file.open(QIODevice::ReadOnly);
    in = new QTextStream(&file);

    for(int i = 0; i < tempLength; i++)
    {
        m_doubleData[i] = in->readLine().toDouble();
        m_data[i] = int(m_doubleData[i] * 50);
    }
    file.close();
}
开发者ID:zhoutl1106,项目名称:graduate,代码行数:31,代码来源:mainwindow.cpp


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