This file is indexed.

/usr/include/KDb3/KDbExpressionData.h is in libkdb3-dev 3.1.0-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
/* This file is part of the KDE project
   Copyright (C) 2003-2015 Jarosław Staniek <staniek@kde.org>

   Based on nexp.cpp : Parser module of Python-like language
   (C) 2001 Jarosław Staniek, MIMUW (www.mimuw.edu.pl)

   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Library General Public
   License as published by the Free Software Foundation; either
   version 2 of the License, or (at your option) any later version.

   This library 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
   Library General Public License for more details.

   You should have received a copy of the GNU Library General Public License
   along with this library; see the file COPYING.LIB.  If not, write to
   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301, USA.
 */

#ifndef KDB_EXPRESSION_P_H
#define KDB_EXPRESSION_P_H

#include "config-kdb.h"
#include "KDbToken.h"
#include "KDbField.h"

class KDbConstExpressionData;
class KDbEscapedString;
class KDbExpressionData;
class KDbParseInfo;
class KDbQueryParameterExpressionData;
class KDbQuerySchemaParameter;
class KDbQuerySchemaParameterValueListIterator;
class KDbUnaryExpressionData;

namespace KDb
{
typedef QList<const KDbExpressionData*> ExpressionCallStack;

//! Classes of expressions
enum ExpressionClass {
    UnknownExpression,
    UnaryExpression,
    ArithmeticExpression,
    LogicalExpression,
    RelationalExpression,
    SpecialBinaryExpression,
    ConstExpression,
    VariableExpression,
    FunctionExpression,
    AggregationExpression,
    FieldListExpression,
    TableListExpression,
    ArgumentListExpression,
    QueryParameterExpression,
    LastExpressionClass = QueryParameterExpression //!< This line should be at the end of the list
};
}

typedef QExplicitlySharedDataPointer<KDbExpressionData> ExplicitlySharedExpressionDataPointer;

//! Internal data class used to implement implicitly shared class KDbExpression.
//! Provides thread-safe reference counting.
class KDB_TESTING_EXPORT KDbExpressionData : public QSharedData
{
public:
    KDbExpressionData();

    /*Data(const Data& other)
    : QSharedData(other)
    , token(other.token)
    , expressionClass(other.expressionClass)
    , parent(other.parent)
    , children(other.children)
    {
        kdbDebug() << "KDbExpressionData" << ref;
    }*/

    virtual ~KDbExpressionData();

    //! @see KDbExpression::token()
    KDbToken token;
    //! @see KDbExpression::expressionClass()
    KDb::ExpressionClass expressionClass;
    ExplicitlySharedExpressionDataPointer parent;
    QList<ExplicitlySharedExpressionDataPointer> children;
    KDbField::Type type() const; //!< @return type of this expression;
    bool isValid() const;
    bool isTextType() const;
    bool isIntegerType() const;
    bool isNumericType() const;
    bool isFPNumericType() const;
    bool isDateTimeType() const;
    KDbEscapedString toString(const KDbDriver *driver,
                              KDbQuerySchemaParameterValueListIterator *params = nullptr,
                              KDb::ExpressionCallStack *callStack = nullptr) const;
    virtual void getQueryParameters(QList<KDbQuerySchemaParameter> *params);
    bool validate(KDbParseInfo *parseInfo);
    virtual KDbExpressionData* clone();

    template <typename T>
    const T* convertConst() const { return dynamic_cast<const T*>(this); }

    template <typename T>
    T* convert() { return dynamic_cast<T*>(this); }

    //! Sends information about this expression  to debug output @a dbg.
    QDebug debug(QDebug dbg, KDb::ExpressionCallStack *callStack) const;

    KDbField::Type type(KDb::ExpressionCallStack *callStack) const;

    bool validate(KDbParseInfo *parseInfo, KDb::ExpressionCallStack *callStack);

protected:
    //! Sends information about this expression  to debug output @a dbg (internal).
    virtual void debugInternal(QDebug dbg, KDb::ExpressionCallStack *callStack) const;

    virtual KDbField::Type typeInternal(KDb::ExpressionCallStack *callStack) const;

    virtual KDbEscapedString toStringInternal(const KDbDriver *driver,
                                              KDbQuerySchemaParameterValueListIterator *params,
                                              KDb::ExpressionCallStack *callStack) const;

    virtual bool validateInternal(KDbParseInfo *parseInfo, KDb::ExpressionCallStack *callStack);

    bool addToCallStack(QDebug *dbg, KDb::ExpressionCallStack *callStack) const;
};

//! Internal data class used to implement implicitly shared class KDbNArgExpression.
//! Provides thread-safe reference counting.
class KDbNArgExpressionData : public KDbExpressionData
{
    Q_DECLARE_TR_FUNCTIONS(KDbNArgExpressionData)
public:
    KDbNArgExpressionData();
    ~KDbNArgExpressionData() override;

