Herunterladen als
root/src/expression.cpp @ 827458ed
c047c335 | Christian Ehringfeld | /*
|
|
* Copyright (C) 2015 Christian Ehringfeld <c.ehringfeld@t-online.de>
|
|||
*
|
|||
* This program is free software; you can redistribute it and/or modify it
|
|||
* under the terms of the GNU Lesser General Public License as published by
|
|||
* the Free Software Foundation.
|
|||
*
|
|||
* This program is distributed in the hope that it will be useful, but
|
|||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|||
* for more details.
|
|||
*
|
|||
* You should have received a copy of the GNU Lesser General Public License
|
|||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
|||
*/
|
|||
3160499c | Christian Ehringfeld | #include "expression.h"
|
|
using namespace CuteEntityManager;
|
|||
Expression::Expression() {
|
|||
}
|
|||
506067a2 | Christian Ehringfeld | Expression::Expression(QString expression, QHash<QString, QVariant> params,
|
|
3160499c | Christian Ehringfeld | bool onlyColumn) {
|
|
3b82c8c0 | Christian Ehringfeld | for(auto i = params.begin(); i != params.end(); ++i) {
|
|
373a84e2 | Christian Ehringfeld | QString ikey = i.key();
|
|
expression.replace(":" + ikey.replace('.','_'),":" + this->generateParam());
|
|||
3b82c8c0 | Christian Ehringfeld | this->appendParam(i.key(),i.value());
|
|
}
|
|||
3160499c | Christian Ehringfeld | this->expression = expression;
|
|
3b82c8c0 | Christian Ehringfeld | this->onlyColumn = onlyColumn;
|
|
}
|
|||
Expression::Expression(QString expression, QString key, QVariant value, bool onlyColumn) {
|
|||
373a84e2 | Christian Ehringfeld | this->expression = expression.replace(":" + key.replace('.','_'), ":" + this->generateParam());
|
|
3b82c8c0 | Christian Ehringfeld | this->appendParam(key, value);
|
|
506067a2 | Christian Ehringfeld | this->onlyColumn = onlyColumn;
|
|
}
|
|||
Expression::Expression(QString expression, bool onlyColumn) {
|
|||
this->expression = expression;
|
|||
3160499c | Christian Ehringfeld | this->onlyColumn = onlyColumn;
|
|
}
|
|||
QString Expression::getExpression() const {
|
|||
return this->expression;
|
|||
}
|
|||
void Expression::setExpression(const QString &value) {
|
|||
this->expression = value;
|
|||
}
|
|||
QString Expression::toString() const {
|
|||
return this->expression;
|
|||
}
|
|||
bool Expression::getOnlyColumn() const {
|
|||
return onlyColumn;
|
|||
}
|
|||
void Expression::setOnlyColumn(bool value) {
|
|||
onlyColumn = value;
|
|||
}
|
|||
3b82c8c0 | Christian Ehringfeld | QString Expression::generateParam() {
|
|
return (QString("emP") + QString::number(this->params.size() + 1));
|
|||
}
|
|||
ea6e88f6 | Christian Ehringfeld | void Expression::appendParam(QString key, const QVariant &value) {
|
|
3b82c8c0 | Christian Ehringfeld | this->params.insert(this->generateParam(), value);
|
|
373a84e2 | Christian Ehringfeld | /**
|
|
@todo remove
|
|||
*/
|
|||
ea6e88f6 | Christian Ehringfeld | this->params.insert(key.replace('.','_'), value);
|
|
506067a2 | Christian Ehringfeld | }
|
|
QHash<QString, QVariant> Expression::getParams() const {
|
|||
return params;
|
|||
}
|
|||
void Expression::setParams(const QHash<QString, QVariant> &value) {
|
|||
params = value;
|
|||
}
|
|||