Remove c++17 dependency

This commit is contained in:
Luis Ángel San Martín 2019-09-23 19:55:00 +02:00 committed by Luis Ángel San Martín
parent 2d3888b4b4
commit 4990093e3d
3 changed files with 7 additions and 11 deletions

View File

@ -67,10 +67,6 @@ macx {
QT += macextras gui-private
}
unix {
CONFIG += c++1z
}
#CONFIG += release
CONFIG -= flat
QT += sql network widgets script

View File

@ -26,7 +26,7 @@ int QueryParser::TreeNode::buildSqlString(std::string &sqlString, int bindPositi
}
oss << "UPPER(c.filename) LIKE UPPER(:bindPosition" << bindPosition << ") OR ";
oss << "UPPER(f.name) LIKE UPPER(:bindPosition" << bindPosition << ")) ";
} else if (isIn(fieldType(children[0].t), FieldType::numeric, FieldType::boolean)) {
} else if (isIn(fieldType(children[0].t), { FieldType::numeric, FieldType::boolean })) {
oss << "ci." << children[0].t << " = :bindPosition" << bindPosition << " ";
} else if (fieldType(children[0].t) == FieldType::filename) {
oss << "(UPPER(c." << children[0].t << ") LIKE UPPER(:bindPosition" << bindPosition << ")) ";
@ -56,7 +56,7 @@ int QueryParser::TreeNode::bindValues(QSqlQuery &selectQuery, int bindPosition)
if (t == "token") {
std::ostringstream oss;
oss << ":bindPosition" << ++bindPosition;
if (isIn(fieldType(children[0].t), FieldType::numeric, FieldType::boolean)) {
if (isIn(fieldType(children[0].t), { FieldType::numeric, FieldType::boolean })) {
selectQuery.bindValue(oss.str().c_str(), std::stoi(children[1].t));
} else {
selectQuery.bindValue(oss.str().c_str(), ("%%" + children[1].t + "%%").c_str());
@ -201,7 +201,7 @@ QueryParser::TreeNode QueryParser::andExpression()
return { "and", { lhs, andExpression() } };
}
if ((isIn(tokenType(), TokenType::atWord, TokenType::word, TokenType::quotedWord) || token() == "(") && lcaseToken() != "or") {
if ((isIn(tokenType(), { TokenType::atWord, TokenType::word, TokenType::quotedWord }) || token() == "(") && lcaseToken() != "or") {
return { "and", { lhs, andExpression() } };
}
@ -227,7 +227,7 @@ QueryParser::TreeNode QueryParser::locationExpression()
}
return res;
}
if (!isIn(tokenType(), TokenType::atWord, TokenType::word, TokenType::quotedWord)) {
if (!isIn(tokenType(), { TokenType::atWord, TokenType::word, TokenType::quotedWord })) {
throw std::invalid_argument("Invalid syntax. Expected a lookup name or a word");
}
return baseToken();

View File

@ -68,10 +68,10 @@ private:
bool isEof() const;
void advance();
template<typename First, typename... T>
static bool isIn(First &&first, T &&... t)
template<typename T>
static bool isIn(const T &e, const std::list<T> &v)
{
return ((first == t) || ...);
return std::find(v.begin(), v.end(), e) != v.end();
}
enum class FieldType { unknown,