    void getQueryParameters(QList<KDbQuerySchemaParameter> *params) override;
    KDbNArgExpressionData* clone() override;
    bool containsInvalidArgument() const;
    bool containsNullArgument() const;

protected:
    //! Sends information about this expression  to debug output @a dbg (internal).
    void debugInternal(QDebug dbg, KDb::ExpressionCallStack *callStack) const override;

    KDbField::Type typeInternal(KDb::ExpressionCallStack *callStack) const override;

    KDbEscapedString toStringInternal(const KDbDriver *driver,
                                      KDbQuerySchemaParameterValueListIterator *params,
                                      KDb::ExpressionCallStack *callStack) const override;

    bool validateInternal(KDbParseInfo *parseInfo, KDb::ExpressionCallStack *callStack) override;
};

//! Internal data class used to implement implicitly shared class KDbUnaryExpression.
//! Provides thread-safe reference counting.
class KDbUnaryExpressionData : public KDbExpressionData
{
public:
    KDbUnaryExpressionData();
    ~KDbUnaryExpressionData() override;

    void getQueryParameters(QList<KDbQuerySchemaParameter> *params) override;
    KDbUnaryExpressionData* clone() override;
    inline ExplicitlySharedExpressionDataPointer arg() const {
        return children.isEmpty() ? ExplicitlySharedExpressionDataPointer() : children.first();
    }

protected:
    //! Sends information about this expression  to debug output @a dbg (internal).
    void debugInternal(QDebug dbg, KDb::ExpressionCallStack *callStack) const override;

    KDbEscapedString toStringInternal(const KDbDriver *driver,
                                      KDbQuerySchemaParameterValueListIterator *params,
                                      KDb::ExpressionCallStack *callStack) const override;

    KDbField::Type typeInternal(KDb::ExpressionCallStack *callStack) const override;

    bool validateInternal(KDbParseInfo *parseInfo, KDb::ExpressionCallStack *callStack) override;
};

//! Internal data class used to implement implicitly shared class KDbBinaryExpression.
//! Provides thread-safe reference counting.
class KDbBinaryExpressionData : public KDbExpressionData
{
    Q_DECLARE_TR_FUNCTIONS(KDbBinaryExpressionData)
public:
    KDbBinaryExpressionData();
    ~KDbBinaryExpressionData() override;

    void getQueryParameters(QList<KDbQuerySchemaParameter> *params) override;
    KDbBinaryExpressionData *clone() override;
    ExplicitlySharedExpressionDataPointer left() const;
    ExplicitlySharedExpressionDataPointer right() const;

protected:
    void setLeft(const KDbExpressionData& left);

    //! Sends information about this expression  to debug output @a dbg (internal).
    void debugInternal(QDebug dbg, KDb::ExpressionCallStack *callStack) const override;

    KDbEscapedString toStringInternal(const KDbDriver *driver,
                                      KDbQuerySchemaParameterValueListIterator *params,
                                      KDb::ExpressionCallStack *callStack) const override;

    KDbField::Type typeInternal(KDb::ExpressionCallStack *callStack) const override;

    bool validateInternal(KDbParseInfo *parseInfo, KDb::ExpressionCallStack *callStack) override;
};

//! Internal data class used to implement implicitly shared class KDbConstExpression.
//! Provides thread-safe reference counting.
class KDbConstExpressionData : public KDbExpressionData
{
public:
    explicit KDbConstExpressionData(const QVariant& aValue = QVariant());
    ~KDbConstExpressionData() override;

    QVariant value;
    void getQueryParameters(QList<KDbQuerySchemaParameter> *params) override;
    KDbConstExpressionData *clone() override;

protected:
    //! Sends information about this expression  to debug output @a dbg (internal).
    void debugInternal(QDebug dbg, KDb::ExpressionCallStack *callStack) const override;

    KDbEscapedString toStringInternal(const KDbDriver *driver,
                                      KDbQuerySchemaParameterValueListIterator *params,
                                      KDb::ExpressionCallStack *callStack) const override;

    KDbField::Type typeInternal(KDb::ExpressionCallStack *callStack) const override;

    bool validateInternal(KDbParseInfo *parseInfo, KDb::ExpressionCallStack *callStack) override;
};

//! Internal data class used to implement implicitly shared class KDbQueryParameterExpression.
//! Provides thread-safe reference counting.
class KDbQueryParameterExpressionData : public KDbConstExpressionData
{
public:
    KDbQueryParameterExpressionData();
    KDbQueryParameterExpressionData(KDbField::Type type, const QVariant& value);
    ~KDbQueryParameterExpressionData() override;

