QxOrm 1.1.6
C++ Object Relational Mapping library
QxHashValue.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_HASH_VALUE_H_
00027 #define _QX_HASH_VALUE_H_
00028 
00029 #ifdef _MSC_VER
00030 #pragma once
00031 #endif
00032 
00040 #include <QtCore/qstring.h>
00041 #include <QtCore/qdatetime.h>
00042 #include <QtCore/qvariant.h>
00043 
00044 #include <boost/tuple/tuple.hpp>
00045 #include <boost/tuple/tuple_comparison.hpp>
00046 #include <boost/tuple/tuple_io.hpp>
00047 
00048 inline std::size_t hash_value(const QString & s)      { return qHash(s); }
00049 inline std::size_t hash_value(const QDate & d)        { return qHash(d.toJulianDay()); }
00050 inline std::size_t hash_value(const QTime & t)        { return qHash(t.toString()); }
00051 inline std::size_t hash_value(const QDateTime & dt)   { return qHash(dt.toString()); }
00052 inline std::size_t hash_value(const QVariant & v)     { return qHash(v.toString()); }
00053 
00054 template <typename T0, typename T1>
00055 inline std::size_t hash_value(const boost::tuple<T0, T1> & tu)
00056 {
00057    std::size_t seed = 0;
00058    boost::hash_combine(seed, boost::get<0>(tu));
00059    boost::hash_combine(seed, boost::get<1>(tu));
00060    return seed;
00061 }
00062 
00063 template <typename T0, class T1, typename T2>
00064 inline std::size_t hash_value(const boost::tuple<T0, T1, T2> & tu)
00065 {
00066    std::size_t seed = 0;
00067    boost::hash_combine(seed, boost::get<0>(tu));
00068    boost::hash_combine(seed, boost::get<1>(tu));
00069    boost::hash_combine(seed, boost::get<2>(tu));
00070    return seed;
00071 }
00072 
00073 template <typename T0, typename T1, typename T2, typename T3>
00074 inline std::size_t hash_value(const boost::tuple<T0, T1, T2, T3> & tu)
00075 {
00076    std::size_t seed = 0;
00077    boost::hash_combine(seed, boost::get<0>(tu));
00078    boost::hash_combine(seed, boost::get<1>(tu));
00079    boost::hash_combine(seed, boost::get<2>(tu));
00080    boost::hash_combine(seed, boost::get<3>(tu));
00081    return seed;
00082 }
00083 
00084 template <typename T0, typename T1, typename T2, typename T3, typename T4>
00085 inline std::size_t hash_value(const boost::tuple<T0, T1, T2, T3, T4> & tu)
00086 {
00087    std::size_t seed = 0;
00088    boost::hash_combine(seed, boost::get<0>(tu));
00089    boost::hash_combine(seed, boost::get<1>(tu));
00090    boost::hash_combine(seed, boost::get<2>(tu));
00091    boost::hash_combine(seed, boost::get<3>(tu));
00092    boost::hash_combine(seed, boost::get<4>(tu));
00093    return seed;
00094 }
00095 
00096 template <typename T0, typename T1, typename T2, typename T3, typename T4, typename T5>
00097 inline std::size_t hash_value(const boost::tuple<T0, T1, T2, T3, T4, T5> & tu)
00098 {
00099    std::size_t seed = 0;
00100    boost::hash_combine(seed, boost::get<0>(tu));
00101    boost::hash_combine(seed, boost::get<1>(tu));
00102    boost::hash_combine(seed, boost::get<2>(tu));
00103    boost::hash_combine(seed, boost::get<3>(tu));
00104    boost::hash_combine(seed, boost::get<4>(tu));
00105    boost::hash_combine(seed, boost::get<5>(tu));
00106    return seed;
00107 }
00108 
00109 template <typename T0, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
00110 inline std::size_t hash_value(const boost::tuple<T0, T1, T2, T3, T4, T5, T6> & tu)
00111 {
00112    std::size_t seed = 0;
00113    boost::hash_combine(seed, boost::get<0>(tu));
00114    boost::hash_combine(seed, boost::get<1>(tu));
00115    boost::hash_combine(seed, boost::get<2>(tu));
00116    boost::hash_combine(seed, boost::get<3>(tu));
00117    boost::hash_combine(seed, boost::get<4>(tu));
00118    boost::hash_combine(seed, boost::get<5>(tu));
00119    boost::hash_combine(seed, boost::get<6>(tu));
00120    return seed;
00121 }
00122 
00123 template <typename T0, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7>
00124 inline std::size_t hash_value(const boost::tuple<T0, T1, T2, T3, T4, T5, T6, T7> & tu)
00125 {
00126    std::size_t seed = 0;
00127    boost::hash_combine(seed, boost::get<0>(tu));
00128    boost::hash_combine(seed, boost::get<1>(tu));
00129    boost::hash_combine(seed, boost::get<2>(tu));
00130    boost::hash_combine(seed, boost::get<3>(tu));
00131    boost::hash_combine(seed, boost::get<4>(tu));
00132    boost::hash_combine(seed, boost::get<5>(tu));
00133    boost::hash_combine(seed, boost::get<6>(tu));
00134    boost::hash_combine(seed, boost::get<7>(tu));
00135    return seed;
00136 }
00137 
00138 template <typename T0, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8>
00139 inline std::size_t hash_value(const boost::tuple<T0, T1, T2, T3, T4, T5, T6, T7, T8> & tu)
00140 {
00141    std::size_t seed = 0;
00142    boost::hash_combine(seed, boost::get<0>(tu));
00143    boost::hash_combine(seed, boost::get<1>(tu));
00144    boost::hash_combine(seed, boost::get<2>(tu));
00145    boost::hash_combine(seed, boost::get<3>(tu));
00146    boost::hash_combine(seed, boost::get<4>(tu));
00147    boost::hash_combine(seed, boost::get<5>(tu));
00148    boost::hash_combine(seed, boost::get<6>(tu));
00149    boost::hash_combine(seed, boost::get<7>(tu));
00150    boost::hash_combine(seed, boost::get<8>(tu));
00151    return seed;
00152 }
00153 
00154 template <typename T0, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9>
00155 inline std::size_t hash_value(const boost::tuple<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9> & tu)
00156 {
00157    std::size_t seed = 0;
00158    boost::hash_combine(seed, boost::get<0>(tu));
00159    boost::hash_combine(seed, boost::get<1>(tu));
00160    boost::hash_combine(seed, boost::get<2>(tu));
00161    boost::hash_combine(seed, boost::get<3>(tu));
00162    boost::hash_combine(seed, boost::get<4>(tu));
00163    boost::hash_combine(seed, boost::get<5>(tu));
00164    boost::hash_combine(seed, boost::get<6>(tu));
00165    boost::hash_combine(seed, boost::get<7>(tu));
00166    boost::hash_combine(seed, boost::get<8>(tu));
00167    boost::hash_combine(seed, boost::get<9>(tu));
00168    return seed;
00169 }
00170 
00171 #endif // _QX_HASH_VALUE_H_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines