KDb

KDbSqlTypes.h
1/* This file is part of the KDE project
2 Copyright (C) 2003, 2006 Jarosław Staniek <staniek@kde.org>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18*/
19
20#ifndef SQLTYPES_H
21#define SQLTYPES_H
22
23#include <QVariant>
24#include <QList>
25
26#include "KDbExpression.h"
27#include "KDbOrderByColumn.h"
28
29struct dateType {
30 int year;
31 int month;
32 int day;
33};
34
35struct realType {
36 int integer;
37 int fractional;
38};
39
40//! @internal
42{
44 : columnNumber(-1)
45 , order(KDbOrderByColumn::SortOrder::Ascending) {
46 }
47
48 void setColumnByNameOrNumber(const QVariant& nameOrNumber) {
49 if (nameOrNumber.type() == QVariant::String) {
50 aliasOrName = nameOrNumber.toString();
51 columnNumber = -1;
52 } else {
53 columnNumber = nameOrNumber.toInt();
55 }
56 }
57
58 //! Can include a "tablename." prefix
60 //! Optional, used instead of aliasOrName to refer to column
61 //! by its number rather than name.
64};
65
66//! @internal
68 SelectOptionsInternal() : orderByColumns(nullptr) {}
70 delete orderByColumns; // delete because this is internal temp. structure
71 }
72 KDbExpression whereExpr;
73 QList<OrderByColumnInternal>* orderByColumns;
74};
75
76class KDbExpressionPtr
77{
78public:
79 inline explicit KDbExpressionPtr(KDbExpression *exp) : e(exp) {}
80 inline KDbExpression toExpr() {
81 KDbExpression exp(*e);
82 delete e;
83 e = nullptr;
84 return exp;
85 }
86 inline KDbNArgExpression toNArg() {
87 KDbNArgExpression exp(e->toNArg());
88 delete e;
89 e = nullptr;
90 return exp;
91 }
92//private:
94private:
95 Q_DISABLE_COPY(KDbExpressionPtr)
96};
97
98QDebug operator<<(QDebug dbg, const KDbExpressionPtr& expr);
99
100#endif
The KDbExpression class represents a base class for all expressions.
KDbNArgExpression toNArg() const
Convenience type casts.
The KDbNArgExpression class represents a base class N-argument expression.
SortOrder
Column sort order.
QDebug operator<<(QDebug dbg, const PerceptualColor::LchaDouble &value)
void clear()
Type type() const const
int toInt(bool *ok) const const
QString toString() const const
QString aliasOrName
Can include a "tablename." prefix.
Definition KDbSqlTypes.h:59
int columnNumber
Optional, used instead of aliasOrName to refer to column by its number rather than name.
Definition KDbSqlTypes.h:62
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Jul 12 2024 12:05:27 by doxygen 1.11.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.