    KDbField::Type m_type;
    void getQueryParameters(QList<KDbQuerySchemaParameter> *params) override;
    KDbQueryParameterExpressionData* clone() override;

protected:
    //! Sends information about this expression  to debug output @a dbg (internal).
    void debugInternal(QDebug dbg, KDb::ExpressionCallStack *callStack) const override;

    KDbEscapedString toStringInternal(const KDbDriver *driver,
                                      KDbQuerySchemaParameterValueListIterator *params,
                                      KDb::ExpressionCallStack *callStack) const override;

    KDbField::Type typeInternal(KDb::ExpressionCallStack *callStack) const override;

    bool validateInternal(KDbParseInfo *parseInfo, KDb::ExpressionCallStack *callStack) override;
};

//! Internal data class used to implement implicitly shared class KDbVariableExpression.
//! Provides thread-safe reference counting.
class KDbVariableExpressionData : public KDbExpressionData
{
    Q_DECLARE_TR_FUNCTIONS(KDbVariableExpressionData)
public:
    KDbVariableExpressionData();
    explicit KDbVariableExpressionData(const QString& aName);
    ~KDbVariableExpressionData() override;

    /*! Verbatim name as returned by scanner. */
    QString name;

    /*! 0 by default. After successful validate() it will point to a field,
     if the variable is of a form "tablename.fieldname" or "fieldname",
     otherwise (eg. for asterisks) still 0.
     Only meaningful for column expressions within a query. */
    KDbField *field;

    /*! -1 by default. After successful validate() it will contain a position of a table
     within query that needs to be bound to the field.
     This value can be either be -1 if no binding is needed.
     This value is used in the Parser to call
      KDbQuerySchema::addField(KDbField* field, int bindToTable);
     Only meaningful for column expressions within a query. */
    int tablePositionForField;

    /*! 0 by default. After successful validate() it will point to a table
     that is referenced by asterisk, i.e. "*.tablename".
     This is set to @c nullptr if this variable is not an asterisk of that form. */
    KDbTableSchema *tableForQueryAsterisk;

    void getQueryParameters(QList<KDbQuerySchemaParameter> *params) override;
    KDbVariableExpressionData* clone() override;

protected:
    //! Sends information about this expression  to debug output @a dbg (internal).
    void debugInternal(QDebug dbg, KDb::ExpressionCallStack *callStack) const override;

    KDbEscapedString toStringInternal(const KDbDriver *driver,
                                      KDbQuerySchemaParameterValueListIterator *params,
                                      KDb::ExpressionCallStack *callStack) const override;

    KDbField::Type typeInternal(KDb::ExpressionCallStack *callStack) const override;

    /*! Validation. Sets field, tablePositionForField
     and tableForQueryAsterisk members.
     See addColumn() in parse.y to see how it's used on column adding. */
    bool validateInternal(KDbParseInfo *parseInfo, KDb::ExpressionCallStack *callStack) override;
};

//! Internal data class used to implement implicitly shared class KDbFunctionExpression.
//! Provides thread-safe reference counting.
class KDbFunctionExpressionData : public KDbExpressionData
{
    Q_DECLARE_TR_FUNCTIONS(KDbFunctionExpressionData)
public:
    KDbFunctionExpressionData();
    explicit KDbFunctionExpressionData(const QString &aName,
                                       ExplicitlySharedExpressionDataPointer arguments
                                       = ExplicitlySharedExpressionDataPointer());
    ~KDbFunctionExpressionData() override;

    QString name;
    ExplicitlySharedExpressionDataPointer args;

    void getQueryParameters(QList<KDbQuerySchemaParameter> *params) override;
    KDbFunctionExpressionData* clone() override;

    void setArguments(ExplicitlySharedExpressionDataPointer arguments);

    static KDbEscapedString toString(const QString &name,
                                     const KDbDriver *driver,
                                     const KDbNArgExpressionData *args,
                                     KDbQuerySchemaParameterValueListIterator *params,
                                     KDb::ExpressionCallStack *callStack);

protected:
    //! Sends information about this expression  to debug output @a dbg (internal).
    void debugInternal(QDebug dbg, KDb::ExpressionCallStack *callStack) const override;

    KDbEscapedString toStringInternal(const KDbDriver *driver,
                                      KDbQuerySchemaParameterValueListIterator *params,
                                      KDb::ExpressionCallStack *callStack) const override;

    KDbField::Type typeInternal(KDb::ExpressionCallStack *callStack) const override;

    /*! Validation. Sets field, tablePositionForField
     and tableForQueryAsterisk members.
     See addColumn() in parse.y to see how it's used on column adding. */
    bool validateInternal(KDbParseInfo *parseInfo, KDb::ExpressionCallStack *callStack) override;
};

QDebug operator<<(QDebug dbg, const KDbExpressionData& expr);

#endif