void Argument::get (const std::string &name, bool &value) { char v[BUFSIZ]; sprintf_s(v, BUFSIZ, "%s", value ? "true" : "false"); std::string temp(v); get(name, temp); std::transform(temp.begin(), temp.end(), temp.begin(), tolower); if (temp != "") value = STRING_TO_BOOL(temp); }
void Argument::get (const std::string &name, std::vector<bool> &value) { std::vector<std::string> temp; for (unsigned int i=0; i<value.size(); i++) { char v[BUFSIZ]; sprintf_s(v, BUFSIZ, "%s", value[i] ? "true" : "false"); temp.push_back(v); } get(name, temp); for (unsigned int i=0; i<temp.size(); i++) value.push_back(STRING_TO_BOOL(temp[i])); }
bool RegExpController::loadFromFile(const QString &filename) { QFile file(filename); if (!file.open(QFile::ReadOnly|QFile::Text)) { return false; } QRegExp keyValuePattern("\\s*(\\w+)\\s*=\\s*(.*)"); QTextStream stream(&file); QString line; QString pattern(""); QRegExp::PatternSyntax patternSyntax = QRegExp::RegExp; QRegExp::CaretMode caretMode = QRegExp::CaretAtZero; Qt::CaseSensitivity caseSensitivity = Qt::CaseSensitive; bool minimal = false; QString key; QString value; int lineNum = 0; bool parseSuccessful = false; _fileError.clear(); try { while (!stream.atEnd()) { lineNum ++; line = stream.readLine().trimmed(); if (!keyValuePattern.exactMatch(line)) { continue; } key = keyValuePattern.cap(1); value = keyValuePattern.cap(2).trimmed(); // qDebug() << QString("%1 = %2").arg(key).arg(value); if (key.compare("pattern", Qt::CaseInsensitive) == 0) { pattern = value; } else if (key.compare("patternSyntax", Qt::CaseInsensitive) == 0) { patternSyntax = patternSyntaxStringToId(value); } else if (key.compare("caretMode", Qt::CaseInsensitive) == 0) { caretMode = caretModeStringToId(value); } else if (key.compare("caseSensitivity", Qt::CaseInsensitive) == 0) { caseSensitivity = STRING_TO_BOOL(value) ? Qt::CaseSensitive : Qt::CaseInsensitive; } else if (key.compare("minimal", Qt::CaseInsensitive) == 0) { minimal = STRING_TO_BOOL(value); } } parseSuccessful = true; } catch (...) { _fileError = QString("Error(line#=%1) bad syntax or unknown items").arg(lineNum); } file.close(); if (parseSuccessful) { _regexp->setPattern(pattern); _regexp->setPatternSyntax(patternSyntax); _caretMode = caretMode; _regexp->setCaseSensitivity(caseSensitivity); _regexp->setMinimal(minimal); _filename = filename; } return parseSuccessful; }
void FORTE_F_STRING_TO_BOOL::executeEvent(int pa_nEIID){ if(scm_nEventREQID == pa_nEIID){ OUT() = STRING_TO_BOOL(IN()); sendOutputEvent(scm_nEventCNFID); } }