| QxOrm 1.2.7 C++ Object Relational Mapping library

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

- File List
- File Members

is_container_base_of.h
Go to the documentation of this file.

    00001 /****************************************************************************
    00002 **
    00003 ** http://www.qxorm.com/
    00004 ** Copyright (C) 2013 Lionel Marty (contact@qxorm.com)
    00005 **
    00006 ** This file is part of the QxOrm library
    00007 **
    00008 ** This software is provided 'as-is', without any express or implied
    00009 ** warranty. In no event will the authors be held liable for any
    00010 ** damages arising from the use of this software
    00011 **
    00012 ** Commercial Usage
    00013 ** Licensees holding valid commercial QxOrm licenses may use this file in
    00014 ** accordance with the commercial license agreement provided with the
    00015 ** Software or, alternatively, in accordance with the terms contained in
    00016 ** a written agreement between you and Lionel Marty
    00017 **
    00018 ** GNU General Public License Usage
    00019 ** Alternatively, this file may be used under the terms of the GNU
    00020 ** General Public License version 3.0 as published by the Free Software
    00021 ** Foundation and appearing in the file 'license.gpl3.txt' included in the
    00022 ** packaging of this file. Please review the following information to
    00023 ** ensure the GNU General Public License version 3.0 requirements will be
    00024 ** met : http://www.gnu.org/copyleft/gpl.html
    00025 **
    00026 ** If you are unsure which license is appropriate for your use, or
    00027 ** if you have questions regarding the use of this file, please contact :
    00028 ** contact@qxorm.com
    00029 **
    00030 ****************************************************************************/
    00031
    00032 #ifndef _QX_IS_CONTAINER_BASE_OF_H_
    00033 #define _QX_IS_CONTAINER_BASE_OF_H_
    00034
    00035 #ifdef _MSC_VER
    00036 #pragma once
    00037 #endif
    00038
    00039 #include <boost/mpl/if.hpp>
    00040 #include <boost/mpl/logical.hpp>
    00041 #include <boost/type_traits/is_base_of.hpp>
    00042
    00043 #include <QxTraits/is_container.h>
    00044
    00045 #define qx_container_base_of_test_0() (sizeof(qx::trait::is_container_base_of<B, D>::removeContainer(b, d)) == sizeof(char))
    00046 #define qx_container_base_of_test_1() (sizeof(qx::trait::is_container_base_of<B, D>::removeContainer((* b_std_vector), d)) == sizeof(char))
    00047 #define qx_container_base_of_test_2() (sizeof(qx::trait::is_container_base_of<B, D>::removeContainer((* b_std_list), d)) == sizeof(char))
    00048 #define qx_container_base_of_test_3() (sizeof(qx::trait::is_container_base_of<B, D>::removeContainer((* b_std_set), d)) == sizeof(char))
    00049 #define qx_container_base_of_test_4() (sizeof(qx::trait::is_container_base_of<B, D>::removeContainer((* b_qt_vector), d)) == sizeof(char))
    00050 #define qx_container_base_of_test_5() (sizeof(qx::trait::is_container_base_of<B, D>::removeContainer((* b_qt_list), d)) == sizeof(char))
    00051 #define qx_container_base_of_test_6() (sizeof(qx::trait::is_container_base_of<B, D>::removeContainer((* b_qt_set), d)) == sizeof(char))
    00052 #define qx_container_base_of_test_7() (sizeof(qx::trait::is_container_base_of<B, D>::removeContainer((* b_qt_linked_list), d)) == sizeof(char))
    00053 #define qx_container_base_of_test_8() (sizeof(qx::trait::is_container_base_of<B, D>::removeContainer((* b_boost_unordered_set), d)) == sizeof(char))
    00054 #define qx_container_base_of_test_9() (sizeof(qx::trait::is_container_base_of<B, D>::removeContainer((* b_boost_unordered_multi_set), d)) == sizeof(char))
    00055
    00056 #define qx_container_base_of_all_test() \
    00057 qx_container_base_of_test_1() || qx_container_base_of_test_2() || qx_container_base_of_test_3() || \
    00058 qx_container_base_of_test_4() || qx_container_base_of_test_5() || qx_container_base_of_test_6() || \
    00059 qx_container_base_of_test_7() || qx_container_base_of_test_8() || qx_container_base_of_test_9()
    00060
    00061 namespace qx {
    00062 namespace trait {
    00063
    00064 template <typename B, typename D>
    00065 class is_container_base_of
    00066 {
    00067
    00068 private:
    00069
    00070    template <typename V, typename W>
    00071    static typename boost::mpl::if_c<boost::is_base_of<V, W>::value, char, int>::type removeContainer(const std::vector<V> &, const std::vector<W> &);
    00072
    00073    template <typename V, typename W>
    00074    static typename boost::mpl::if_c<boost::is_base_of<V, W>::value, char, int>::type removeContainer(const std::list<V> &, const std::list<W> &);
    00075
    00076    template <typename V, typename W>
    00077    static typename boost::mpl::if_c<boost::is_base_of<V, W>::value, char, int>::type removeContainer(const std::set<V> &, const std::set<W> &);
    00078
    00079    template <typename V, typename W>
    00080    static typename boost::mpl::if_c<boost::is_base_of<V, W>::value, char, int>::type removeContainer(const QVector<V> &, const QVector<W> &);
    00081
    00082    template <typename V, typename W>
    00083    static typename boost::mpl::if_c<boost::is_base_of<V, W>::value, char, int>::type removeContainer(const QList<V> &, const QList<W> &);
    00084
    00085    template <typename V, typename W>
    00086    static typename boost::mpl::if_c<boost::is_base_of<V, W>::value, char, int>::type removeContainer(const QSet<V> &, const QSet<W> &);
    00087
    00088    template <typename V, typename W>
    00089    static typename boost::mpl::if_c<boost::is_base_of<V, W>::value, char, int>::type removeContainer(const QLinkedList<V> &, const QLinkedList<W> &);
    00090
    00091    template <typename V, typename W>
    00092    static typename boost::mpl::if_c<boost::is_base_of<V, W>::value, char, int>::type removeContainer(const boost::unordered_set<V> &, const boost::unordered_set<W> &);
    00093
    00094    template <typename V, typename W>
    00095    static typename boost::mpl::if_c<boost::is_base_of<V, W>::value, char, int>::type removeContainer(const boost::unordered_multiset<V> &, const boost::unordered_multiset<W> &);
    00096
    00097    static int removeContainer(...);
    00098    static B b;
    00099    static D d;
    00100
    00101    static std::vector<B> * b_std_vector;
    00102    static std::list<B> * b_std_list;
    00103    static std::set<B> * b_std_set;
    00104    static QVector<B> * b_qt_vector;
    00105    static QList<B> * b_qt_list;
    00106    static QSet<B> * b_qt_set;
    00107    static QLinkedList<B> * b_qt_linked_list;
    00108    static boost::unordered_set<B> * b_boost_unordered_set;
    00109    static boost::unordered_multiset<B> * b_boost_unordered_multi_set;
    00110
    00111    enum { value_0 = (qx::trait::is_container<D>::value) };
    00112    enum { value_1 = (qx::trait::is_container<B>::value) };
    00113    enum { value_2 = ((value_0 && value_1) ? qx_container_base_of_test_0() : 0) };
    00114    enum { value_3 = ((value_0 && ! value_1) ? qx_container_base_of_all_test() : 0) };
    00115
    00116 public:
    00117
    00118    enum { value = (qx::trait::is_container_base_of<B, D>::value_2 || qx::trait::is_container_base_of<B, D>::value_3) };
    00119
    00120    typedef typename boost::mpl::if_c<qx::trait::is_container_base_of<B, D>::value, boost::mpl::true_, boost::mpl::false_>::type type;
    00121
    00122 };
    00123
    00124 } // namespace trait
    00125 } // namespace qx
    00126
    00127 #endif // _QX_IS_CONTAINER_BASE_OF_H_