//convert a string to compound predicate Predicate* Utilities::stringToCompoundPredicates(string aString) { int lConnectiveCount = 0; Connective lAllPossibleConnectives[5] = { EQU,IMPLY,OR,AND,NOT }; for (int i = 0; i < 5; i++) { string toSearch = connectiveToString(lAllPossibleConnectives[i]); size_t lPosition = aString.find(toSearch); if (lPosition != string::npos) { lConnectiveCount++; } } if(lConnectiveCount<=1) { return stringToPredicate(aString); } else { Connective lCompoundConnective; Variable lLVal; Variable lRVal = ""; for (int i = 0; i<5; i++) { string toSearch = connectiveToString(lAllPossibleConnectives[i]); size_t lPosition = aString.find(toSearch); if (lPosition != string::npos) { lCompoundConnective = lAllPossibleConnectives[i]; lRVal = aString.substr(lPosition + toSearch.size(), aString.size() - lPosition + toSearch.size()); lLVal = aString.substr(0, aString.size() - lRVal.size() - toSearch.size()); break; } } Predicate* lLPredicate = stringToPredicate(lLVal); Predicate* lRPredicate = stringToPredicate(lRVal); CompoundPredicate* myCompoundPredicate = new CompoundPredicate(*lLPredicate, *lRPredicate, lCompoundConnective); return myCompoundPredicate; } }
void Criterion::readConfig(KConfigGroup *config) { m_subject = stringToSubject(config->readEntry(QStringLiteral("subject"), QString())); m_predicate = stringToPredicate(config->readEntry(QStringLiteral("predicate"), QString())); QVariant::Type type = QVariant::nameToType(config->readEntry(QStringLiteral("objType"), QString()).toLatin1()); if (type != QVariant::Invalid) { m_object = config->readEntry(QStringLiteral("objectValue"), QVariant(type)); } }