QxDao_Helper_Container.inl 3.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /****************************************************************************
  2. **
  3. ** https://www.qxorm.com/
  4. ** Copyright (C) 2013 Lionel Marty (contact@qxorm.com)
  5. **
  6. ** This file is part of the QxOrm library
  7. **
  8. ** This software is provided 'as-is', without any express or implied
  9. ** warranty. In no event will the authors be held liable for any
  10. ** damages arising from the use of this software
  11. **
  12. ** Commercial Usage
  13. ** Licensees holding valid commercial QxOrm licenses may use this file in
  14. ** accordance with the commercial license agreement provided with the
  15. ** Software or, alternatively, in accordance with the terms contained in
  16. ** a written agreement between you and Lionel Marty
  17. **
  18. ** GNU General Public License Usage
  19. ** Alternatively, this file may be used under the terms of the GNU
  20. ** General Public License version 3.0 as published by the Free Software
  21. ** Foundation and appearing in the file 'license.gpl3.txt' included in the
  22. ** packaging of this file. Please review the following information to
  23. ** ensure the GNU General Public License version 3.0 requirements will be
  24. ** met : http://www.gnu.org/copyleft/gpl.html
  25. **
  26. ** If you are unsure which license is appropriate for your use, or
  27. ** if you have questions regarding the use of this file, please contact :
  28. ** contact@qxorm.com
  29. **
  30. ****************************************************************************/
  31. #define QX_DAO_HELPER_CONTAINER(className) \
  32. namespace qx { namespace dao { namespace detail { \
  33. template <class T> \
  34. class QxDao_Helper_Container< className<T> > : public IxDao_Helper \
  35. { \
  36. public: \
  37. QxDao_Helper_Container(className<T> & t, QSqlDatabase * pDatabase, const QString & sContext, qx::IxSqlQueryBuilder * pBuilder, const qx::QxSqlQuery * pQuery = NULL) : IxDao_Helper(pBuilder, pQuery) { Q_UNUSED(t); init(pDatabase, sContext); } \
  38. virtual ~QxDao_Helper_Container() { static_assert(qx::trait::is_qx_registered<typename qx::QxSqlQueryBuilder<T>::type_sql>::value, "qx::trait::is_qx_registered<typename qx::QxSqlQueryBuilder<T>::type_sql>::value"); } \
  39. }; }}} // namespace qx::dao::detail
  40. #define QX_DAO_HELPER_CONTAINER_KEY_VALUE(className) \
  41. namespace qx { namespace dao { namespace detail { \
  42. template <class Key, class Value> \
  43. class QxDao_Helper_Container< className<Key, Value> > : public IxDao_Helper \
  44. { \
  45. public: \
  46. QxDao_Helper_Container(className<Key, Value> & t, QSqlDatabase * pDatabase, const QString & sContext, qx::IxSqlQueryBuilder * pBuilder, const qx::QxSqlQuery * pQuery = NULL) : IxDao_Helper(pBuilder, pQuery) { Q_UNUSED(t); init(pDatabase, sContext); } \
  47. virtual ~QxDao_Helper_Container() { static_assert(qx::trait::is_qx_registered<typename qx::QxSqlQueryBuilder<Value>::type_sql>::value, "qx::trait::is_qx_registered<typename qx::QxSqlQueryBuilder<Value>::type_sql>::value"); } \
  48. }; }}} // namespace qx::dao::detail
  49. namespace qx {
  50. namespace dao {
  51. namespace detail {
  52. template <class T>
  53. struct QxDao_Helper_Container { ; };
  54. } // namespace detail
  55. } // namespace dao
  56. } // namespace qx
  57. QX_DAO_HELPER_CONTAINER(std::vector)
  58. QX_DAO_HELPER_CONTAINER(std::list)
  59. QX_DAO_HELPER_CONTAINER(std::set)
  60. QX_DAO_HELPER_CONTAINER_KEY_VALUE(std::map)
  61. #ifdef _QX_ENABLE_BOOST
  62. QX_DAO_HELPER_CONTAINER(boost::unordered_set)
  63. QX_DAO_HELPER_CONTAINER(boost::unordered_multiset)
  64. QX_DAO_HELPER_CONTAINER_KEY_VALUE(boost::unordered_map)
  65. QX_DAO_HELPER_CONTAINER_KEY_VALUE(boost::unordered_multimap)
  66. #endif // _QX_ENABLE_BOOST
  67. QX_DAO_HELPER_CONTAINER(std::unordered_set)
  68. QX_DAO_HELPER_CONTAINER(std::unordered_multiset)
  69. QX_DAO_HELPER_CONTAINER_KEY_VALUE(std::unordered_map)
  70. QX_DAO_HELPER_CONTAINER_KEY_VALUE(std::unordered_multimap)
  71. QX_DAO_HELPER_CONTAINER(QVector)
  72. QX_DAO_HELPER_CONTAINER(QList)
  73. QX_DAO_HELPER_CONTAINER(QLinkedList)
  74. QX_DAO_HELPER_CONTAINER(QSet)
  75. QX_DAO_HELPER_CONTAINER_KEY_VALUE(QMap)
  76. QX_DAO_HELPER_CONTAINER_KEY_VALUE(QMultiMap)
  77. QX_DAO_HELPER_CONTAINER_KEY_VALUE(QHash)
  78. QX_DAO_HELPER_CONTAINER_KEY_VALUE(QMultiHash)
  79. QX_DAO_HELPER_CONTAINER_KEY_VALUE(qx::QxCollection)