void Process(const Utils::StringList &data, int level, const QString &location) { if (m_debug) Out(QString("List (level %1)").arg(level)); if (level > CMaxIncludeDepth) { IncludeErr(QString("Include depth more than %1.").arg(CMaxIncludeDepth), ""/*fileName*/); } Location fileLine(location); bool inComment = false; // state var for multiline comments for (int i = 0; i < data.size(); ++i) { fileLine.Line = i + 1; // starts from 1 ProcessLine(data.at(i), level, fileLine, inComment); } }
//Constructor... pretty much everything happens here... void enlilControlFile::processControlFile(const char* FileName) { this->FileName = QString(FileName); //Open File std::ifstream inFile(FileName); char line[1024]; while(!inFile.eof()) { inFile.getline(line, 1024); QString fileLine(line); //remove whitespace from ends fileLine = fileLine.trimmed(); //skip to next line if line is a comment or is blank if(fileLine.startsWith('#') || fileLine == "") continue; //if not a comment, split on comment fileLine = fileLine.split("#")[0]; //Split on =, then value on "," QStringList varDecl = fileLine.split("="); if(varDecl.size() > 1) { bool isNumber=false; QStringList value = varDecl[1].split(","); QString key = varDecl[0].trimmed(); double dvalue = value[0].toDouble(&isNumber); //if we have a number, store list as doubles if(isNumber) { for(int n1=0; n1 < value.count(); n1++) { QVariant newValue(value[n1].toDouble()); controlFile[key].push_back(newValue); } } //if we do not have a number, store list as strings else { for(int n1=0; n1 < value.count(); n1++) { controlFile[key].push_back(value[n1]); } } } else { std::cerr << "Failure Reading Control File " << this->FileName.toStdString() << std::endl; } } //close the file inFile.close(); }