| QxOrm 1.1.6 C++ Object Relational Mapping library

- Main Page
- Modules
- Namespaces
- Classes
- Files
- Directories

- File List
- File Members

QxDao.h
Go to the documentation of this file.

    00001 /****************************************************************************
    00002 **
    00003 ** http://www.qxorm.com/
    00004 ** http://sourceforge.net/projects/qxorm/
    00005 ** Original file by Lionel Marty
    00006 **
    00007 ** This file is part of the QxOrm library
    00008 **
    00009 ** This software is provided 'as-is', without any express or implied
    00010 ** warranty. In no event will the authors be held liable for any
    00011 ** damages arising from the use of this software.
    00012 **
    00013 ** GNU Lesser General Public License Usage
    00014 ** This file must be used under the terms of the GNU Lesser
    00015 ** General Public License version 2.1 as published by the Free Software
    00016 ** Foundation and appearing in the file 'license.lgpl.txt' included in the
    00017 ** packaging of this file.  Please review the following information to
    00018 ** ensure the GNU Lesser General Public License version 2.1 requirements
    00019 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    00020 **
    00021 ** If you have questions regarding the use of this file, please contact :
    00022 ** contact@qxorm.com
    00023 **
    00024 ****************************************************************************/
    00025
    00026 #ifndef _QX_DAO_H_
    00027 #define _QX_DAO_H_
    00028
    00029 #ifdef _MSC_VER
    00030 #pragma once
    00031 #endif
    00032
    00040 #include <QtSql/qsqldatabase.h>
    00041 #include <QtSql/qsqlquery.h>
    00042 #include <QtSql/qsqlrecord.h>
    00043 #include <QtSql/qsqlfield.h>
    00044 #include <QtSql/qsqlerror.h>
    00045 #include <QtSql/qsqldriver.h>
    00046
    00047 #include <QxCommon/QxBool.h>
    00048
    00049 #include <QxDao/QxDaoPointer.h>
    00050 #include <QxDao/QxSqlQuery.h>
    00051
    00052 namespace qx {
    00053 namespace dao {
    00054
    00055 namespace detail {
    00056 struct IxDao_Helper;
    00057 template <class T> struct QxDao_Count;
    00058 template <class T> struct QxDao_FetchById;
    00059 template <class T> struct QxDao_FetchById_WithRelation;
    00060 template <class T> struct QxDao_FetchAll;
    00061 template <class T> struct QxDao_FetchAll_WithRelation;
    00062 template <class T> struct QxDao_Insert;
    00063 template <class T> struct QxDao_Insert_WithRelation;
    00064 template <class T> struct QxDao_Update;
    00065 template <class T> struct QxDao_Update_Optimized;
    00066 template <class T> struct QxDao_Update_WithRelation;
    00067 template <class T> struct QxDao_Save;
    00068 template <class T> struct QxDao_Save_WithRelation;
    00069 template <class T> struct QxDao_DeleteById;
    00070 template <class T> struct QxDao_DeleteAll;
    00071 template <class T> struct QxDao_Exist;
    00072 template <class T> struct QxDao_CreateTable;
    00073 template <class T> struct QxDao_Trigger;
    00074 } // namespace detail
    00075
    00084 template <class T>
    00085 inline long count(QSqlDatabase * pDatabase)
    00086 { return qx::dao::detail::QxDao_Count<T>::count("", pDatabase); }
    00087
    00097 template <class T>
    00098 inline long count(const qx::QxSqlQuery & query, QSqlDatabase * pDatabase)
    00099 { return qx::dao::detail::QxDao_Count<T>::count(query, pDatabase); }
    00100
    00111 template <class T>
    00112 inline QSqlError fetch_by_id(T & t, QSqlDatabase * pDatabase)
    00113 { return qx::dao::detail::QxDao_FetchById<T>::fetchById(t, pDatabase, QStringList()); }
    00114
    00125 template <class T>
    00126 inline QSqlError fetch_all(T & t, QSqlDatabase * pDatabase)
    00127 { return qx::dao::detail::QxDao_FetchAll<T>::fetchAll("", t, pDatabase, QStringList()); }
    00128
    00140 template <class T>
    00141 inline QSqlError fetch_by_query(const qx::QxSqlQuery & query, T & t, QSqlDatabase * pDatabase)
    00142 { return qx::dao::detail::QxDao_FetchAll<T>::fetchAll(query, t, pDatabase, QStringList()); }
    00143
    00154 template <class T>
    00155 inline QSqlError insert(T & t, QSqlDatabase * pDatabase)
    00156 { return qx::dao::detail::QxDao_Insert<T>::insert(t, pDatabase); }
    00157
    00168 template <class T>
    00169 inline QSqlError update(T & t, QSqlDatabase * pDatabase)
    00170 { return qx::dao::detail::QxDao_Update<T>::update(t, pDatabase, QStringList()); }
    00171
    00184 template <class T>
    00185 inline QSqlError save(T & t, QSqlDatabase * pDatabase)
    00186 { return qx::dao::detail::QxDao_Save<T>::save(t, pDatabase); }
    00187
    00198 template <class T>
    00199 inline QSqlError delete_by_id(T & t, QSqlDatabase * pDatabase)
    00200 { return qx::dao::detail::QxDao_DeleteById<T>::deleteById(t, pDatabase); }
    00201
    00211 template <class T>
    00212 inline QSqlError delete_all(QSqlDatabase * pDatabase)
    00213 { return qx::dao::detail::QxDao_DeleteAll<T>::deleteAll("", pDatabase); }
    00214
    00225 template <class T>
    00226 inline QSqlError delete_by_query(const qx::QxSqlQuery & query, QSqlDatabase * pDatabase)
    00227 { return qx::dao::detail::QxDao_DeleteAll<T>::deleteAll(query, pDatabase); }
    00228
    00238 template <class T>
    00239 inline QSqlError create_table(QSqlDatabase * pDatabase)
    00240 { return qx::dao::detail::QxDao_CreateTable<T>::createTable(pDatabase); }
    00241
    00252 template <class T>
    00253 inline qx_bool exist(T & t, QSqlDatabase * pDatabase)
    00254 { return qx::dao::detail::QxDao_Exist<T>::exist(t, pDatabase); }
    00255
    00267 template <class T>
    00268 inline QSqlError fetch_by_id_with_relation(const QString & relation, T & t, QSqlDatabase * pDatabase)
    00269 { return qx::dao::detail::QxDao_FetchById_WithRelation<T>::fetchById(relation, t, pDatabase); }
    00270
    00282 template <class T>
    00283 inline QSqlError fetch_by_id_with_relation(const QStringList & relation, T & t, QSqlDatabase * pDatabase)
    00284 { return qx::dao::detail::QxDao_FetchById_WithRelation<T>::fetchById(relation, t, pDatabase); }
    00285
    00296 template <class T>
    00297 inline QSqlError fetch_by_id_with_all_relation(T & t, QSqlDatabase * pDatabase)
    00298 { return qx::dao::detail::QxDao_FetchById_WithRelation<T>::fetchById("*", t, pDatabase); }
    00299
    00311 template <class T>
    00312 inline QSqlError fetch_all_with_relation(const QString & relation, T & t, QSqlDatabase * pDatabase)
    00313 { return qx::dao::detail::QxDao_FetchAll_WithRelation<T>::fetchAll(relation, "", t, pDatabase); }
    00314
    00326 template <class T>
    00327 inline QSqlError fetch_all_with_relation(const QStringList & relation, T & t, QSqlDatabase * pDatabase)
    00328 { return qx::dao::detail::QxDao_FetchAll_WithRelation<T>::fetchAll(relation, "", t, pDatabase); }
    00329
    00340 template <class T>
    00341 inline QSqlError fetch_all_with_all_relation(T & t, QSqlDatabase * pDatabase)
    00342 { return qx::dao::detail::QxDao_FetchAll_WithRelation<T>::fetchAll("*", "", t, pDatabase); }
    00343
    00356 template <class T>
    00357 inline QSqlError fetch_by_query_with_relation(const QString & relation, const qx::QxSqlQuery & query, T & t, QSqlDatabase * pDatabase)
    00358 { return qx::dao::detail::QxDao_FetchAll_WithRelation<T>::fetchAll(relation, query, t, pDatabase); }
    00359
    00372 template <class T>
    00373 inline QSqlError fetch_by_query_with_relation(const QStringList & relation, const qx::QxSqlQuery & query, T & t, QSqlDatabase * pDatabase)
    00374 { return qx::dao::detail::QxDao_FetchAll_WithRelation<T>::fetchAll(relation, query, t, pDatabase); }
    00375
    00387 template <class T>
    00388 inline QSqlError fetch_by_query_with_all_relation(const qx::QxSqlQuery & query, T & t, QSqlDatabase * pDatabase)
    00389 { return qx::dao::detail::QxDao_FetchAll_WithRelation<T>::fetchAll("*", query, t, pDatabase); }
    00390
    00402 template <class T>
    00403 inline QSqlError insert_with_relation(const QString & relation, T & t, QSqlDatabase * pDatabase)
    00404 { return qx::dao::detail::QxDao_Insert_WithRelation<T>::insert(relation, t, pDatabase); }
    00405
    00417 template <class T>
    00418 inline QSqlError insert_with_relation(const QStringList & relation, T & t, QSqlDatabase * pDatabase)
    00419 { return qx::dao::detail::QxDao_Insert_WithRelation<T>::insert(relation, t, pDatabase); }
    00420
    00431 template <class T>
    00432 inline QSqlError insert_with_all_relation(T & t, QSqlDatabase * pDatabase)
    00433 { return qx::dao::detail::QxDao_Insert_WithRelation<T>::insert("*", t, pDatabase); }
    00434
    00446 template <class T>
    00447 inline QSqlError update_with_relation(const QString & relation, T & t, QSqlDatabase * pDatabase)
    00448 { return qx::dao::detail::QxDao_Update_WithRelation<T>::update(relation, t, pDatabase); }
    00449
    00461 template <class T>
    00462 inline QSqlError update_with_relation(const QStringList & relation, T & t, QSqlDatabase * pDatabase)
    00463 { return qx::dao::detail::QxDao_Update_WithRelation<T>::update(relation, t, pDatabase); }
    00464
    00475 template <class T>
    00476 inline QSqlError update_with_all_relation(T & t, QSqlDatabase * pDatabase)
    00477 { return qx::dao::detail::QxDao_Update_WithRelation<T>::update("*", t, pDatabase); }
    00478
    00492 template <class T>
    00493 inline QSqlError save_with_relation(const QString & relation, T & t, QSqlDatabase * pDatabase)
    00494 { return qx::dao::detail::QxDao_Save_WithRelation<T>::save(relation, t, pDatabase); }
    00495
    00509 template <class T>
    00510 inline QSqlError save_with_relation(const QStringList & relation, T & t, QSqlDatabase * pDatabase)
    00511 { return qx::dao::detail::QxDao_Save_WithRelation<T>::save(relation, t, pDatabase); }
    00512
    00525 template <class T>
    00526 inline QSqlError save_with_all_relation(T & t, QSqlDatabase * pDatabase)
    00527 { return qx::dao::detail::QxDao_Save_WithRelation<T>::save("*", t, pDatabase); }
    00528
    00536 template <class T>
    00537 inline long count()
    00538 { return qx::dao::detail::QxDao_Count<T>::count("", NULL); }
    00539
    00548 template <class T>
    00549 inline long count(const qx::QxSqlQuery & query)
    00550 { return qx::dao::detail::QxDao_Count<T>::count(query, NULL); }
    00551
    00561 template <class T>
    00562 inline QSqlError fetch_by_id(T & t)
    00563 { return qx::dao::detail::QxDao_FetchById<T>::fetchById(t, NULL, QStringList()); }
    00564
    00574 template <class T>
    00575 inline QSqlError fetch_all(T & t)
    00576 { return qx::dao::detail::QxDao_FetchAll<T>::fetchAll("", t, NULL, QStringList()); }
    00577
    00588 template <class T>
    00589 inline QSqlError fetch_by_query(const qx::QxSqlQuery & query, T & t)
    00590 { return qx::dao::detail::QxDao_FetchAll<T>::fetchAll(query, t, NULL, QStringList()); }
    00591
    00601 template <class T>
    00602 inline QSqlError insert(T & t)
    00603 { return qx::dao::detail::QxDao_Insert<T>::insert(t, NULL); }
    00604
    00614 template <class T>
    00615 inline QSqlError update(T & t)
    00616 { return qx::dao::detail::QxDao_Update<T>::update(t, NULL, QStringList()); }
    00617
    00629 template <class T>
    00630 inline QSqlError save(T & t)
    00631 { return qx::dao::detail::QxDao_Save<T>::save(t, NULL); }
    00632
    00642 template <class T>
    00643 inline QSqlError delete_by_id(T & t)
    00644 { return qx::dao::detail::QxDao_DeleteById<T>::deleteById(t, NULL); }
    00645
    00654 template <class T>
    00655 inline QSqlError delete_all()
    00656 { return qx::dao::detail::QxDao_DeleteAll<T>::deleteAll("", NULL); }
    00657
    00667 template <class T>
    00668 inline QSqlError delete_by_query(const qx::QxSqlQuery & query)
    00669 { return qx::dao::detail::QxDao_DeleteAll<T>::deleteAll(query, NULL); }
    00670
    00679 template <class T>
    00680 inline QSqlError create_table()
    00681 { return qx::dao::detail::QxDao_CreateTable<T>::createTable(NULL); }
    00682
    00692 template <class T>
    00693 inline qx_bool exist(T & t)
    00694 { return qx::dao::detail::QxDao_Exist<T>::exist(t, NULL); }
    00695
    00707 template <class T>
    00708 inline QSqlError fetch_by_id(T & t, QSqlDatabase * pDatabase, const QStringList & columns)
    00709 { return qx::dao::detail::QxDao_FetchById<T>::fetchById(t, pDatabase, columns); }
    00710
    00722 template <class T>
    00723 inline QSqlError fetch_all(T & t, QSqlDatabase * pDatabase, const QStringList & columns)
    00724 { return qx::dao::detail::QxDao_FetchAll<T>::fetchAll("", t, pDatabase, columns); }
    00725
    00738 template <class T>
    00739 inline QSqlError fetch_by_query(const qx::QxSqlQuery & query, T & t, QSqlDatabase * pDatabase, const QStringList & columns)
    00740 { return qx::dao::detail::QxDao_FetchAll<T>::fetchAll(query, t, pDatabase, columns); }
    00741
    00753 template <class T>
    00754 inline QSqlError update(T & t, QSqlDatabase * pDatabase, const QStringList & columns)
    00755 { return qx::dao::detail::QxDao_Update<T>::update(t, pDatabase, columns); }
    00756
    00766 template <class T>
    00767 inline QSqlError update_optimized(qx::dao::ptr<T> & ptr)
    00768 { return qx::dao::detail::QxDao_Update_Optimized<T>::update_optimized(ptr, NULL); }
    00769
    00780 template <class T>
    00781 inline QSqlError update_optimized(qx::dao::ptr<T> & ptr, QSqlDatabase * pDatabase)
    00782 { return qx::dao::detail::QxDao_Update_Optimized<T>::update_optimized(ptr, pDatabase); }
    00783
    00794 template <class T>
    00795 inline QSqlError fetch_by_id_with_relation(const QString & relation, T & t)
    00796 { return qx::dao::detail::QxDao_FetchById_WithRelation<T>::fetchById(relation, t, NULL); }
    00797
    00808 template <class T>
    00809 inline QSqlError fetch_by_id_with_relation(const QStringList & relation, T & t)
    00810 { return qx::dao::detail::QxDao_FetchById_WithRelation<T>::fetchById(relation, t, NULL); }
    00811
    00821 template <class T>
    00822 inline QSqlError fetch_by_id_with_all_relation(T & t)
    00823 { return qx::dao::detail::QxDao_FetchById_WithRelation<T>::fetchById("*", t, NULL); }
    00824
    00835 template <class T>
    00836 inline QSqlError fetch_all_with_relation(const QString & relation, T & t)
    00837 { return qx::dao::detail::QxDao_FetchAll_WithRelation<T>::fetchAll(relation, "", t, NULL); }
    00838
    00849 template <class T>
    00850 inline QSqlError fetch_all_with_relation(const QStringList & relation, T & t)
    00851 { return qx::dao::detail::QxDao_FetchAll_WithRelation<T>::fetchAll(relation, "", t, NULL); }
    00852
    00862 template <class T>
    00863 inline QSqlError fetch_all_with_all_relation(T & t)
    00864 { return qx::dao::detail::QxDao_FetchAll_WithRelation<T>::fetchAll("*", "", t, NULL); }
    00865
    00877 template <class T>
    00878 inline QSqlError fetch_by_query_with_relation(const QString & relation, const qx::QxSqlQuery & query, T & t)
    00879 { return qx::dao::detail::QxDao_FetchAll_WithRelation<T>::fetchAll(relation, query, t, NULL); }
    00880
    00892 template <class T>
    00893 inline QSqlError fetch_by_query_with_relation(const QStringList & relation, const qx::QxSqlQuery & query, T & t)
    00894 { return qx::dao::detail::QxDao_FetchAll_WithRelation<T>::fetchAll(relation, query, t, NULL); }
    00895
    00906 template <class T>
    00907 inline QSqlError fetch_by_query_with_all_relation(const qx::QxSqlQuery & query, T & t)
    00908 { return qx::dao::detail::QxDao_FetchAll_WithRelation<T>::fetchAll("*", query, t, NULL); }
    00909
    00920 template <class T>
    00921 inline QSqlError insert_with_relation(const QString & relation, T & t)
    00922 { return qx::dao::detail::QxDao_Insert_WithRelation<T>::insert(relation, t, NULL); }
    00923
    00934 template <class T>
    00935 inline QSqlError insert_with_relation(const QStringList & relation, T & t)
    00936 { return qx::dao::detail::QxDao_Insert_WithRelation<T>::insert(relation, t, NULL); }
    00937
    00947 template <class T>
    00948 inline QSqlError insert_with_all_relation(T & t)
    00949 { return qx::dao::detail::QxDao_Insert_WithRelation<T>::insert("*", t, NULL); }
    00950
    00961 template <class T>
    00962 inline QSqlError update_with_relation(const QString & relation, T & t)
    00963 { return qx::dao::detail::QxDao_Update_WithRelation<T>::update(relation, t, NULL); }
    00964
    00975 template <class T>
    00976 inline QSqlError update_with_relation(const QStringList & relation, T & t)
    00977 { return qx::dao::detail::QxDao_Update_WithRelation<T>::update(relation, t, NULL); }
    00978
    00988 template <class T>
    00989 inline QSqlError update_with_all_relation(T & t)
    00990 { return qx::dao::detail::QxDao_Update_WithRelation<T>::update("*", t, NULL); }
    00991
    01004 template <class T>
    01005 inline QSqlError save_with_relation(const QString & relation, T & t)
    01006 { return qx::dao::detail::QxDao_Save_WithRelation<T>::save(relation, t, NULL); }
    01007
    01020 template <class T>
    01021 inline QSqlError save_with_relation(const QStringList & relation, T & t)
    01022 { return qx::dao::detail::QxDao_Save_WithRelation<T>::save(relation, t, NULL); }
    01023
    01035 template <class T>
    01036 inline QSqlError save_with_all_relation(T & t)
    01037 { return qx::dao::detail::QxDao_Save_WithRelation<T>::save("*", t, NULL); }
    01038
    01043 template <class T>
    01044 inline void on_before_insert(T * t, qx::dao::detail::IxDao_Helper * dao)
    01045 { qx::dao::detail::QxDao_Trigger<T>::onBeforeInsert(t, dao); }
    01046
    01051 template <class T>
    01052 inline void on_before_update(T * t, qx::dao::detail::IxDao_Helper * dao)
    01053 { qx::dao::detail::QxDao_Trigger<T>::onBeforeUpdate(t, dao); }
    01054
    01059 template <class T>
    01060 inline void on_before_delete(T * t, qx::dao::detail::IxDao_Helper * dao)
    01061 { qx::dao::detail::QxDao_Trigger<T>::onBeforeDelete(t, dao); }
    01062
    01067 template <class T>
    01068 inline void on_after_insert(T * t, qx::dao::detail::IxDao_Helper * dao)
    01069 { qx::dao::detail::QxDao_Trigger<T>::onAfterInsert(t, dao); }
    01070
    01075 template <class T>
    01076 inline void on_after_update(T * t, qx::dao::detail::IxDao_Helper * dao)
    01077 { qx::dao::detail::QxDao_Trigger<T>::onAfterUpdate(t, dao); }
    01078
    01083 template <class T>
    01084 inline void on_after_delete(T * t, qx::dao::detail::IxDao_Helper * dao)
    01085 { qx::dao::detail::QxDao_Trigger<T>::onAfterDelete(t, dao); }
    01086
    01087 } // namespace dao
    01088 } // namespace qx
    01089
    01090 #endif // _QX_DAO_H_

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines