/usr/include/KDb3/KDbToken.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 | /****************************************************************************
* Created by generate_parser_code.sh
* WARNING! All changes made in this file will be lost!
****************************************************************************/
/* This file is part of the KDE project
Copyright (C) 2015 Jarosław Staniek <staniek@kde.org>
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_TOKEN_H
#define KDB_TOKEN_H
#include "kdb_export.h"
#include <QDebug>
class KDbDriver;
/*! @brief A type-safe KDbSQL token
It can be used in KDb expressions
@see KDbExpression */
class KDB_EXPORT KDbToken
{
public:
//! @todo add KDbToken(const QByteArray &name)
//! Creates an invalid token
inline KDbToken() : v(0) {}
KDbToken(const KDbToken &other) : v(other.v) {}
//! Creates a single-character token
//! Only characters that belong to the grammar are accepted:
//! ';' ',' '.' '>' '<' '=' '+' '-' '&' '|' '/' '*' '%' '~' '(' ')'
//! Invalid KDbToken is created for character that is not accepted.
KDbToken(char charToken);
//! @return true if this token is valid
inline bool isValid() const { return v != 0; }
//! @return name of this token
//! Useful for debugging.
//! For example "NOT_EQUAL" string is returned for the NOT_EQUAL token.
//! A single character is returned for printable single-character tokens.
//! A number is returned for non-printable single-character.
//! "<INVALID_TOKEN>" is returned for an invalid string.
QString name() const;
//! @return string interpretation of this token (as visibe to the user)
//! For example "<>" is returned for the NOT_EQUAL token.
//! Empty string is returned for an invalid string
//! The result may depend on the optional @a driver parameter.
//! If @a driver is @c nullptr, representation for portable KDbSQL dialect is returned.
QString toString(const KDbDriver *driver = nullptr) const;
//! Like toString(const KDbDriver *driver)
static QString toString(KDbToken token, const KDbDriver *driver = nullptr);
//! Maximum character token value (253)
static const int maxCharTokenValue;
//! Maximum character token value
static const int maxTokenValue;
//! @return character equivalent of this token
//! Only character-based tokens are supported this way (toInt() <= maxCharTokenValue).
//! For unsupported tokens @c nullptr is returned.
inline char toChar() const { return v <= maxCharTokenValue ? v : 0; }
//! @return numeric value of this token
inline int value() const { return v; }
//! @return true if this token is equal to @a other token
inline bool operator==(KDbToken other) const { return v == other.v; }
//! @return true if this token is not equal to @a other token
inline bool operator!=(KDbToken other) const { return v != other.v; }
//! @return true if this token is equal to @a other token
inline bool operator==(char charToken) const { return v == charToken; }
//! @return true if this token is not equal to @a other token
inline bool operator!=(char charToken) const { return v != charToken; }
static QList<KDbToken> allTokens();
// -- constants go here --
static const KDbToken SQL_TYPE;
static const KDbToken AS;
static const KDbToken AS_EMPTY;
static const KDbToken ASC;
static const KDbToken AUTO_INCREMENT;
static const KDbToken BIT;
static const KDbToken BITWISE_SHIFT_LEFT;
static const KDbToken BITWISE_SHIFT_RIGHT;
static const KDbToken BY;
static const KDbToken CHARACTER_STRING_LITERAL;
static const KDbToken CONCATENATION;
static const KDbToken CREATE;
static const KDbToken DESC;
static const KDbToken DISTINCT;
static const KDbToken DOUBLE_QUOTED_STRING;
static const KDbToken FROM;
static const KDbToken JOIN;
static const KDbToken KEY;
static const KDbToken LEFT;
static const KDbToken LESS_OR_EQUAL;
static const KDbToken GREATER_OR_EQUAL;
static const KDbToken SQL_NULL;
static const KDbToken SQL_IS;
static const KDbToken SQL_IS_NULL;
static const KDbToken SQL_IS_NOT_NULL;
static const KDbToken ORDER;
static const KDbToken PRIMARY;
static const KDbToken SELECT;
static const KDbToken INTEGER_CONST;
static const KDbToken REAL_CONST;
static const KDbToken RIGHT;
static const KDbToken SQL_ON;
static const KDbToken DATE_CONST;
static const KDbToken DATETIME_CONST;
static const KDbToken TIME_CONST;
static const KDbToken TABLE;
static const KDbToken IDENTIFIER;
static const KDbToken IDENTIFIER_DOT_ASTERISK;
static const KDbToken QUERY_PARAMETER;
static const KDbToken VARCHAR;
static const KDbToken WHERE;
static const KDbToken SQL;
static const KDbToken SQL_TRUE;
static const KDbToken SQL_FALSE;
static const KDbToken UNION;
static const KDbToken SCAN_ERROR;
static const KDbToken AND;
static const KDbToken BETWEEN;
static const KDbToken NOT_BETWEEN;
static const KDbToken EXCEPT;
static const KDbToken SQL_IN;
static const KDbToken INTERSECT;
static const KDbToken LIKE;
static const KDbToken ILIKE;
static const KDbToken NOT_LIKE;
static const KDbToken NOT;
static const KDbToken NOT_EQUAL;
static const KDbToken NOT_EQUAL2;
static const KDbToken OR;
static const KDbToken SIMILAR_TO;
static const KDbToken NOT_SIMILAR_TO;
static const KDbToken XOR;
static const KDbToken UMINUS;
//! Custom tokens are not used in parser but used as an extension in expression classes.
static const KDbToken BETWEEN_AND;
static const KDbToken NOT_BETWEEN_AND;
// -- end of constants --
class List;
private:
inline KDbToken(int value) : v(value) {}
int v;
};
//! Sends information about token @a token to debug output @a dbg.
KDB_EXPORT QDebug operator<<(QDebug dbg, KDbToken token);
#endif
|