diff --git a/YACReaderLibrary/YACReaderLibrary.pro b/YACReaderLibrary/YACReaderLibrary.pro index 8f79b706..e6d86252 100644 --- a/YACReaderLibrary/YACReaderLibrary.pro +++ b/YACReaderLibrary/YACReaderLibrary.pro @@ -67,10 +67,6 @@ macx { QT += macextras gui-private } -unix { - CONFIG += c++1z -} - #CONFIG += release CONFIG -= flat QT += sql network widgets script diff --git a/YACReaderLibrary/db/query_parser.cpp b/YACReaderLibrary/db/query_parser.cpp index c68502db..802c11b8 100644 --- a/YACReaderLibrary/db/query_parser.cpp +++ b/YACReaderLibrary/db/query_parser.cpp @@ -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(); diff --git a/YACReaderLibrary/db/query_parser.h b/YACReaderLibrary/db/query_parser.h index 427cda30..0d032036 100644 --- a/YACReaderLibrary/db/query_parser.h +++ b/YACReaderLibrary/db/query_parser.h @@ -68,10 +68,10 @@ private: bool isEof() const; void advance(); - template - static bool isIn(First &&first, T &&... t) + template + static bool isIn(const T &e, const std::list &v) { - return ((first == t) || ...); + return std::find(v.begin(), v.end(), e) != v.end(); } enum class FieldType { unknown,