is_container.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  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. #ifndef _QX_IS_CONTAINER_H_
  32. #define _QX_IS_CONTAINER_H_
  33. #ifdef _MSC_VER
  34. #pragma once
  35. #endif
  36. /*!
  37. * \file is_container.h
  38. * \author Lionel Marty
  39. * \ingroup QxTraits
  40. * \brief qx::trait::is_container<T>::value : return true if T is a container from stl, boost, Qt or QxOrm library, otherwise return false
  41. */
  42. #include <QxTraits/is_boost_unordered_map.h>
  43. #include <QxTraits/is_boost_unordered_set.h>
  44. #include <QxTraits/is_qt_hash.h>
  45. #include <QxTraits/is_qt_linked_list.h>
  46. #include <QxTraits/is_qt_list.h>
  47. #include <QxTraits/is_qt_map.h>
  48. #include <QxTraits/is_qt_multi_hash.h>
  49. #include <QxTraits/is_qt_multi_map.h>
  50. #include <QxTraits/is_qt_set.h>
  51. #include <QxTraits/is_qt_vector.h>
  52. #include <QxTraits/is_qx_collection.h>
  53. #include <QxTraits/is_std_list.h>
  54. #include <QxTraits/is_std_map.h>
  55. #include <QxTraits/is_std_set.h>
  56. #include <QxTraits/is_std_vector.h>
  57. #include <QxTraits/is_std_unordered_map.h>
  58. #include <QxTraits/is_std_unordered_set.h>
  59. #include <QxCollection/QxCollection.h>
  60. namespace qx {
  61. namespace trait {
  62. /*!
  63. * \ingroup QxTraits
  64. * \brief qx::trait::is_container<T>::value : return true if T is a container from stl, boost, Qt or QxOrm library, otherwise return false
  65. */
  66. template <typename T>
  67. struct is_container : public std::false_type { ; };
  68. #ifdef _QX_ENABLE_BOOST
  69. template <typename Key, typename Value>
  70. struct is_container< boost::unordered_map<Key, Value> > : public std::true_type { ; };
  71. template <typename Key, typename Value>
  72. struct is_container< boost::unordered_map<Key, Value> & > : public std::true_type { ; };
  73. template <typename Key, typename Value>
  74. struct is_container< const boost::unordered_map<Key, Value> > : public std::true_type { ; };
  75. template <typename Key, typename Value>
  76. struct is_container< const boost::unordered_map<Key, Value> & > : public std::true_type { ; };
  77. template <typename Key, typename Value>
  78. struct is_container< boost::unordered_multimap<Key, Value> > : public std::true_type { ; };
  79. template <typename Key, typename Value>
  80. struct is_container< boost::unordered_multimap<Key, Value> & > : public std::true_type { ; };
  81. template <typename Key, typename Value>
  82. struct is_container< const boost::unordered_multimap<Key, Value> > : public std::true_type { ; };
  83. template <typename Key, typename Value>
  84. struct is_container< const boost::unordered_multimap<Key, Value> & > : public std::true_type { ; };
  85. template <typename T>
  86. struct is_container< boost::unordered_set<T> > : public std::true_type { ; };
  87. template <typename T>
  88. struct is_container< boost::unordered_set<T> & > : public std::true_type { ; };
  89. template <typename T>
  90. struct is_container< const boost::unordered_set<T> > : public std::true_type { ; };
  91. template <typename T>
  92. struct is_container< const boost::unordered_set<T> & > : public std::true_type { ; };
  93. template <typename T>
  94. struct is_container< boost::unordered_multiset<T> > : public std::true_type { ; };
  95. template <typename T>
  96. struct is_container< boost::unordered_multiset<T> & > : public std::true_type { ; };
  97. template <typename T>
  98. struct is_container< const boost::unordered_multiset<T> > : public std::true_type { ; };
  99. template <typename T>
  100. struct is_container< const boost::unordered_multiset<T> & > : public std::true_type { ; };
  101. #endif // _QX_ENABLE_BOOST
  102. template <typename Key, typename Value>
  103. struct is_container< QHash<Key, Value> > : public std::true_type { ; };
  104. template <typename Key, typename Value>
  105. struct is_container< QHash<Key, Value> & > : public std::true_type { ; };
  106. template <typename Key, typename Value>
  107. struct is_container< const QHash<Key, Value> > : public std::true_type { ; };
  108. template <typename Key, typename Value>
  109. struct is_container< const QHash<Key, Value> & > : public std::true_type { ; };
  110. template <typename T>
  111. struct is_container< QLinkedList<T> > : public std::true_type { ; };
  112. template <typename T>
  113. struct is_container< QLinkedList<T> & > : public std::true_type { ; };
  114. template <typename T>
  115. struct is_container< const QLinkedList<T> > : public std::true_type { ; };
  116. template <typename T>
  117. struct is_container< const QLinkedList<T> & > : public std::true_type { ; };
  118. template <typename T>
  119. struct is_container< QList<T> > : public std::true_type { ; };
  120. template <typename T>
  121. struct is_container< QList<T> & > : public std::true_type { ; };
  122. template <typename T>
  123. struct is_container< const QList<T> > : public std::true_type { ; };
  124. template <typename T>
  125. struct is_container< const QList<T> & > : public std::true_type { ; };
  126. template <typename Key, typename Value>
  127. struct is_container< QMap<Key, Value> > : public std::true_type { ; };
  128. template <typename Key, typename Value>
  129. struct is_container< QMap<Key, Value> & > : public std::true_type { ; };
  130. template <typename Key, typename Value>
  131. struct is_container< const QMap<Key, Value> > : public std::true_type { ; };
  132. template <typename Key, typename Value>
  133. struct is_container< const QMap<Key, Value> & > : public std::true_type { ; };
  134. template <typename Key, typename Value>
  135. struct is_container< QMultiHash<Key, Value> > : public std::true_type { ; };
  136. template <typename Key, typename Value>
  137. struct is_container< QMultiHash<Key, Value> & > : public std::true_type { ; };
  138. template <typename Key, typename Value>
  139. struct is_container< const QMultiHash<Key, Value> > : public std::true_type { ; };
  140. template <typename Key, typename Value>
  141. struct is_container< const QMultiHash<Key, Value> & > : public std::true_type { ; };
  142. template <typename Key, typename Value>
  143. struct is_container< QMultiMap<Key, Value> > : public std::true_type { ; };
  144. template <typename Key, typename Value>
  145. struct is_container< QMultiMap<Key, Value> & > : public std::true_type { ; };
  146. template <typename Key, typename Value>
  147. struct is_container< const QMultiMap<Key, Value> > : public std::true_type { ; };
  148. template <typename Key, typename Value>
  149. struct is_container< const QMultiMap<Key, Value> & > : public std::true_type { ; };
  150. template <typename T>
  151. struct is_container< QSet<T> > : public std::true_type { ; };
  152. template <typename T>
  153. struct is_container< QSet<T> & > : public std::true_type { ; };
  154. template <typename T>
  155. struct is_container< const QSet<T> > : public std::true_type { ; };
  156. template <typename T>
  157. struct is_container< const QSet<T> & > : public std::true_type { ; };
  158. template <typename T>
  159. struct is_container< QVector<T> > : public std::true_type { ; };
  160. template <typename T>
  161. struct is_container< QVector<T> & > : public std::true_type { ; };
  162. template <typename T>
  163. struct is_container< const QVector<T> > : public std::true_type { ; };
  164. template <typename T>
  165. struct is_container< const QVector<T> & > : public std::true_type { ; };
  166. template <typename Key, typename Value>
  167. struct is_container< qx::QxCollection<Key, Value> > : public std::true_type { ; };
  168. template <typename Key, typename Value>
  169. struct is_container< qx::QxCollection<Key, Value> & > : public std::true_type { ; };
  170. template <typename Key, typename Value>
  171. struct is_container< const qx::QxCollection<Key, Value> > : public std::true_type { ; };
  172. template <typename Key, typename Value>
  173. struct is_container< const qx::QxCollection<Key, Value> & > : public std::true_type { ; };
  174. template <typename T>
  175. struct is_container< std::list<T> > : public std::true_type { ; };
  176. template <typename T>
  177. struct is_container< std::list<T> & > : public std::true_type { ; };
  178. template <typename T>
  179. struct is_container< const std::list<T> > : public std::true_type { ; };
  180. template <typename T>
  181. struct is_container< const std::list<T> & > : public std::true_type { ; };
  182. template <typename Key, typename Value>
  183. struct is_container< std::map<Key, Value> > : public std::true_type { ; };
  184. template <typename Key, typename Value>
  185. struct is_container< std::map<Key, Value> & > : public std::true_type { ; };
  186. template <typename Key, typename Value>
  187. struct is_container< const std::map<Key, Value> > : public std::true_type { ; };
  188. template <typename Key, typename Value>
  189. struct is_container< const std::map<Key, Value> & > : public std::true_type { ; };
  190. template <typename T>
  191. struct is_container< std::set<T> > : public std::true_type { ; };
  192. template <typename T>
  193. struct is_container< std::set<T> & > : public std::true_type { ; };
  194. template <typename T>
  195. struct is_container< const std::set<T> > : public std::true_type { ; };
  196. template <typename T>
  197. struct is_container< const std::set<T> & > : public std::true_type { ; };
  198. template <typename T>
  199. struct is_container< std::vector<T> > : public std::true_type { ; };
  200. template <typename T>
  201. struct is_container< std::vector<T> & > : public std::true_type { ; };
  202. template <typename T>
  203. struct is_container< const std::vector<T> > : public std::true_type { ; };
  204. template <typename T>
  205. struct is_container< const std::vector<T> & > : public std::true_type { ; };
  206. template <typename Key, typename Value>
  207. struct is_container< std::unordered_map<Key, Value> > : public std::true_type { ; };
  208. template <typename Key, typename Value>
  209. struct is_container< std::unordered_map<Key, Value> & > : public std::true_type { ; };
  210. template <typename Key, typename Value>
  211. struct is_container< const std::unordered_map<Key, Value> > : public std::true_type { ; };
  212. template <typename Key, typename Value>
  213. struct is_container< const std::unordered_map<Key, Value> & > : public std::true_type { ; };
  214. template <typename Key, typename Value>
  215. struct is_container< std::unordered_multimap<Key, Value> > : public std::true_type { ; };
  216. template <typename Key, typename Value>
  217. struct is_container< std::unordered_multimap<Key, Value> & > : public std::true_type { ; };
  218. template <typename Key, typename Value>
  219. struct is_container< const std::unordered_multimap<Key, Value> > : public std::true_type { ; };
  220. template <typename Key, typename Value>
  221. struct is_container< const std::unordered_multimap<Key, Value> & > : public std::true_type { ; };
  222. template <typename T>
  223. struct is_container< std::unordered_set<T> > : public std::true_type { ; };
  224. template <typename T>
  225. struct is_container< std::unordered_set<T> & > : public std::true_type { ; };
  226. template <typename T>
  227. struct is_container< const std::unordered_set<T> > : public std::true_type { ; };
  228. template <typename T>
  229. struct is_container< const std::unordered_set<T> & > : public std::true_type { ; };
  230. template <typename T>
  231. struct is_container< std::unordered_multiset<T> > : public std::true_type { ; };
  232. template <typename T>
  233. struct is_container< std::unordered_multiset<T> & > : public std::true_type { ; };
  234. template <typename T>
  235. struct is_container< const std::unordered_multiset<T> > : public std::true_type { ; };
  236. template <typename T>
  237. struct is_container< const std::unordered_multiset<T> & > : public std::true_type { ; };
  238. } // namespace trait
  239. } // namespace qx
  240. #endif // _QX_IS_CONTAINER_H_