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


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

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


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

示例1: Sha1File

// File must not be open and will be closed afterwards!
QByteArray Sha1File(QFile& file) {
  file.open(QIODevice::ReadOnly);
  QCryptographicHash hash(QCryptographicHash::Sha1);
  QByteArray data;

  while (!file.atEnd()) {
    data = file.read(1000000);  // 1 mib
    hash.addData(data.data(), data.length());
    data.clear();
  }

  file.close();

  return hash.result();
}
开发者ID:zeloras,项目名称:Clementine,代码行数:16,代码来源:utilities.cpp

示例2: config

Nuria::ArgumentManager::ArgumentManager (QObject *parent)
	: QObject (parent)
{
	
	// 
	g_data = new Nuria::ArgumentManagerPrivate;
	
	// 
	QStringList args = qApp->arguments ();
	QString configPath = qApp->applicationDirPath () + "/settings.cfg";
	
	// Has the user passed a different path to the settings file?
	for (int i = 1; i < args.length (); i++) {
		const QString &cur = args.at (i);
		
		if (cur.startsWith (QLatin1String ("nuria.settings="), Qt::CaseInsensitive)) {
			configPath = cur.mid (cur.indexOf ('=') + 1);
			break;
		}
		
	}
	
	// Load additional settings from settings.cfg
	QFile config (configPath);
	if (config.open (QIODevice::ReadOnly | QIODevice::Text)) {
		
		while (!config.atEnd ()) {
			QString line = config.readLine ();
			
			if (line.indexOf ('#') != -1)
				line = line.left (line.indexOf ('#'));
			else if (line.endsWith (QLatin1Char ('\n')))
				line.chop (1);
			else if (line.endsWith (QLatin1String ("\r\n")))
				line.chop (2);
			
			if (!line.isEmpty ())
				matchArgument (line);
			
		}
		
	}
	
	// Parse command line arguments
	for (int i = 1; i < args.length (); i++)
		matchArgument (args.at (i));
	
}
开发者ID:NuriaProject,项目名称:Core,代码行数:48,代码来源:argumentmanager.cpp

示例3: processProjectFile

static bool processProjectFile(QFile& projectFile, QMap<QString, QString>& args)
{
    QByteArray line = projectFile.readLine().trimmed();
    if (line.isEmpty() || line != "[generator-project]")
        return false;

    QStringList includePaths;
    QStringList typesystemPaths;
    QStringList apiVersions;

    while (!projectFile.atEnd()) {
        line = projectFile.readLine().trimmed();
        if (line.isEmpty())
            continue;

        int split = line.indexOf("=");
        QString key;
        QString value;
        if (split > 0) {
            key = line.left(split - 1).trimmed();
            value = line.mid(split + 1).trimmed();
        } else {
            key = line;
        }

        if (key == "include-path")
            includePaths << QDir::toNativeSeparators(value);
        else if (key == "typesystem-path")
            typesystemPaths << QDir::toNativeSeparators(value);
        else if (key == "api-version")
            apiVersions << value;
        else if (key == "header-file")
            args["arg-1"] = value;
        else if (key == "typesystem-file")
            args["arg-2"] = value;
        else
            args[key] = value;
    }

    if (!includePaths.isEmpty())
        args["include-paths"] = includePaths.join(PATH_SPLITTER);

    if (!typesystemPaths.isEmpty())
        args["typesystem-paths"] = typesystemPaths.join(PATH_SPLITTER);
    if (!apiVersions.isEmpty())
        args["api-version"] = apiVersions.join("|");
    return true;
}
开发者ID:Hasimir,项目名称:Shiboken,代码行数:48,代码来源:main.cpp

示例4: detectLineEndingType

//-------------------------------------------------------------------------------------------
void AsciiDataReader::detectLineEndingType(QFile& file)
{
  QByteArray line;
  int line_size = 0;
  while (line_size < 2 && !file.atEnd()) {
    line = file.readLine();
    line_size = line.size();
  }
  file.seek(0);
  if (line_size < 2) {
    _lineending = LineEndingType();
  } else {
    _lineending.is_crlf = line[line_size - 2] == '\r' && line[line_size - 1] == '\n' ;
    _lineending.character =  _lineending.is_crlf ? line[line_size - 2] : line[line_size - 1];
  }
}
开发者ID:jmlee4301,项目名称:kst,代码行数:17,代码来源:asciidatareader.cpp

