KDb

KDb.h
1/* This file is part of the KDE project
2 Copyright (C) 2004-2018 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 KDB_H
21#define KDB_H
22
23#include "KDbField.h"
24#include "KDbGlobal.h"
25#include "KDbSqlResult.h"
26#include "KDbTableSchema.h"
27
28class QDomNode;
29class QDomElement;
30class QDomDocument;
31
32class KDbConnection;
34class KDbDriver;
38class KDbResultable;
39class KDbResultInfo;
41class KDbVersionInfo;
42class tristate;
43
44namespace KDb
45{
46
47//! @return runtime information about version of the KDb library.
48//! @see KDbConnection::databaseVersion() KDbConnection::serverVersion() KDbDriverMetaData::version()
49KDB_EXPORT KDbVersionInfo version();
50
51/**
52 * @brief Deletes records using one generic criteria.
53 *
54 * @return @c true on success and @c false on failure and if @a conn is @c nullptr
55 */
56KDB_EXPORT bool deleteRecords(KDbConnection* conn, const QString &tableName,
57 const QString &keyname, KDbField::Type keytype, const QVariant &keyval);
58
59//! @overload
60inline bool deleteRecords(KDbConnection* conn, const KDbTableSchema &table,
61 const QString &keyname, KDbField::Type keytype, const QVariant &keyval)
62{
63 return deleteRecords(conn, table.name(), keyname, keytype, keyval);
64}
65
66//! @overload
67inline bool deleteRecords(KDbConnection* conn, const QString &tableName,
68 const QString &keyname, const QString &keyval)
69{
70 return deleteRecords(conn, tableName, keyname, KDbField::Text, keyval);
71}
72
73//! @overload
74inline bool deleteRecords(KDbConnection* conn, const KDbTableSchema &table,
75 const QString &keyname, const QString &keyval)
76{
77 return deleteRecords(conn, table.name(), keyname, keyval);
78}
79
80//! @overload
81inline bool deleteRecords(KDbConnection* conn, const KDbTableSchema &table,
82 const QString& keyname, int keyval)
83{
84 return deleteRecords(conn, table, keyname, KDbField::Integer, keyval);
85}
86
87//! @overload
88inline bool deleteRecords(KDbConnection* conn, const QString &tableName,
89 const QString& keyname, int keyval)
90{
91 return deleteRecords(conn, tableName, keyname, KDbField::Integer, keyval);
92}
93
94//! Deletes records with two generic criterias.
95KDB_EXPORT bool deleteRecords(KDbConnection* conn, const QString &tableName,
96 const QString &keyname1, KDbField::Type keytype1, const QVariant& keyval1,
97 const QString &keyname2, KDbField::Type keytype2, const QVariant& keyval2);
98
99//! Deletes records with three generic criterias.
100KDB_EXPORT bool deleteRecords(KDbConnection* conn, const QString &tableName,
101 const QString &keyname1, KDbField::Type keytype1, const QVariant& keyval1,
102 const QString &keyname2, KDbField::Type keytype2, const QVariant& keyval2,
103 const QString &keyname3, KDbField::Type keytype3, const QVariant& keyval3);
104
105//! Deletes all records from table @a tableName.
106KDB_EXPORT bool deleteAllRecords(KDbConnection* conn, const QString &tableName);
107
108//! @overload bool deleteAllRecords(KDbConnection*, const QString&);
109inline bool deleteAllRecords(KDbConnection* conn, const KDbTableSchema &table)
110{
111 return KDb::deleteAllRecords(conn, table.name());
112}
113
114/**
115 * Returns value of last inserted record for an autoincrement field
116 *
117 * This method internally fetches values of the last inserted record for which @a result was
118 * returned and returns selected field's value. The field belong to @a tableName table.
119 * The field must be of integer type, there must be a record inserted using query for which the @a
120 * result is returned.
121 * std::numeric_limits<quint64>::max() is returned on error or if @a result is null.
122 * The last inserted record is identified by a magical record identifier, usually called ROWID
123 * (PostgreSQL has it as well as SQLite;
124 * see KDbDriverBehavior::ROW_ID_FIELD_RETURNS_LAST_AUTOINCREMENTED_VALUE).
125 * ROWID's value will be assigned back to @a recordId if this pointer is not @c nullptr.
126 */
128 const QString &autoIncrementFieldName,
129 const QString &tableName, quint64 *recordId = nullptr);
130
131/**
132 * @overload
133 *
134 * Accepts @a recordId that can be obtained from KDbPreparedStatement::lastInsertRecordId()
135 * or KDbSqlResult::lastInsertRecordId().
136*/
137KDB_EXPORT quint64 lastInsertedAutoIncValue(KDbConnection *conn, const quint64 recordId,
138 const QString &autoIncrementFieldName,
139 const QString &tableName);
140
141/**
142@overload
143*/
145 const QString &autoIncrementFieldName,
146 const KDbTableSchema &table, quint64 *recordId = nullptr)
147{
148 return lastInsertedAutoIncValue(result, autoIncrementFieldName, table.name(), recordId);
149}
150
151/*! @return list of field types for field type group @a typeGroup. */
153
154/*! @return list of translated field type names for field type group @a typeGroup. */
156
157/*! @return list of (nontranslated) field type names for field type group @a typeGroup. */
159
160/*! @return default field type for field type group @a typeGroup,
161 for example, KDbField::Integer for KDbField::IntegerGroup.
162 It is used e.g. in KexiAlterTableDialog, to properly fill
163 'type' property when user selects type group for a field. */
165
166/*! @return a slightly simplified field type name type @a type.
167 For KDbField::BLOB type it returns a translated "Image" string or other, depending on the mime type.
168 For numbers (either floating-point or integer) it returns a translated "Number" string.
169 For other types KDbField::typeGroupName() is returned. */
170//! @todo support names of other BLOB subtypes
172
173/*! @return true if value @a value represents an empty (but not null) value.
174 - Case 1: If field type @a type is of any text type (KDbField::isTextType(type) == true)
175 then the function returns true if @a value casted to a QString value is empty and not null.
176 - Case 2: If field type @a type is KDbField::BLOB then the function returns if @a value casted
177 to a QByteArray value is empty and not null.
178 - Case 3: If field type @a type is of any other type then the function returns true if value.isNull().
179 @see KDbField::hasEmptyProperty() */
180KDB_EXPORT bool isEmptyValue(KDbField::Type type, const QVariant &value);
181
182/**
183 * @brief Sets HTML-formatted error message with extra details obtained from result object
184 *
185 * Sets string pointed by @a msg to an error message retrieved from @a resultable,
186 * and string pointed by @a details to details of this error (server message and result number).
187 * Does nothing if there is no error (resultable.result().isError() == false) or if @a msg or
188 * @a details is @c nullptr.
189 * In this case strings pointer by @a msg and @a details strings are not changed.
190 * If the string pointed by @a msg is not empty, it is not modified and message obtained from
191 * @a resultable is appended to the string pointed by @a details instead.
192 */
193KDB_EXPORT void getHTMLErrorMesage(const KDbResultable& resultable, QString *msg, QString *details);
194
195/**
196 * @overload
197 *
198 * This methods works similarly but appends both a message and a description to string pointed by
199 * @a msg.
200 */
201KDB_EXPORT void getHTMLErrorMesage(const KDbResultable& resultable, QString *msg);
202
203/**
204 * @overload
205 *
206 * This methods similarly but outputs message to @a info instead.
207 */
208KDB_EXPORT void getHTMLErrorMesage(const KDbResultable& resultable, KDbResultInfo *info);
209
210/*! Function useful for building WHERE parts of SQL statements.
211 Constructs an SQL string like "fielname = value" for specific @a drv driver,
212 field type @a t, @a fieldName and @a value. If @a value is null, "fieldname IS NULL"
213 string is returned. */
215 const QString& fieldName, const QVariant& value);
216
217/**
218 * @brief Finds an identifier for object @a objName of type @a objType
219 *
220 * On success true is returned and *id is set to the value of the identifier.
221 * On failure or if @a conn is @c nullptr, @c false is returned.
222 * If there is no object with specified name and type, @c cancelled value is returned.
223*/
224KDB_EXPORT tristate idForObjectName(KDbConnection* conn, int *id, const QString& objName,
225 int objType);
226
227/**
228 * @brief Shows connection test dialog
229 *
230 * Shows connection test dialog with a progress bar indicating connection testing
231 * (within a separate thread). @a data is used to perform a (temporary) test connection.
232 * @a msgHandler can be used for error handling. @a parent is used as dialog's parent widget.
233 *
234 * The dialog is modal so the call is blocking.
235 *
236 * On successful connecting, a successfull message of type KDbMessageHandler::Information is passed
237 * to @a msgHandler. After testing, temporary connection is closed.
238 *
239 * @return @c true for successfull connecting, @c for failed connecting and @c cancelled if the test
240 * has been cancelled.
241 */
242KDB_EXPORT tristate showConnectionTestDialog(QWidget* parent, const KDbConnectionData& data,
243 KDbMessageHandler* msgHandler);
244
245//! Used in splitToTableAndFieldParts().
247 FailIfNoTableOrFieldName = 0, //!< default value for splitToTableAndFieldParts()
248 SetFieldNameIfNoTableName = 1 //!< see splitToTableAndFieldParts()
250
251/*! Splits @a string like "table.field" into "table" and "field" parts.
252 On success, a table name is passed to @a tableName and a field name is passed to @a fieldName.
253 The function fails if either:
254 - @a string is empty, or
255 - @a string does not contain '.' character and @a option is FailIfNoTableOrFieldName
256 (the default), or
257 - '.' character is the first of last character of @a string (in this case table name
258 or field name could become empty what is not allowed).
259 - @a tableName or @a fieldName is @c nullptr
260
261 If @a option is SetFieldNameIfNoTableName and @a string does not contain '.',
262 @a string is passed to @a fieldName and @a tableName is set to QString()
263 without failure.
264
265 If function fails, @a tableName and @a fieldName remain unchanged.
266 @return true on success. */
267KDB_EXPORT bool splitToTableAndFieldParts(const QString& string,
268 QString *tableName, QString *fieldName,
270
271/*! @return true if @a type supports "visibleDecimalPlaces" property. */
273
274/*! @return string constructed by converting @a value.
275 * If @a decimalPlaces is < 0, all meaningful fractional digits are returned (up to 10).
276 * If @a automatically is 0, just integer part is returned.
277 * If @a automatically is > 0, fractional part should take exactly
278 N digits: if the fractional part is shorter than N, additional zeros are appended.
279 Examples:
280 * numberToString(12.345, 6) == "12.345000"
281 * numberToString(12.345, 0) == "12"
282 * numberToString(12.345, -1) == "12.345"
283 * numberToString(12.0, -1) == "12"
284 * numberToString(0.0, -1) == "0"
285
286 @note No rounding is performed
287 @note No thousands group separator is used. Decimal symbol is '.'.
288
289 @see KDb::numberToLocaleString() KDbField::visibleDecimalPlaces() */
290KDB_EXPORT QString numberToString(double value, int decimalPlaces);
291
292/**
293 * @brief Returns number converted to string using default locale
294 *
295 * This method is similar to KDb::numberToString() but the string is formatted using QLocale::toString().
296 *
297 * @see KDb::numberToString() KDbField::visibleDecimalPlaces()
298 */
299KDB_EXPORT QString numberToLocaleString(double value, int decimalPlaces);
300
301/**
302 * @overload
303 *
304 * Returns number converted to string using specified locale.
305 */
306KDB_EXPORT QString numberToLocaleString(double value, int decimalPlaces, const QLocale &locale);
307
308//! @return true if @a propertyName is a builtin field property.
309KDB_EXPORT bool isBuiltinTableFieldProperty(const QByteArray& propertyName);
310
311//! @return true if @a propertyName is an extended field property.
312KDB_EXPORT bool isExtendedTableFieldProperty(const QByteArray& propertyName);
313
314//! @return true if @a propertyName is belongs to lookup field's schema.
315KDB_EXPORT bool isLookupFieldSchemaProperty(const QByteArray& propertyName);
316
317/*! @return type of field for integer value @a type.
318 If @a type cannot be casted to KDbField::Type or is not normal type,
319 i.e. @a type > KDbField::LastType (e.g. KDbField::Null), KDbField::InvalidType is returned.
320 This can be used when type information is deserialized from a string or QVariant.
321 @see KDbField::typesCount() KDbField::specialTypesCount() */
322KDB_EXPORT KDbField::Type intToFieldType(int type);
323
324/*! @return type group of field for integer value @a typeGroup.
325 If @a typeGroup cannot be casted to KDbField::TypeGroup, KDbField::InvalidGroup is returned.
326 This can be used when type information is deserialized from a string or QVariant.
327 @see KDbField::typeGroupsCount() */
328KDB_EXPORT KDbField::TypeGroup intToFieldTypeGroup(int typeGroup);
329
330/*! Gets property values for the lookup schema @a lookup.
331 @a values is not cleared before filling. This function is used e.g. for altering table design.
332 Nothing is performed if @a values is @c nullptr.
333 If @a lookup is @c nullptr, all returned values are null.
334*/
335KDB_EXPORT void getProperties(const KDbLookupFieldSchema *lookup, QMap<QByteArray, QVariant> *values);
336
337/*! Gets property values for @a field.
338 Properties from extended schema are included. @a values is cleared before filling.
339 The same number of properties in the same order is returned.
340 This function is used e.g. for altering table design.
341 Nothing is performed if @a values is @c nullptr.
342 */
343KDB_EXPORT void getFieldProperties(const KDbField &field, QMap<QByteArray, QVariant> *values);
344
345/*! Sets property values for @a field. @return true if all the values are valid and allowed.
346 On failure contents of @a field is undefined.
347 Properties from extended schema are also supported.
348 This function is used e.g. by KDbAlterTableHandler when property information comes in form of text.
349 If @a field is @c nullptr nothing is performed and @c false is returned.
350 */
351KDB_EXPORT bool setFieldProperties(KDbField *field, const QMap<QByteArray, QVariant>& values);
352
353/*! Sets value of a single property for @a field. @return true if the property has been found and
354 the value is valid for this property. On failure contents of @a field is not modified.
355 Properties from extended schema are also supported as well as custom properties
356 (using KDbField::setCustomProperty()).
357
358 This function is used e.g. by KDbAlterTableHandler when property information comes in form of text.
359 If @a field is @c nullptr nothing is performed and @c false is returned.
360 */
361KDB_EXPORT bool setFieldProperty(KDbField *field, const QByteArray &propertyName,
362 const QVariant &value);
363
364/*! @return property value loaded from a DOM @a node, written in a QtDesigner-like
365 notation: &lt;number&gt;int&lt;/number&gt; or &lt;bool&gt;bool&lt;/bool&gt;, etc. Supported types are
366 "string", "cstring", "bool", "number". For invalid values null QVariant is returned.
367 Validity of the returned value can be checked using the @a ok parameter and QVariant::type(). */
368KDB_EXPORT QVariant loadPropertyValueFromDom(const QDomNode& node, bool *ok);
369
370/*! Convenience version of loadPropertyValueFromDom(). @return int value. */
371KDB_EXPORT int loadIntPropertyValueFromDom(const QDomNode& node, bool* ok);
372
373/*! Convenience version of loadPropertyValueFromDom(). @return QString value. */
374KDB_EXPORT QString loadStringPropertyValueFromDom(const QDomNode& node, bool* ok);
375
376/*! Creates a new DOM element named @a elementName with numeric value @a value in @a doc document
377 within parent element @a parentEl. The value will be enclosed in "number" element and
378 "elementName" element.
379 Example: saveNumberElementToDom(doc, parentEl, "height", 15) creates:
380 @code
381 <height><number>15</number></height>
382 @endcode
383 @return the reference to element created with tag elementName.
384 Null element is returned if @a doc or @a parentEl is @c nullptr or if @a elementName is empty.
385*/
387 const QString& elementName, int value);
388
389/*! Creates a new DOM element named @a elementName with boolean value @a value in @a doc document
390 within parent element @a parentEl.
391 This method is like saveNumberElementToDom() but creates "bool" tags. True/false values will be
392 saved as "true"/"false" strings.
393 Example: saveBooleanElementToDom(doc, parentEl, "visible", true) creates:
394 @code
395 <visible><bool>true</bool></visible>
396 @endcode
397 @return the reference to element created with tag elementName.
398 Null element is returned if @a doc or @a parentEl is @c nullptr or if @a elementName is empty.
399*/
401 const QString& elementName, bool value);
402
403//! @return equivalent of empty (default) value that can be set for a database field of type @a type
404/*! In particular returns:
405 - empty string for text types,
406 - 0 for integer and floating-point types,
407 - false for boolean types,
408 - a null byte array for BLOB type,
409 - current date, time, date+time is returned (measured at client side) for date, time and
410 date/time types respectively,
411 - a null QVariant for unsupported values such as KDbField::InvalidType. */
413
414//! @return a value that can be set for a database field of type @a type having "notEmpty" property set.
415/*! It works in a similar way as @ref QVariant KDb::emptyValueForFieldType(KDbField::Type type)
416 with the following differences:
417 - " " string (a single space) is returned for Text and LongText types
418 - a byte array with saved "filenew" PNG image (icon) for BLOB type
419 Returns null QVariant for unsupported values like KDbField::InvalidType. */
421
422/*! @return true if the @a word is an reserved KDBSQL keyword
423 See generated/sqlkeywords.cpp.
424 @todo add function returning list of keywords. */
425KDB_EXPORT bool isKDbSqlKeyword(const QByteArray& word);
426
427//! @return @a string string with applied KDBSQL identifier escaping
428/*! This escaping can be used for field, table, database names, etc.
429 Use it for user-visible backend-independent statements.
430 @see KDb::escapeIdentifierAndAddQuotes() */
431KDB_EXPORT QString escapeIdentifier(const QString& string);
432
433//! @overload QString escapeIdentifier(const QString&)
434KDB_EXPORT QByteArray escapeIdentifier(const QByteArray& string);
435
436//! @return @a string string with applied KDBSQL identifier escaping and enclosed in " quotes
437/*! This escaping can be used for field, table, database names, etc.
438 Use it for user-visible backend-independent statements.
439 @see KDb::escapeIdentifier */
440KDB_EXPORT QString escapeIdentifierAndAddQuotes(const QString& string);
441
442//! @overload QString escapeIdentifierAndAddQuotes(const QString&)
443KDB_EXPORT QByteArray escapeIdentifierAndAddQuotes(const QByteArray& string);
444
445/*! @return escaped string @a string for the KDBSQL dialect,
446 i.e. doubles single quotes ("'") and inserts the string into single quotes.
447 Quotes "'" are prepended and appended.
448 Also escapes \\n, \\r, \\t, \\\\, \\0.
449 Use it for user-visible backend-independent statements.
450 @see unescapeString() */
451KDB_EXPORT QString escapeString(const QString& string);
452
453/**
454 * @brief Returns escaped string @a string
455 *
456 * If @a drv driver is present, it is used to perform escaping, otherwise escapeString() is used
457 * so the KDBSQL dialect-escaping is performed.
458 *
459 * @since 3.1.0
460 */
461KDB_EXPORT KDbEscapedString escapeString(KDbDriver *drv, const QString& string);
462
463/**
464 * @brief Returns escaped string @a string
465 *
466 * If @a conn is present, its driver is used to perform escaping, otherwise escapeString() is used
467 * so the KDBSQL dialect-escaping is performed.
468 *
469 * @since 3.1.0
470 */
471KDB_EXPORT KDbEscapedString escapeString(KDbConnection *conn, const QString& string);
472
473//! Unescapes characters in string @a string for the KDBSQL dialect.
474/** The operation depends on @a quote character, which can be be ' or ".
475 * @a string is assumed to be properly constructed. This is assured by the lexer's grammar.
476 * Used by lexer to recognize the CHARACTER_STRING_LITERAL token.
477 * @return unescaped string and sets value pointed by @a errorPosition (if any) to -1 on success;
478 * and to index of problematic character on failure.
479 * The function fails when unsupported @a quote character is passed or for unsupported sequences.
480 *
481 * Example sequences for ' character quote:
482 * - \' -> ' (escaping)
483 * - \" -> " (escaping)
484 * - '' -> ' (repeated quote escapes too)
485 * - "" -> "" (repeated but this is not the quote)
486 * - ' -> (disallowed, escaping needed)
487 * - " -> "
488 * Example sequences for " character quote:
489 * - \' -> ' (escaping)
490 * - \" -> " (escaping)
491 * - " -> " (disallowed, escaping needed)
492 * - "" -> " (repeated quote escapes too)
493 * - '' -> '' (repeated but this is not the quote)
494 * - ' -> '
495 *
496 * Following sequences are always unescaped (selection based on a mix of MySQL and C/JavaScript):
497 * - \0 -> NULL (QChar())
498 * - \b -> backspace 0x8
499 * - \f -> form feed 0xc
500 * - \n -> new line 0xa
501 * - \r -> carriage return 0xd
502 * - \t -> horizontal tab 0x9
503 * - \v -> vertical tab 0xb
504 * - \\ -> backslash
505 * - \? -> ? (useful when '?' placeholders are used)
506 * - \% -> (useful when '%' wildcards are used e.g. for the LIKE operator)
507 * - \_ -> (useful when '_' pattern is used e.g. for the LIKE operator)
508 * - \xhh -> a character for which hh (exactly 2 digits) is interpreted as an hexadecimal
509 * number, 00 <= hh <= FF. Widely supported by programming languages.
510 * Can be also 00 <= hh <= ff.
511 * Example: \xA9 translates to "©".
512 * - \uxxxx -> 16-bit unicode character, exactly 4 digits, each x is a hexadecimal digit,
513 * case insensitive; known from JavaScript, Java, C/C++. 0000 <= xxxxxx <= FFFF
514 * Example: \u2665 translates to "♥".
515 * - \u{xxxxxx} -> 24-bit unicode "code point" character, each x is a hexadecimal digit,
516 * case insensitive; known from JavaScript (ECMAScript 6). 0 <= xxxxxx <= 10FFFF
517 * Example: \u{1D306} translates to "𝌆"
518 *
519 * @note Characters without special meaning can be escaped, but then the "\" character
520 * is skipped, e.g. "\a" == "a".
521 * @note Trailing "\" character in @a string is ignored.
522 * @note \nnn octal notation is not supported, it may be confusing and conflicting
523 * when combined with other characters (\0012 is not the same as \012).
524 * The industry is moving away from it and EcmaScript 5 deprecates it.
525 *
526 * See also:
527 * - https://dev.mysql.com/doc/refman/5.7/en/string-literals.html
528 * - https://en.wikipedia.org/wiki/Escape_sequences_in_C#Table_of_escape_sequences
529 * - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Grammar_and_types#Using_special_characters_in_strings
530 * - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Lexical_grammar#String_literals
531 */
532KDB_EXPORT QString unescapeString(const QString& string, char quote, int *errorPosition = nullptr);
533
534//! Escaping types for BLOBS. Used in escapeBLOB().
536 XHex = 1, //!< Escaping like X'1FAD', used by sqlite (hex numbers)
537 ZeroXHex, //!< Escaping like 0x1FAD, used by mysql (hex numbers)
538 Hex, //!< Escaping like 1FAD without quotes or prefixes
539 Octal, //!< Escaping like 'zk\\000$x', used by PostgreSQL
540 //!< (only non-printable characters are escaped using octal numbers);
541 //!< see https://www.postgresql.org/docs/9.5/interactive/datatype-binary.html
542 ByteaHex //!< "bytea hex" escaping, e.g. E'\xDEADBEEF'::bytea used by PostgreSQL
543 //!< (only non-printable characters are escaped using octal numbers);
544 //!< see https://www.postgresql.org/docs/9.5/interactive/datatype-binary.html
545};
546
547/*! @return a string containing escaped, printable representation of @a array.
548 Escaping is controlled by @a type. For empty array, QString() is returned,
549 so if you want to use this function in an SQL statement, empty arrays should be
550 detected and "NULL" string should be put instead.
551 This is helper, used in KDbDriver::escapeBLOB() and KDb::variantToString(). */
552KDB_EXPORT QString escapeBLOB(const QByteArray& array, BLOBEscapingType type);
553
554/*! @return byte array converted from @a data of length @a length.
555 If @a length is negative, the data is assumed to point to a null-terminated string
556 and its length is determined dynamically.
557 @a data is escaped in format used by PostgreSQL's bytea datatype
558 described at https://www.postgresql.org/docs/8.1/interactive/datatype-binary.html
559 This function is used by PostgreSQL KDb and migration drivers. */
560KDB_EXPORT QByteArray pgsqlByteaToByteArray(const char* data, int length = -1);
561
562/*! @return byte array converted from @a data of length @a length.
563 If @a length is negative, the data is assumed to point to a null-terminated string
564 and its length is determined dynamically.
565 @a data is escaped in format X'*', where * is one or more hexadecimal digits.
566 Both A-F and a-f letters are supported. Even and odd number of digits are supported.
567 If @a ok is not 0, *ok is set to result of the conversion.
568 See BLOBEscapingType::XHex. */
569KDB_EXPORT QByteArray xHexToByteArray(const char* data, int length = -1, bool *ok = nullptr);
570
571/*! @return byte array converted from @a data of length @a length.
572 If @a length is negative, the data is assumed to point to a null-terminated string
573 and its length is determined dynamically.
574 @a data is escaped in format 0x*, where * is one or more hexadecimal digits.
575 Both A-F and a-f letters are supported. Even and odd number of digits are supported.
576 If @a ok is not 0, *ok is set to result of the conversion.
577 See BLOBEscapingType::ZeroXHex. */
578KDB_EXPORT QByteArray zeroXHexToByteArray(const char* data, int length = -1, bool *ok = nullptr);
579
580/*! @return int list converted from string list.
581 If @a ok is not 0, *ok is set to result of the conversion. */
582KDB_EXPORT QList<int> stringListToIntList(const QStringList &list, bool *ok = nullptr);
583
584/*! @return string converted from list @a list.
585 Separators are ',' characters, "," and "\\" are escaped.
586 @see KDb::deserializeList() */
587KDB_EXPORT QString serializeList(const QStringList &list);
588
589/*! @return string list converted from @a data which was built using serializeList().
590 Separators are ',' characters, escaping is assumed as "\\,". */
591KDB_EXPORT QStringList deserializeList(const QString &data);
592
593/*! @return int list converted from @a data which was built using serializeList().
594 Separators are ',' characters, escaping is assumed as "\\,".
595 If @a ok is not 0, *ok is set to result of the conversion.
596 @see KDb::stringListToIntList() */
597KDB_EXPORT QList<int> deserializeIntList(const QString &data, bool *ok);
598
599/*! @return string value serialized from a variant value @a v.
600 This functions works like QVariant::toString() except the case when @a v is of type:
601 - QByteArray - in this case KDb::escapeBLOB(v.toByteArray(), KDb::BLOBEscapeHex) is used.
602 - QStringList - in this case KDb::serializeList(v.toStringList()) is used.
603
604 This function is needed for handling values of random type, for example "defaultValue"
605 property of table fields can contain value of any type.
606 Note: the returned string is an unescaped string. */
607KDB_EXPORT QString variantToString(const QVariant& v);
608
609/*! @return variant value of type @a type for a string @a s that was previously serialized using
610 @ref variantToString( const QVariant& v ) function.
611 @a ok is set to the result of the operation. With exception for types mentioned in documentation
612 of variantToString(), QVariant::convert() is used for conversion. */
613KDB_EXPORT QVariant stringToVariant(const QString& s, QVariant::Type type, bool* ok);
614
615/*! @return true if setting default value for @a field field is allowed. Fields with unique
616 (and thus primary key) flags set do not accept default values. */
617KDB_EXPORT bool isDefaultValueAllowed(const KDbField &field);
618
619//! Provides limits for values of type @a type
620/*! The result is put into integers pointed by @a minValue and @a maxValue.
621 The limits are machine-independent,. what is useful for format and protocol compatibility.
622 Supported types are Byte, ShortInteger, Integer and BigInteger.
623 The value of @a signedness controls the values; they can be limited to unsigned or not.
624 Results for BigInteger or non-integer types are the same as for Integer due to limitation
625 of int type. Signed integers are assumed. @a minValue and @a maxValue must not be 0. */
626KDB_EXPORT void getLimitsForFieldType(KDbField::Type type, qlonglong *minValue, qlonglong *maxValue,
627 KDb::Signedness signedness = KDb::Signed);
628
629/*! @return type that's maximum of two integer types @a t1 and @a t2, e.g. Integer for (Byte, Integer).
630 If one of the types is not of the integer group, KDbField::InvalidType is returned.
631 Returned type may not fit to the result of evaluated expression that involves the arguments.
632 For example, 100 is within Byte type, maximumForIntegerFieldTypes(Byte, Byte) is Byte but result
633 of 100 * 100 exceeds the range of Byte. */
635
636//! @return QVariant value converted from a @a data string
637/*! Conversion is based on the information about type @a type.
638 @a type has to be an element from KDbField::Type, not greater than KDbField::LastType.
639 For unsupported type this function fails. @a length value controls number of characters
640 used in the conversion. It is optional value for all cases but for the BLOB type because
641 for it @a data is not null-terminated so the length cannot be measured.
642 The value of @a signedness controls the conversion in case of integer types; numbers can be
643 limited to unsigned or not.
644 If @a ok is not 0 *ok is set to false on failure and to true on success. On failure a null
645 QVariant is returned. The function fails if @a data is 0.
646 For rules of conversion to the boolean type see the documentation of @ref QVariant::toBool(),
647 QVariant::toDate() for date type, QVariant::toDateTime() for date+time type,
648 QVariant::toTime() for time type. */
649KDB_EXPORT QVariant cstringToVariant(const char* data, KDbField::Type type, bool *ok, int length = -1,
650 KDb::Signedness signedness = KDb::Signed);
651
652/*! @return default file-based driver MIME type
653 (typically something like "application/x-kexiproject-sqlite") */
655
656/*! @return default file-based driver ID (currently, "org.kde.kdb.sqlite"). */
658
659/*! Escapes and converts value @a v (for type @a ftype)
660 to string representation required by KDBSQL commands.
661 For Date/Time type KDb::dateTimeToSql() is used.
662 For BLOB type KDb::escapeBlob() with BLOBEscapingType::ZeroXHex conversion type is used. */
664
665/**
666 * Converts date/time value to its string representation in ISO 8601 DateTime format - with "T" delimiter
667 *
668 * @note This method is deprecated since 3.1.1, use KDb::dateTimeToIsoString() which has identical
669 * effect. The ISO format is no longer used for creating KDBSQL statements.
670 * Prior to this version it was used to generate date/time constants in
671 * KDb::valueToSql(KDbField::Type ftype, const QVariant& v) for KDbField::DateTime type.
672 * KDb::dateTimeToIsoString() is still used as default implementation for drivers
673 * in KDbDriver::dateTimeToSql().
674 *
675 * KDb 3.1.0 improved type safety for KDBSQL so Text type are no longer compatible with
676 * Date/Time types. By implementing wish https://bugs.kde.org/393094 format of date/time constants
677 * for KDBSQL has been strictly defined in a backend-independent way.
678 * See https://community.kde.org/Kexi/Plugins/Queries/SQL_Constants for details.
679 */
680KDB_DEPRECATED_EXPORT KDbEscapedString dateTimeToSql(const QDateTime& v);
681
682/**
683 * Converts date value to its string representation in ISO 8601 DateTime format
684 *
685 * The string is enclosed with single quotes "'". It is compatible with SQLite format for the
686 * date type. It is used as default implementation for drivers in KDbDriver::dateToSql().
687 *
688 * If the @a v value is convertible to KDbDate then KDbDate::toString() is used to obtain
689 * the result. Otherwise the value is converted to QDate and QDate::toString(Qt::ISODate) is
690 * used to obtain the result.
691 *
692 * "<INVALID_DATE>" string is returned for invalid (also null) date values.
693 *
694 * For specification of the ISO format see https://www.w3.org/TR/NOTE-datetime.
695 *
696 * Example value: "'1994-11-05'".
697 *
698 * @since 3.2.0
699 */
701
702/**
703 * Converts time value to its string representation in ISO 8601 Time format
704 *
705 * The string is enclosed with single quotes "'". It is compatible with SQLite format for the
706 * time type. It is used as default implementation for drivers in KDbDriver::timeToSql().
707 *
708 * If the @a v value is convertible to KDbTime then KDbTime::toString() is used to obtain the result.
709 * Otherwise the value is converted to QTime and QTime::toString() is used to obtain the result.
710 * If the time's milliseconds value is zero, it is not included.
711 *
712 * "<INVALID_TIME>" string is returned for invalid (also null) time values.
713 *
714 * For specification of the ISO format see https://www.w3.org/TR/NOTE-datetime.
715 *
716 * Example values: "'13:15:30.123'", "'13:15:30'".
717 *
718 * @since 3.2.0
719 */
721
722/**
723 * Converts date/time value to its string representation in ISO 8601 DateTime format - with "T" delimiter
724 *
725 * The string is enclosed with single quotes "'". It is compatible with SQLite format for the
726 * date/time type. It is used as default implementation for drivers in KDbDriver::dateTimeToSql().
727 *
728 * If the @a v value is convertible to KDbDateTime then KDbDateTime::toString() is used to obtain
729 * the result. Otherwise the value is converted to QDateTime and QDateTime::toString() is
730 * used as well as QTime::toString() to obtain the result.
731 * If the time's milliseconds value is zero, it is not included.
732 *
733 * "<INVALID_DATETIME>" string is returned for invalid (also null) time values.
734 *
735 * For specification of the ISO format see https://www.w3.org/TR/NOTE-datetime.
736 *
737 * Example value: "'1994-11-05T13:15:30'", not "'1994-11-05 13:15:30'".
738 *
739 * @since 3.2.0
740 */
742
743/**
744 * Converts date value to its string representation required by KDBSQL commands
745 *
746 * The value can be of type QDate or KDbDate. If the value is not one of these types or is invalid
747 * QDate or is a null KDbDate then "<INVALID_DATE>" is returned. If the value is of type KDbDate
748 * that is not null then even if some components of the date are invalid, properly formatted string
749 * is returned.
750 *
751 * Example values: "#1994-11-05", "#1994-9-05#".
752 *
753 * See https://community.kde.org/Kexi/Plugins/Queries/SQL_Constants for details.
754 *
755 * @since 3.2.0
756 */
758
759/**
760 * Converts time value to its string representation required by KDBSQL commands
761 *
762 * The value can be of type QTime or KDbTime. If the value is not one of these types or is invalid
763 * QTime or is a null KDbTime then "<INVALID_TIME>" is returned. If the value is of type KDbTime
764 * that is not null then even if some components of the time are invalid, properly formatted string
765 * is returned. If the time's milliseconds value is zero, it is not included.
766 *
767 * See https://community.kde.org/Kexi/Plugins/Queries/SQL_Constants for details.
768 *
769 * Example values: "#13:15#", "#13:9:30#", "#13:15:30.921#, "#7:20 AM#".
770 *
771 * @since 3.2.0
772 */
774
775/**
776 * Converts date/time value to its string representation required by KDBSQL commands
777 *
778 * The value can be of type QDateTime or KDbDateTime. If the value is not one of these types or
779 * is invalid QDateTime or is a null KDbDateTime then "<INVALID_DATETIME>" is returned.
780 * If the value is of type KDbDateTime that is not null then even if some components of the
781 * date/time are invalid, properly formatted string is returned.
782 * If the time's milliseconds value is zero, it is not included.
783 *
784 * See https://community.kde.org/Kexi/Plugins/Queries/SQL_Constants for details.
785 *
786 * Example values: "#1994-11-05 13:15#", "#1994-11-05 13:9:30#", "#1994-9-05 13:15:30.921#".
787 *
788 * @since 3.2.0
789 */
791
792#ifdef KDB_DEBUG_GUI
793//! A prototype of handler for GUI debugger
794typedef void(*DebugGUIHandler)(const QString&);
795
796//! Sets handler for GUI debugger
797KDB_EXPORT void setDebugGUIHandler(DebugGUIHandler handler);
798
799//! Outputs string @a text to the GUI debugger
800KDB_EXPORT void debugGUI(const QString& text);
801
802//! A prototype of handler for GUI debugger (specialized for the Alter Table feature)
803typedef void(*AlterTableActionDebugGUIHandler)(const QString&, int);
804
805//! Sets handler for GUI debugger (specialized for the Alter Table feature)
806KDB_EXPORT void setAlterTableActionDebugHandler(AlterTableActionDebugGUIHandler handler);
807
808//! Outputs string @a text to the GUI debugger (specialized for the Alter Table feature);
809//! @a nestingLevel can be provided for nested outputs.
810KDB_EXPORT void alterTableActionDebugGUI(const QString& text, int nestingLevel = 0);
811#endif
812
813//! @return @a string if it is not empty, else returns @a stringIfEmpty.
814/*! This function is an optimization in cases when @a string is a result of expensive
815 functioncall because any evaluation will be performed once, not twice. Another advantage
816 is simpified code through the functional approach.
817 The function expects bool isEmpty() method to be present in type T, so T can typically
818 be QString or QByteArray. */
819template<typename T>
820T iifNotEmpty(const T &string, const T &stringIfEmpty)
821{
822 return string.isEmpty() ? stringIfEmpty : string;
823}
824
825//! @overload iifNotEmpty(const T &string, const T &stringIfEmpty)
826template<typename T>
827T iifNotEmpty(const QByteArray &string, const T &stringIfEmpty)
828{
829 return iifNotEmpty(QLatin1String(string), stringIfEmpty);
830}
831
832//! @overload iifNotEmpty(const T &string, const T &stringIfEmpty)
833template<typename T>
834T iifNotEmpty(const T &string, const QByteArray &stringIfEmpty)
835{
836 return iifNotEmpty(string, QLatin1String(stringIfEmpty));
837}
838
839//! @return @a value if @a ok is true, else returns default value T().
840template<typename T>
841T iif(bool ok, const T &value)
842{
843 if (ok) {
844 return value;
845 }
846 return T();
847}
848
849/*! @return a list of paths that KDb will search when dynamically loading libraries (plugins)
850 This is basicaly list of directories returned QCoreApplication::libraryPaths() that have readable
851 subdirectory "kdb".
852 @see QCoreApplication::libraryPaths() */
854
855/*! @return new temporary name suitable for creating new table.
856 The name has mask tmp__{baseName}{rand} where baseName is passed as argument and {rand}
857 is a 10 digits long hexadecimal number. @a baseName can be empty. It is adviced to use
858 the returned name as quickly as possible for creating new physical table.
859 It is not 100% guaranteed that table with this name will not exist at an attempt of creation
860 but it is very unlikely. The function checks for existence of a table with temporary name
861 for connection @a conn. Empty string is returned if @a conn is @c nullptr or is not open
862 or if checking for existence of table with temporary name failed.
863*/
864KDB_EXPORT QString temporaryTableName(KDbConnection *conn, const QString &baseName);
865
866/*! @return absolute path to "sqlite3" program.
867 Empty string is returned if the program was not found. */
869
870/*! Imports file in SQL format from @a inputFileName into @a outputFileName.
871 Works for any SQLite 3 dump file. Requires access to executing the "sqlite3" command.
872 File named @a outputFileName will be silently overwritten with a new SQLite 3 database file.
873 @return true on success. */
874KDB_EXPORT bool importSqliteFile(const QString &inputFileName, const QString &outputFileName);
875
876/*! @return @c true if @a s is a valid identifier, i.e. starts with a letter or '_' character
877 and contains only letters, numbers and '_' character. */
878KDB_EXPORT bool isIdentifier(const QString& s);
879
880//! @overload isIdentifier(const QString& s)
881//! @since 3.1
882KDB_EXPORT bool isIdentifier(const QByteArray& s);
883
884/*! @return valid identifier based on @a s.
885 Non-alphanumeric characters (or spaces) are replaced with '_'.
886 If a number is at the beginning, '_' is added at start.
887 Empty strings are not changed. Case remains unchanged. */
888KDB_EXPORT QString stringToIdentifier(const QString &s);
889
890/*! @return useful message "Value of "valueName" field must be an identifier.
891 "v" is not a valid identifier.". It is also used by KDbIdentifierValidator. */
892KDB_EXPORT QString identifierExpectedMessage(const QString &valueName,
893 const QVariant& v);
894
895} // namespace KDb
896
897#endif
Database specific connection data, e.g. host, port.
Provides database connection, allowing queries and data modification.
Database driver's abstraction.
Definition KDbDriver.h:50
Specialized string for escaping.
Meta-data for a field.
Definition KDbField.h:72
@ Integer
Definition KDbField.h:90
Provides information about lookup field's setup.
Interface for classes providing a result.
3-state logical type with three values: true, false and cancelled and convenient operators.
A database connectivity and creation framework.
KDB_EXPORT KDbEscapedString timeToSql(const QVariant &v)
Converts time value to its string representation required by KDBSQL commands.
KDB_EXPORT KDbEscapedString dateToSql(const QVariant &v)
Converts date value to its string representation required by KDBSQL commands.
BLOBEscapingType
Escaping types for BLOBS. Used in escapeBLOB().
Definition KDb.h:535
@ ByteaHex
"bytea hex" escaping, e.g.
@ ZeroXHex
Escaping like 0x1FAD, used by mysql (hex numbers)
@ Octal
Escaping like 'zk\000$x', used by PostgreSQL.
@ Hex
Escaping like 1FAD without quotes or prefixes.
@ XHex
Escaping like X'1FAD', used by sqlite (hex numbers)
KDB_EXPORT QString sqlite3ProgramPath()
KDB_EXPORT QString escapeIdentifierAndAddQuotes(const QString &string)
Definition KDb.cpp:1346
T iif(bool ok, const T &value)
Definition KDb.h:841
KDB_EXPORT QDomElement saveNumberElementToDom(QDomDocument *doc, QDomElement *parentEl, const QString &elementName, int value)
Definition KDb.cpp:1169
KDB_EXPORT bool isExtendedTableFieldProperty(const QByteArray &propertyName)
for isExtendedTableProperty()
Definition KDb.cpp:954
KDB_EXPORT QString numberToString(double value, int decimalPlaces)
Definition KDb.cpp:654
KDB_EXPORT void getProperties(const KDbLookupFieldSchema *lookup, QMap< QByteArray, QVariant > *values)
Definition KDb.cpp:758
KDB_EXPORT QString escapeBLOB(const QByteArray &array, BLOBEscapingType type)
KDB_EXPORT bool setFieldProperties(KDbField *field, const QMap< QByteArray, QVariant > &values)
Definition KDb.cpp:833
KDB_EXPORT const QList< KDbField::Type > fieldTypesForGroup(KDbField::TypeGroup typeGroup)
Definition KDb.cpp:485
SplitToTableAndFieldPartsOptions
Used in splitToTableAndFieldParts().
Definition KDb.h:246
@ SetFieldNameIfNoTableName
see splitToTableAndFieldParts()
Definition KDb.h:248
@ FailIfNoTableOrFieldName
default value for splitToTableAndFieldParts()
Definition KDb.h:247
KDB_EXPORT bool isIdentifier(const QString &s)
KDB_EXPORT QByteArray pgsqlByteaToByteArray(const char *data, int length=-1)
KDB_EXPORT QString escapeIdentifier(const QString &string)
Definition KDb.cpp:1334
KDB_EXPORT KDbEscapedString timeToIsoString(const QVariant &v)
Converts time value to its string representation in ISO 8601 Time format.
KDB_EXPORT quint64 lastInsertedAutoIncValue(QSharedPointer< KDbSqlResult > result, const QString &autoIncrementFieldName, const QString &tableName, quint64 *recordId=nullptr)
Returns value of last inserted record for an autoincrement field.
Definition KDb.cpp:392
KDB_EXPORT bool deleteRecords(KDbConnection *conn, const QString &tableName, const QString &keyname, KDbField::Type keytype, const QVariant &keyval)
Deletes records using one generic criteria.
Definition KDb.cpp:342
KDB_EXPORT QString defaultFileBasedDriverMimeType()
KDB_EXPORT KDbEscapedString sqlWhere(KDbDriver *drv, KDbField::Type t, const QString &fieldName, const QVariant &value)
Definition KDb.cpp:440
KDB_EXPORT KDbField::Type maximumForIntegerFieldTypes(KDbField::Type t1, KDbField::Type t2)
KDB_EXPORT QStringList deserializeList(const QString &data)
KDB_EXPORT bool isEmptyValue(KDbField::Type type, const QVariant &value)
Definition KDb.cpp:429
KDB_EXPORT QStringList fieldTypeStringsForGroup(KDbField::TypeGroup typeGroup)
Definition KDb.cpp:495
KDB_EXPORT QString defaultFileBasedDriverId()
KDB_EXPORT bool isLookupFieldSchemaProperty(const QByteArray &propertyName)
for isLookupFieldSchemaProperty()
Definition KDb.cpp:976
KDB_EXPORT KDbEscapedString dateToIsoString(const QVariant &v)
Converts date value to its string representation in ISO 8601 DateTime format.
KDB_EXPORT void getFieldProperties(const KDbField &field, QMap< QByteArray, QVariant > *values)
Definition KDb.cpp:787
KDB_EXPORT bool importSqliteFile(const QString &inputFileName, const QString &outputFileName)
KDB_EXPORT QString escapeString(const QString &string)
Definition KDb.cpp:1356
KDB_EXPORT KDbVersionInfo version()
Definition KDb.cpp:336
KDB_EXPORT QString variantToString(const QVariant &v)
KDB_EXPORT bool isKDbSqlKeyword(const QByteArray &word)
KDB_EXPORT KDbField::Type defaultFieldTypeForGroup(KDbField::TypeGroup typeGroup)
Definition KDb.cpp:500
KDB_EXPORT QList< int > stringListToIntList(const QStringList &list, bool *ok=nullptr)
KDB_EXPORT bool supportsVisibleDecimalPlacesProperty(KDbField::Type type)
Definition KDb.cpp:623
KDB_EXPORT bool isBuiltinTableFieldProperty(const QByteArray &propertyName)
for KDb::isBuiltinTableFieldProperty()
Definition KDb.cpp:734
KDB_EXPORT QStringList fieldTypeNamesForGroup(KDbField::TypeGroup typeGroup)
Definition KDb.cpp:490
KDB_EXPORT QString identifierExpectedMessage(const QString &valueName, const QVariant &v)
T iifNotEmpty(const T &string, const T &stringIfEmpty)
Definition KDb.h:820
KDB_EXPORT KDbEscapedString dateTimeToIsoString(const QVariant &v)
Converts date/time value to its string representation in ISO 8601 DateTime format - with "T" delimite...
KDB_EXPORT QString stringToIdentifier(const QString &s)
KDB_EXPORT QString loadStringPropertyValueFromDom(const QDomNode &node, bool *ok)
Definition KDb.cpp:1110
KDB_EXPORT QVariant notEmptyValueForFieldType(KDbField::Type type)
Used in KDb::notEmptyValueForFieldType()
Definition KDb.cpp:1275
KDB_EXPORT QString simplifiedFieldTypeName(KDbField::Type type)
KDB_EXPORT KDbEscapedString valueToSql(KDbField::Type ftype, const QVariant &v)
KDB_EXPORT bool setFieldProperty(KDbField *field, const QByteArray &propertyName, const QVariant &value)
Definition KDb.cpp:981
KDB_EXPORT QDomElement saveBooleanElementToDom(QDomDocument *doc, QDomElement *parentEl, const QString &elementName, bool value)
Definition KDb.cpp:1183
KDB_EXPORT KDbField::Type intToFieldType(int type)
Definition KDb.cpp:670
KDB_EXPORT QVariant emptyValueForFieldType(KDbField::Type type)
Used in KDb::emptyValueForFieldType()
Definition KDb.cpp:1222
KDB_EXPORT int loadIntPropertyValueFromDom(const QDomNode &node, bool *ok)
Definition KDb.cpp:1097
KDB_EXPORT QString serializeList(const QStringList &list)
KDB_EXPORT tristate showConnectionTestDialog(QWidget *parent, const KDbConnectionData &data, KDbMessageHandler *msgHandler)
Shows connection test dialog.
Definition KDb.cpp:592
KDB_EXPORT bool deleteAllRecords(KDbConnection *conn, const QString &tableName)
Deletes all records from table tableName.
Definition KDb.cpp:384
Signedness
A property of numeric values.
Definition KDbGlobal.h:151
@ Signed
Values can be both positive and negative.
Definition KDbGlobal.h:152
KDB_EXPORT tristate idForObjectName(KDbConnection *conn, int *id, const QString &objName, int objType)
Finds an identifier for object objName of type objType.
Definition KDb.cpp:579
KDB_EXPORT void getLimitsForFieldType(KDbField::Type type, qlonglong *minValue, qlonglong *maxValue, KDb::Signedness signedness=KDb::Signed)
Provides limits for values of type type.
KDB_EXPORT QString unescapeString(const QString &string, char quote, int *errorPosition=nullptr)
Unescapes characters in string string for the KDBSQL dialect.
KDB_EXPORT QVariant cstringToVariant(const char *data, KDbField::Type type, bool *ok, int length=-1, KDb::Signedness signedness=KDb::Signed)
KDB_EXPORT QStringList libraryPaths()
KDB_EXPORT QString numberToLocaleString(double value, int decimalPlaces)
Returns number converted to string using default locale.
Definition KDb.cpp:659
KDB_EXPORT bool splitToTableAndFieldParts(const QString &string, QString *tableName, QString *fieldName, SplitToTableAndFieldPartsOptions option=FailIfNoTableOrFieldName)
Definition KDb.cpp:603
KDB_EXPORT KDbField::TypeGroup intToFieldTypeGroup(int typeGroup)
Definition KDb.cpp:678
KDB_EXPORT QByteArray xHexToByteArray(const char *data, int length=-1, bool *ok=nullptr)
KDB_EXPORT QVariant loadPropertyValueFromDom(const QDomNode &node, bool *ok)
Definition KDb.cpp:1123
KDB_EXPORT QByteArray zeroXHexToByteArray(const char *data, int length=-1, bool *ok=nullptr)
KDB_EXPORT void getHTMLErrorMesage(const KDbResultable &resultable, QString *msg, QString *details)
Sets HTML-formatted error message with extra details obtained from result object.
Definition KDb.cpp:505
KDB_EXPORT QVariant stringToVariant(const QString &s, QVariant::Type type, bool *ok)
KDB_EXPORT QString temporaryTableName(KDbConnection *conn, const QString &baseName)
KDB_EXPORT bool isDefaultValueAllowed(const KDbField &field)
KDB_DEPRECATED_EXPORT KDbEscapedString dateTimeToSql(const QDateTime &v)
Converts date/time value to its string representation in ISO 8601 DateTime format - with "T" delimite...
KDB_EXPORT QList< int > deserializeIntList(const QString &data, bool *ok)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:38:30 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.