KDb

KDbQuerySchemaParameter.cpp
1 /* This file is part of the KDE project
2  Copyright (C) 2006-2010 JarosÅ‚aw Staniek <[email protected]>
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 #include "KDbQuerySchemaParameter.h"
21 #include "KDbDriver.h"
22 #include "KDbDriverManager_p.h"
23 #include "kdb_debug.h"
24 
25 #include <QWeakPointer>
26 
27 KDbQuerySchemaParameter::~KDbQuerySchemaParameter()
28 {
29 }
30 
31 QDebug operator<<(QDebug dbg, const KDbQuerySchemaParameter& parameter)
32 {
33  dbg.nospace() << "MESSAGE=" << parameter.message() << "TYPE=" << KDbField::typeName(parameter.type());
34  return dbg.space();
35 }
36 
38 {
39  dbg.nospace() << QString::fromLatin1("QUERY PARAMETERS (%1):").arg(list.count());
40  foreach(const KDbQuerySchemaParameter& parameter, list) {
41  dbg.nospace() << " - " << parameter;
42  }
43  return dbg.space();
44 }
45 
46 //================================================
47 
48 class Q_DECL_HIDDEN KDbQuerySchemaParameterValueListIterator::Private
49 {
50 public:
51  Private(/*const KDbDriver &driver, */const QList<QVariant>& aParams)
52  : //driverWeakPointer(DriverManagerInternal::self()->driverWeakPointer(driver))
53  params(aParams)
54  {
55  //move to last item, as the order is reversed due to parser's internals
56  paramsIt = params.constEnd();
57  --paramsIt;
58  paramsItPosition = params.count();
59  }
60  //! @todo ?? QWeakPointer<const KDbDriver> driverWeakPointer;
61  const QList<QVariant> params;
63  int paramsItPosition;
64 private:
65  Q_DISABLE_COPY(Private)
66 };
67 
68 KDbQuerySchemaParameterValueListIterator::KDbQuerySchemaParameterValueListIterator(
69  const QList<QVariant>& params)
70  : d(new Private(params))
71 {
72 }
73 
74 KDbQuerySchemaParameterValueListIterator::~KDbQuerySchemaParameterValueListIterator()
75 {
76  delete d;
77 }
78 
80 {
81  if (d->paramsItPosition == 0) { //d->params.constEnd()) {
82  kdbWarning() << "no prev value";
83  return QVariant();
84  }
85  QVariant res(*d->paramsIt);
86  --d->paramsItPosition;
87  --d->paramsIt;
88  return res;
89 }
An iterator for a list of values of query schema parameters Allows to iterate over parameters and ret...
int count(const T &value) const const
QDebug & nospace()
A single parameter of a query schema.
QDebug & space()
QDataStream & operator<<(QDataStream &out, const KDateTime &dateTime)
KIOFILEWIDGETS_EXPORT QStringList list(const QString &fileClass)
QString typeName() const
Definition: KDbField.h:377
QString arg(qlonglong a, int fieldWidth, int base, QChar fillChar) const const
QString fromLatin1(const char *str, int size)
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Sun Nov 27 2022 04:10:03 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.