示例5: loadGenericCSVFile

bool FrameFileIO::loadGenericCSVFile(QString filename, QVector<CANFrame>* frames)
{
    QFile *inFile = new QFile(filename);
    CANFrame thisFrame;
    QByteArray line;
    long long timeStamp = Utility::GetTimeMS();
    int lineCounter = 0;

    if (!inFile->open(QIODevice::ReadOnly | QIODevice::Text))
    {
        delete inFile;
        return false;
    }

    line = inFile->readLine(); //read out the header first and discard it.

    while (!inFile->atEnd()) {
        lineCounter++;
        if (lineCounter > 100)
        {
            qApp->processEvents();
            lineCounter = 0;
        }

        line = inFile->readLine();
        if (line.length() > 2)
        {
            QList<QByteArray> tokens = line.split(',');

            timeStamp += 5;
            thisFrame.timestamp = timeStamp;
            thisFrame.ID = tokens[0].toInt(NULL, 16);
            if (thisFrame.ID > 0x7FF) thisFrame.extended = true;
            else thisFrame.extended  = false;
            thisFrame.bus = 0;
            QList<QByteArray> dataTok = tokens[1].split(' ');
            thisFrame.len = dataTok.length();
            if (thisFrame.len > 8) thisFrame.len = 8;
            for (int d = 0; d < thisFrame.len; d++) thisFrame.data[d] = dataTok[d].toInt(NULL, 16);

            frames->append(thisFrame);
        }
    }
    inFile->close();
    delete inFile;
    return true;
}
开发者ID:firefeather,项目名称:SavvyCAN,代码行数:47,代码来源:framefileio.cpp

示例6: checkupdate

bool UpdateAlgePap::checkupdate() {
    //setting keys of existings files
    settings = new QSettings("AlgePap","UpdateAlgePap");
    directory.setPath(DirPath+"/DATA/newspapers/downloadscript");
    QStringList list = directory.entryList();
    for(int i = 2;i < list.count();i++)
        settings->setValue("downloadscript/Dnd"+list.at(i),
                           getkey(directory.path()+"/"+list.at(i)));
    settings->setValue("information/Dninewspapersdata",getkey(DirPath+"/DATA/newspapers/information/newspapersdata"));
    settings->setValue("information/Dninewspapersdataar",getkey(DirPath+"/DATA/newspapers/information/newspapersdataar"));
    //getting keys in web
    list.clear();
    QString linkupdate = "wget -t3 \"https://docs.google.com/document/d/1s0-6xfegMZWrTcdwJcf7zQPDzVblIdRDWSbTPSAOncY/export?format=txt&id=1s0-6xfegMZWrTcdwJcf7zQPDzVblIdRDWSbTPSAOncY&token=AC4w5Vgc6SGsKhrbXlGT0d2JwODk-XHK4Q:1303608416000&authkey=CMjSiN4G&tfe=yn_215\" --output-document \""+DirPath+"/TMP/AlgePapUpdate\"";
    linkweb.setFileName(DirPath+"/TMP/AlgePapUpdate");
    linkdownload.setFileName(DirPath+"/TMP/linkdownload");
    if(!system(linkupdate.toAscii().constData())) {
        if(!linkweb.open(QIODevice::ReadOnly | QIODevice::Text))
            return false;
        if(!linkdownload.open(QIODevice::WriteOnly | QIODevice::Text))
            return false;
        QString loc = QString::fromUtf8(linkweb.readLine());
        loc = QString::fromUtf8(linkweb.readLine());
        while(!linkweb.atEnd() && loc != "END") {
            QString scope = QString::fromUtf8(linkweb.readLine());
            QString link = QString::fromUtf8(linkweb.readLine());
            QString key = QString::fromUtf8(linkweb.readLine());
            QString hash = QString::fromUtf8(linkweb.readLine());
            QString namear = QString::fromAscii(linkweb.readLine());
            scope.remove("\n");
            if(key != settings->value(scope,"").toString()) {
                linkdownload.write(loc.toAscii().constData());
                linkdownload.write(scope.toAscii().constData());
                linkdownload.write("\n");
                linkdownload.write(link.toAscii().constData());
                linkdownload.write(hash.toAscii().constData());
                linkdownload.write(namear.toAscii().constData());
            }
            loc = QString::fromUtf8(linkweb.readLine());
        }
        linkweb.close();
        linkdownload.close();
        delete settings;
        return true;
    }
    else
        return false;
}
开发者ID:HidoussiAissam,项目名称:algepap,代码行数:47,代码来源:updatealgepap.cpp

