is_qt_variant_compatible.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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_QT_VARIANT_COMPATIBLE_H_
  32. #define _QX_IS_QT_VARIANT_COMPATIBLE_H_
  33. #ifdef _MSC_VER
  34. #pragma once
  35. #endif
  36. /*!
  37. * \file is_qt_variant_compatible.h
  38. * \author Lionel Marty
  39. * \ingroup QxTraits
  40. * \brief qx::trait::is_qt_variant_compatible<T>::value : return true if T can be host into a QVariant object of Qt library, otherwise return false
  41. */
  42. #include <QtCore/qvariant.h>
  43. #include <QxCommon/QxConfig.h>
  44. namespace qx {
  45. namespace trait {
  46. /*!
  47. * \ingroup QxTraits
  48. * \brief qx::trait::is_qt_variant_compatible<T>::value : return true if T can be host into a QVariant object of Qt library, otherwise return false
  49. */
  50. template <typename T>
  51. struct is_qt_variant_compatible
  52. { enum { value = (std::is_enum<T>::value || std::is_integral<T>::value) }; };
  53. template <> struct is_qt_variant_compatible<bool> { enum { value = true }; };
  54. template <> struct is_qt_variant_compatible<short> { enum { value = true }; };
  55. template <> struct is_qt_variant_compatible<int> { enum { value = true }; };
  56. template <> struct is_qt_variant_compatible<long> { enum { value = true }; };
  57. template <> struct is_qt_variant_compatible<long long> { enum { value = true }; };
  58. template <> struct is_qt_variant_compatible<float> { enum { value = true }; };
  59. template <> struct is_qt_variant_compatible<double> { enum { value = true }; };
  60. template <> struct is_qt_variant_compatible<long double> { enum { value = true }; };
  61. template <> struct is_qt_variant_compatible<unsigned short> { enum { value = true }; };
  62. template <> struct is_qt_variant_compatible<unsigned int> { enum { value = true }; };
  63. template <> struct is_qt_variant_compatible<unsigned long> { enum { value = true }; };
  64. template <> struct is_qt_variant_compatible<unsigned long long> { enum { value = true }; };
  65. template <> struct is_qt_variant_compatible<QString> { enum { value = true }; };
  66. template <> struct is_qt_variant_compatible<QDate> { enum { value = true }; };
  67. template <> struct is_qt_variant_compatible<QTime> { enum { value = true }; };
  68. template <> struct is_qt_variant_compatible<QDateTime> { enum { value = true }; };
  69. template <> struct is_qt_variant_compatible<QBitArray> { enum { value = true }; };
  70. template <> struct is_qt_variant_compatible<QByteArray> { enum { value = true }; };
  71. template <> struct is_qt_variant_compatible<QLatin1String> { enum { value = true }; };
  72. template <> struct is_qt_variant_compatible<QStringList> { enum { value = true }; };
  73. template <> struct is_qt_variant_compatible<QChar> { enum { value = true }; };
  74. template <> struct is_qt_variant_compatible<QRegExp> { enum { value = true }; };
  75. template <> struct is_qt_variant_compatible<QLocale> { enum { value = true }; };
  76. template <> struct is_qt_variant_compatible<QSize> { enum { value = true }; };
  77. template <> struct is_qt_variant_compatible<QSizeF> { enum { value = true }; };
  78. template <> struct is_qt_variant_compatible<QPoint> { enum { value = true }; };
  79. template <> struct is_qt_variant_compatible<QPointF> { enum { value = true }; };
  80. template <> struct is_qt_variant_compatible<QLine> { enum { value = true }; };
  81. template <> struct is_qt_variant_compatible<QLineF> { enum { value = true }; };
  82. template <> struct is_qt_variant_compatible<QRect> { enum { value = true }; };
  83. template <> struct is_qt_variant_compatible<QRectF> { enum { value = true }; };
  84. template <> struct is_qt_variant_compatible<QUrl> { enum { value = true }; };
  85. template <> struct is_qt_variant_compatible<QVariant> { enum { value = true }; };
  86. #ifdef _QX_ENABLE_QT_GUI
  87. template <> struct is_qt_variant_compatible<QBrush> { enum { value = true }; };
  88. template <> struct is_qt_variant_compatible<QColor> { enum { value = true }; };
  89. template <> struct is_qt_variant_compatible<QFont> { enum { value = true }; };
  90. template <> struct is_qt_variant_compatible<QImage> { enum { value = true }; };
  91. template <> struct is_qt_variant_compatible<QPixmap> { enum { value = true }; };
  92. template <> struct is_qt_variant_compatible<QRegion> { enum { value = true }; };
  93. #endif // _QX_ENABLE_QT_GUI
  94. template <> struct is_qt_variant_compatible< QList<QVariant> > { enum { value = true }; };
  95. template <> struct is_qt_variant_compatible< QMap<QString, QVariant> > { enum { value = true }; };
  96. template <> struct is_qt_variant_compatible< QHash<QString, QVariant> > { enum { value = true }; };
  97. } // namespace trait
  98. } // namespace qx
  99. #endif // _QX_IS_QT_VARIANT_COMPATIBLE_H_