File indexing completed on 2024-10-06 04:18:01
0001 /* This file is part of the KDE project 0002 Copyright (C) 2003-2015 Jarosław Staniek <staniek@kde.org> 0003 0004 This program is free software; you can redistribute it and/or 0005 modify it under the terms of the GNU Library General Public 0006 License as published by the Free Software Foundation; either 0007 version 2 of the License, or (at your option) any later version. 0008 0009 This program is distributed in the hope that it will be useful, 0010 but WITHOUT ANY WARRANTY; without even the implied warranty of 0011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0012 Library General Public License for more details. 0013 0014 You should have received a copy of the GNU Library General Public License 0015 along with this program; see the file COPYING. If not, write to 0016 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0017 * Boston, MA 02110-1301, USA. 0018 */ 0019 0020 #ifndef KDBGLOBAL_H 0021 #define KDBGLOBAL_H 0022 0023 #include "kdb_version.h" 0024 0025 #include <QString> 0026 0027 /*! @file KDbGlobal.h 0028 Global public definitions 0029 */ 0030 0031 /** 0032 * @brief Make a number from the major, minor and release number of a KDb version 0033 * 0034 * This function can be used for preprocessing when KDB_IS_VERSION is not 0035 * appropriate. 0036 */ 0037 #define KDB_MAKE_VERSION( a,b,c ) (((a) << 16) | ((b) << 8) | (c)) 0038 0039 /** 0040 * @brief Check if the KDb version matches a certain version or is higher 0041 * 0042 * This macro is typically used to compile conditionally a part of code: 0043 * @code 0044 * #if KDB_IS_VERSION(3, 1, 0) 0045 * // Code for KDb 3.1 0046 * #else 0047 * // Code for KDb older than 3.1 0048 * #endif 0049 * @endcode 0050 * 0051 * @warning Especially during development phases of KDb, be careful 0052 * when choosing the version number that you are checking against. 0053 * Otherwise you might risk to break the next KDb release. 0054 * Therefore be careful that development version have a 0055 * version number lower than the released version, so do not check 0056 * e.g. for KDb 3.1 with KDB_IS_VERSION(3, 1, 0) 0057 * but with the actual version number at a time a needed feature was introduced, 0058 * e.g. KDB_IS_VERSION(3, 0, 90) for beta 3.1 0059 */ 0060 #define KDB_IS_VERSION(a,b,c) ( KDB_VERSION >= KDB_MAKE_VERSION(a,b,c) ) 0061 0062 0063 /*! @namespace KDb 0064 @brief A database connectivity and creation framework 0065 0066 KDb is consisted of a general-purpose C++ Qt library and set of plugins delivering support 0067 for various database vendors. 0068 0069 @section Framework 0070 KDbDriverManager 0071 KDbDriverMetaData 0072 KDbDriver 0073 0074 Database access 0075 - KDbConnection 0076 - KDbConnectionData 0077 - KDbTransaction 0078 - KDbRecordEditBuffer 0079 - KDbPreparedStatement 0080 0081 Database structure 0082 - Schema 0083 - KDbTableSchema 0084 - KDbQuerySchema 0085 - KDbQuerySchemaParameter 0086 - KDbQueryColumnInfo 0087 - KDbTableOrQuerySchema 0088 - KDbIndexSchema 0089 - KDbFieldList 0090 - KDbLookupFieldSchema 0091 - KDbRelationship 0092 - KDbParser 0093 - KDbExpression 0094 0095 Data representation 0096 - KDbField 0097 - KDbRecordData 0098 - KDbTableViewData 0099 - KDbTableViewColumn 0100 0101 Tools 0102 - KDbObject 0103 - KDbEscapedString 0104 - KDbMessageHandler 0105 - KDbProperties 0106 - KDbAdmin 0107 - KDbAlter 0108 - KDbValidator 0109 - KDbUtils 0110 0111 @section Drivers 0112 0113 Drivers are loaded as plugins on demand by KDbDriverManager. The IDs, descriptions 0114 and other details about drivers are given in their metadata by KDbDriverManager::driverMetaData(). 0115 The metadata is accessible without actually loading any driver. 0116 0117 KDb supports two families of databases, file and network-based while providing a single 0118 uniform API. 0119 0120 Each database driver implements of three main classes KDbDriver, KDbConnection, KDbCursor. 0121 The driver classes handle database-related specifics such as data types, naming and hide 0122 them behind a general purpose API. The connection classes act as a proxy between the KDb API 0123 and the native database. The cursor classes implement cursor functionality specific to 0124 the native database at record level. 0125 */ 0126 namespace KDb 0127 { 0128 0129 /*! Object types set like table or query. */ 0130 enum ObjectType { 0131 UnknownObjectType = -1, //!< helper 0132 AnyObjectType = 0, //!< helper 0133 TableObjectType = 1, 0134 QueryObjectType = 2, 0135 LastObjectType = 2, //ALWAYS UPDATE THIS 0136 0137 KDbSystemTableObjectType = 128, //!< helper, not used in storage 0138 //!< (allows to select KDb system tables 0139 //!< may be or'd with TableObjectType) 0140 IndexObjectType = 256 //!< special 0141 }; 0142 0143 //! Escaping type for identifiers. 0144 enum IdentifierEscapingType { 0145 DriverEscaping, //!< Identifiers are escaped by driver 0146 KDbEscaping //!< Identifiers are escaped using KDb's generic convention 0147 }; 0148 0149 //! A property of numeric values 0150 enum Signedness 0151 { 0152 Signed = 0, //!< Values can be both positive and negative 0153 Unsigned = 1 //!< Values can be both non-negative 0154 }; 0155 0156 } 0157 0158 //! Macros for marking future Qt tr() translations. 0159 #ifndef futureTr 0160 # define futureTr QString 0161 # define futureTr2(a,b) QString(b) 0162 #endif 0163 0164 //! Macros for marking future QT_TR_NOOP translations. 0165 #ifndef FUTURE_TR_NOOP 0166 # define FUTURE_TR_NOOP(x) (x) 0167 #endif 0168 0169 #ifndef WARNING 0170 #ifdef _MSC_VER 0171 /* WARNING preprocessor directive 0172 Reserved: preprocessor needs two indirections to replace __LINE__ with actual 0173 string 0174 */ 0175 #define _MSG0(msg) #msg 0176 /* Preprocessor needs two indirections to replace __LINE__ or __FILE__ 0177 with actual string. */ 0178 #define _MSG1(msg) _MSG0(msg) 0179 0180 /*! Creates message prolog with the name of the source file and the line 0181 number where a preprocessor message has been inserted. 0182 0183 Example: 0184 #pragma KMESSAGE(Your message) 0185 Output: 0186 C:\MyCode.cpp(111) : Your message 0187 */ 0188 # define _MSGLINENO __FILE__ "(" _MSG1(__LINE__) ") : warning: " 0189 # define KDB_WARNING(msg) message(_MSGLINENO #msg) 0190 #endif /*_MSC_VER*/ 0191 #endif /*WARNING*/ 0192 0193 #endif