示例7: QFile

QMap<QString, QString>* MLocationDatabaseFake::countriesMap()
{
    QMap<QString, QString> *map = new QMap<QString, QString>();
    QFile *file;

    file = new QFile(countryListFile);
    if (!file->open(QIODevice::ReadOnly | QIODevice::Text)){
        qCritical("Could not read file %s", qPrintable(countryListFile));
        return map;
    }

    int lineNum = -1;
    while (!file->atEnd()) {
        QString country;
        QString line = file->readLine();
        lineNum++;

        if (line.startsWith("#"))
            continue;

        QStringList item = line.split(QRegExp("\\t"), QString::SkipEmptyParts);

        /* skip bad results/table lines those would break the follower code */
        if(item.size() < 2){
            qWarning("Less than two column found in file %s at line %d",
                    qPrintable(countryListFile),
                    lineNum);
            continue;
        }

        if(2 < item.size())
            qWarning("More than two column found in file %s at line %d",
                    qPrintable(countryListFile),
                    lineNum);

        country = item.at(1);

        /* country code => country name */
        /* key expected but value will not be unique */
        map->insert(item.at(0), country);
    }
    file->close();
    delete file;

    return map;
}
开发者ID:dudochkin-victor,项目名称:touchcp-datetime,代码行数:46,代码来源:mlocationdatabase-fake.cpp

示例8: loadLabels

