Changeset View
Changeset View
Standalone View
Standalone View
src/KDbTableOrQuerySchema.h
Show First 20 Lines • Show All 79 Lines • ▼ Show 20 Line(s) | 35 | public: | |||
---|---|---|---|---|---|
80 | KDbTableSchema* table() const; | 80 | KDbTableSchema* table() const; | ||
81 | 81 | | |||
82 | //! @return name of a query or table | 82 | //! @return name of a query or table | ||
83 | QByteArray name() const; | 83 | QByteArray name() const; | ||
84 | 84 | | |||
85 | //! @return caption (if present) or name of the table/query | 85 | //! @return caption (if present) or name of the table/query | ||
86 | QString captionOrName() const; | 86 | QString captionOrName() const; | ||
87 | 87 | | |||
88 | //! @return number of fields | 88 | /** | ||
89 | int fieldCount() const; | 89 | * @brief Returns number of columns within record set returned from specified table or query | ||
90 | * | ||||
91 | * In case of query expanded fields list is counted. | ||||
92 | * For tables @a conn is not required. | ||||
93 | * Returns -1 if the object has neither table or query assigned. | ||||
94 | * Returns -1 if the object has query assigned but @a conn is @c nullptr. | ||||
95 | */ | ||||
96 | int fieldCount(KDbConnection *conn) const; | ||||
97 | | ||||
98 | /*! Mode for columns(). */ | ||||
99 | enum class ColumnsMode { | ||||
100 | NonUnique, //!< Non-unique columns are returned | ||||
101 | Unique //!< Unique columns are returned | ||||
102 | }; | ||||
90 | 103 | | |||
91 | //! @return all columns for the table or the query | 104 | //! @return all columns for the table or the query | ||
92 | const KDbQueryColumnInfo::Vector columns(bool unique = false); | 105 | const KDbQueryColumnInfo::Vector columns(KDbConnection *conn, ColumnsMode mode = ColumnsMode::NonUnique); | ||
93 | 106 | | |||
94 | /*! @return a field of the table or the query schema for name @a name | 107 | /*! @return a field of the table or the query schema for name @a name | ||
95 | or 0 if there is no such field. */ | 108 | or 0 if there is no such field. */ | ||
96 | KDbField* field(const QString& name); | 109 | KDbField* field(const QString& name); | ||
97 | 110 | | |||
98 | /*! Like KDbField* field(const QString& name); | 111 | /*! Like KDbField* field(const QString& name); | ||
99 | but returns all information associated with field/column @a name. */ | 112 | but returns all information associated with field/column @a name. */ | ||
100 | KDbQueryColumnInfo* columnInfo(const QString& name); | 113 | KDbQueryColumnInfo* columnInfo(KDbConnection *conn, const QString& name); | ||
101 | | ||||
102 | /*! @return connection object, for table or query or 0 if there's no table or query defined. */ | | |||
103 | KDbConnection* connection() const; | | |||
104 | 114 | | |||
105 | private: | 115 | private: | ||
106 | class Private; | 116 | class Private; | ||
107 | Private * const d; | 117 | Private * const d; | ||
108 | 118 | | |||
109 | Q_DISABLE_COPY(KDbTableOrQuerySchema) | 119 | Q_DISABLE_COPY(KDbTableOrQuerySchema) | ||
110 | }; | 120 | }; | ||
111 | 121 | | |||
112 | namespace KDb { | 122 | //! A pair (connection, table-or-schema) for QDebug operator<< | ||
113 | //! Sends information about table or query schema @a schema to debug output @a dbg. | 123 | //! @since 3.1 | ||
114 | KDB_EXPORT QDebug operator<<(QDebug dbg, const KDbTableOrQuerySchema& schema); | 124 | typedef std::tuple<KDbConnection*, const KDbTableOrQuerySchema&> KDbConnectionAndSchema; | ||
115 | } | 125 | | ||
126 | //! Sends information about table or query schema and connection @a connectionAndSchema to debug output @a dbg. | ||||
127 | //! @since 3.1 | ||||
128 | KDB_EXPORT QDebug operator<<(QDebug dbg, const KDbConnectionAndSchema &connectionAndSchema); | ||||
116 | 129 | | |||
117 | #endif | 130 | #endif |