int loadLabels(const char* fn) {
	int res = 1;
	QString path(fn);
	QString line;
	QString name;
	QStringList arr;
	QFile file;
	xAdr xadr;
	if (path.isEmpty())
		path = QFileDialog::getOpenFileName(NULL, "Load SJASM labels");
	if (path.isEmpty()) {
		res = 0;			// no file specified
	} else {
		conf.labels.clear();
		file.setFileName(path);
		if (file.open(QFile::ReadOnly)) {
			while(!file.atEnd()) {
				line = file.readLine();
				arr = line.split(QRegExp("[: \r\n]"),QString::SkipEmptyParts);
				if (arr.size() > 2) {
					xadr.type = MEM_RAM;
					xadr.bank = arr.at(0).toInt(NULL,16);
					xadr.adr = arr.at(1).toInt(NULL,16) & 0x3fff;
					xadr.abs = (xadr.bank << 14) | xadr.adr;
					name = arr.at(2);
					switch (xadr.bank) {
						case 0xff:
							xadr.type = MEM_ROM;
							xadr.bank = -1;
							break;
						case 0x05:
							xadr.adr |= 0x4000;
							break;
						case 0x02:
							xadr.adr |= 0x8000;
							break;
						default:
							xadr.adr |= 0xc000;
							break;
					}
					if (xadr.bank > 0)
						xadr.bank = xadr.abs >> 8;
					conf.labels[name] = xadr;
				}
			}
		} else {
开发者ID:samstyle,项目名称:Xpeccy,代码行数:46,代码来源:labels.cpp

示例9: md5hash

QString md5hash (const QString &fileName)
{
	QFile file (fileName);

	if (!file.open (QIODevice::ReadOnly)) {
		return QString ();
	}

	QCryptographicHash hash (QCryptographicHash::Md5);

	while (!file.atEnd()) {
		const QByteArray &buf = file.read (bufferSize);
		hash.addData (buf);
	}

	return hash.result().toHex();
}
开发者ID:panter-dsd,项目名称:UniversalUpdater,代码行数:17,代码来源:webupdater.cpp

示例10: loadLogFile

/*
tokens:
0 = timestamp
1 = Transmission direction
2 = Channel
3 = ID
4 = Type (s = standard, I believe x = extended)
5 = Data byte length
6-x = The data bytes

Sample chunk of a busmaster log:
***BUSMASTER Ver 2.4.0***
***PROTOCOL CAN***
***NOTE: PLEASE DO NOT EDIT THIS DOCUMENT***
***[START LOGGING SESSION]***
***START DATE AND TIME 8:8:2014 11:49:7:965***
***HEX***
***SYSTEM MODE***
***START CHANNEL BAUD RATE***
***CHANNEL 1 - Kvaser - Kvaser Leaf Light HS #0 (Channel 0), Serial Number- 0, Firmware- 0x00000037 0x00020000 - 500000 bps***
***END CHANNEL BAUD RATE***
***START DATABASE FILES (DBF/DBC)***
***END OF DATABASE FILES (DBF/DBC)***
***<Time><Tx/Rx><Channel><CAN ID><Type><DLC><DataBytes>***
11:49:12:9420 Rx 1 0x023 s 1 40
11:49:12:9440 Rx 1 0x460 s 8 03 E0 00 00 C0 00 00 00
11:49:12:9530 Rx 1 0x023 s 1 40
11:49:12:9680 Rx 1 0x408 s 8 0F 02 00 30 00 00 7F 00
11:49:12:9680 Rx 1 0x40B s 8 00 00 00 00 00 10 60 00
11:49:12:9690 Rx 1 0x045 s 8 40 00 00 00 00 00 00 00
*/
bool FrameFileIO::loadLogFile(QString filename, QVector<CANFrame>* frames)
{
    QFile *inFile = new QFile(filename);
    CANFrame thisFrame;
    QByteArray line;
    uint64_t timeStamp = Utility::GetTimeMS();
    int lineCounter = 0;

    if (!inFile->open(QIODevice::ReadOnly | QIODevice::Text))
    {
        delete inFile;
        return false;
    }

    line = inFile->readLine(); //read out the header first and discard it.

    while (!inFile->atEnd()) {
        lineCounter++;
        if (lineCounter > 100)
        {
            qApp->processEvents();
            lineCounter = 0;
        }

        line = inFile->readLine();
        if (line.startsWith("***")) continue;
        if (line.length() > 1)
        {
            QList<QByteArray> tokens = line.split(' ');
            QList<QByteArray> timeToks = tokens[0].split(':');
            timeStamp = (timeToks[0].toInt() * (1000ul * 1000ul * 60ul * 60ul)) + (timeToks[1].toInt() * (1000ul * 1000ul * 60ul))
                      + (timeToks[2].toInt() * (1000ul * 1000ul)) + (timeToks[3].toInt() * 100ul);
            thisFrame.timestamp = timeStamp;
            thisFrame.ID = tokens[3].right(tokens[3].length() - 2).toInt(NULL, 16);
            if (tokens[4] == "s") thisFrame.extended = false;
            else thisFrame.extended = true;
            thisFrame.bus = tokens[2].toInt() - 1;
            thisFrame.len = tokens[5].toInt();
            for (int d = 0; d < thisFrame.len; d++) thisFrame.data[d] = tokens[d + 6].toInt(NULL, 16);
        }
        frames->append(thisFrame);
    }
    inFile->close();
    delete inFile;
    return true;
}
开发者ID:firefeather,项目名称:SavvyCAN,代码行数:77,代码来源:framefileio.cpp

示例11: getTimetable

bool BadgeData::getTimetable(TimeTable &tt)
{
#ifdef ONLY_BADGE
    QFile data;
    TimeTable dum;
    data.setFileName(QDir::homePath() + QDir::separator() + "badge.data");
    data.open(QIODevice::ReadOnly);
    QDataStream out(&data);



    while (!data.atEnd()) {
        out >> dum;
        if (dum.day == tt.day) {
            tt = dum;
            data.close();
            return true;
        }
    }
    data.close();
    return false;
#else
    QSqlQuery query;
    QVariant vday(tt.day);

    query.prepare("select *  from days where daywork = ?");
    query.addBindValue(vday);

    query.exec();


    if (query.next()) {

        tt.entrance = query.value(1).toTime();
        tt.exit = query.value(2).toTime();
        tt.firstPause  = query.value(3).toTime();
        tt.endFirstPause  = query.value(4).toTime();
        tt.secondPause  = query.value(5).toTime();
        tt.endSecondPause  = query.value(6).toTime();

        return true;
    }
#endif
    return false;
}
开发者ID:BackupTheBerlios,项目名称:qbadgetask,代码行数:45,代码来源:badgedata.cpp

示例12: while

vector<QStringList> MainWindow::getFromCsv(QString path){
    vector<QStringList> fileDate;

    QFile file;
    file.setFileName(path);
    file.open(QIODevice::ReadOnly);
    cout<<"FilePath - "<<path.toUtf8().constData()<<endl;
    while(!file.atEnd()){
        QString str= file.readLine();
        str.replace(',','.');
        QStringList oneString=str.split(';');
        cout<<str.toUtf8().constData()<<endl;
        fileDate.push_back(oneString);
    }
    file.close();

    return fileDate;
}
开发者ID:chester5009,项目名称:diplom,代码行数:18,代码来源:mainwindow.cpp

示例13: dev

/*
 * Writes back the changes of the temporary file
 * to the original file.
 * Must only be called if in write mode, not in read mode
 */
bool KTar::KTarPrivate::writeBackTempFile( const QString & fileName )
{
    if ( !tmpFile )
        return true;

    //qDebug() << "Write temporary file to compressed file" << fileName << mimetype;

    bool forced = false;
    if (QLatin1String(application_gzip) == mimetype || QLatin1String(application_bzip) == mimetype ||
        QLatin1String(application_lzma) == mimetype || QLatin1String(application_xz) == mimetype)
        forced = true;

    // #### TODO this should use QSaveFile to avoid problems on disk full
    // (KArchive uses QSaveFile by default, but the temp-uncompressed-file trick
    // circumvents that).

    KFilterDev dev(fileName);
    QFile* file = tmpFile;
    if ( !dev.open(QIODevice::WriteOnly) )
    {
        file->close();
        return false;
    }
    if ( forced )
        dev.setOrigFileName( origFileName );
    file->seek(0);
    QByteArray buffer;
    buffer.resize(8*1024);
    qint64 len;
    while ( !file->atEnd()) {
        len = file->read(buffer.data(), buffer.size());
        dev.write(buffer.data(),len); // TODO error checking
    }
    file->close();
    dev.close();

    //qDebug() << "Write temporary file to compressed file done.";
    return true;
}
开发者ID:euroelessar,项目名称:cutereader,代码行数:44,代码来源:ktar.cpp

示例14: getSourceCodeStringsNumber

void Dialog::getSourceCodeStringsNumber() {

    QString str;
    QFile srcFile;

    for (ptrdiff_t i=0; i<files->count(); i++) {

        srcFile.setFileName(files->at(i));
        srcFile.open(QIODevice::ReadOnly);

        while (!srcFile.atEnd()) {

            str = srcFile.readLine().trimmed();

            if ( (!str.isEmpty()) && (!str.isNull()) ) {

                lines++;
            }
        }

        srcFile.close();
    }
}
开发者ID:pa23,项目名称:strcnt,代码行数:23,代码来源:dialog.cpp

示例15: update

void BasicMixedProviderPrivate::update(const QString &path, QMap <QString, QString> *data)
{
    data->clear();

    QFile file (path);
    if (!file.open(QIODevice::ReadOnly)) {
        return;
    }

    while (!file.atEnd()) {
        QString line = file.readLine();
        QStringList lineSplitted = line.split(";");

        if (lineSplitted.count() == 1) {
            data->insert(lineSplitted.at(0).trimmed(), QString());
        }

        if (lineSplitted.count() == 2) {
            data->insert(lineSplitted.at(0).trimmed(), lineSplitted.at(1).trimmed());
        }
    }
    file.close();
}
开发者ID:admiral0,项目名称:OpenLockscreen,代码行数:23,代码来源:basicmixedprovider.cpp


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