QxOrm 1.1.9
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 #include <QtCore/qpair.h>
00044 
00045 #include <boost/tuple/tuple.hpp>
00046 #include <boost/tuple/tuple_comparison.hpp>
00047 #include <boost/tuple/tuple_io.hpp>
00048 
00049 inline std::size_t hash_value(const QString & s)      { return qHash(s); }
00050 inline std::size_t hash_value(const QDate & d)        { return qHash(d.toJulianDay()); }
00051 inline std::size_t hash_value(const QTime & t)        { return qHash(t.toString()); }
00052 inline std::size_t hash_value(const QDateTime & dt)   { return qHash(dt.toString()); }
00053 inline std::size_t hash_value(const QVariant & v)     { return qHash(v.toString()); }
00054 
00055 template <typename T0, typename T1>
00056 inline std::size_t hash_value(const QPair<T0, T1> & p)
00057 {
00058    std::size_t seed = 0;
00059    boost::hash_combine(seed, p.first);
00060    boost::hash_combine(seed, p.second);
00061    return seed;
00062 }
00063 
00064 namespace boost {
00065 namespace tuples {
00066 
00067 template <typename T0, typename T1>
00068 inline std::size_t hash_value(const boost::tuple<T0, T1> & tu)
00069 {
00070    std::size_t seed = 0;
00071    boost::hash_combine(seed, boost::get<0>(tu));
00072    boost::hash_combine(seed, boost::get<1>(tu));
00073    return seed;
00074 }
00075 
00076 template <typename T0, class T1, typename T2>
00077 inline std::size_t hash_value(const boost::tuple<T0, T1, T2> & tu)
00078 {
00079    std::size_t seed = 0;
00080    boost::hash_combine(seed, boost::get<0>(tu));
00081    boost::hash_combine(seed, boost::get<1>(tu));
00082    boost::hash_combine(seed, boost::get<2>(tu));
00083    return seed;
00084 }
00085 
00086 template <typename T0, typename T1, typename T2, typename T3>
00087 inline std::size_t hash_value(const boost::tuple<T0, T1, T2, T3> & tu)
00088 {
00089    std::size_t seed = 0;
00090    boost::hash_combine(seed, boost::get<0>(tu));
00091    boost::hash_combine(seed, boost::get<1>(tu));
00092    boost::hash_combine(seed, boost::get<2>(tu));
00093    boost::hash_combine(seed, boost::get<3>(tu));
00094    return seed;
00095 }
00096 
00097 template <typename T0, typename T1, typename T2, typename T3, typename T4>
00098 inline std::size_t hash_value(const boost::tuple<T0, T1, T2, T3, T4> & tu)
00099 {
00100    std::size_t seed = 0;
00101    boost::hash_combine(seed, boost::get<0>(tu));
00102    boost::hash_combine(seed, boost::get<1>(tu));
00103    boost::hash_combine(seed, boost::get<2>(tu));
00104    boost::hash_combine(seed, boost::get<3>(tu));
00105    boost::hash_combine(seed, boost::get<4>(tu));
00106    return seed;
00107 }
00108 
00109 template <typename T0, typename T1, typename T2, typename T3, typename T4, typename T5>
00110 inline std::size_t hash_value(const boost::tuple<T0, T1, T2, T3, T4, T5> & 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    return seed;
00120 }
00121 
00122 template <typename T0, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
00123 inline std::size_t hash_value(const boost::tuple<T0, T1, T2, T3, T4, T5, T6> & tu)
00124 {
00125    std::size_t seed = 0;
00126    boost::hash_combine(seed, boost::get<0>(tu));
00127    boost::hash_combine(seed, boost::get<1>(tu));
00128    boost::hash_combine(seed, boost::get<2>(tu));
00129    boost::hash_combine(seed, boost::get<3>(tu));
00130    boost::hash_combine(seed, boost::get<4>(tu));
00131    boost::hash_combine(seed, boost::get<5>(tu));
00132    boost::hash_combine(seed, boost::get<6>(tu));
00133    return seed;
00134 }
00135 
00136 template <typename T0, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7>
00137 inline std::size_t hash_value(const boost::tuple<T0, T1, T2, T3, T4, T5, T6, T7> & tu)
00138 {
00139    std::size_t seed = 0;
00140    boost::hash_combine(seed, boost::get<0>(tu));
00141    boost::hash_combine(seed, boost::get<1>(tu));
00142    boost::hash_combine(seed, boost::get<2>(tu));
00143    boost::hash_combine(seed, boost::get<3>(tu));
00144    boost::hash_combine(seed, boost::get<4>(tu));
00145    boost::hash_combine(seed, boost::get<5>(tu));
00146    boost::hash_combine(seed, boost::get<6>(tu));
00147    boost::hash_combine(seed, boost::get<7>(tu));
00148    return seed;
00149 }
00150 
00151 template <typename T0, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8>
00152 inline std::size_t hash_value(const boost::tuple<T0, T1, T2, T3, T4, T5, T6, T7, T8> & tu)
00153 {
00154    std::size_t seed = 0;
00155    boost::hash_combine(seed, boost::get<0>(tu));
00156    boost::hash_combine(seed, boost::get<1>(tu));
00157    boost::hash_combine(seed, boost::get<2>(tu));
00158    boost::hash_combine(seed, boost::get<3>(tu));
00159    boost::hash_combine(seed, boost::get<4>(tu));
00160    boost::hash_combine(seed, boost::get<5>(tu));
00161    boost::hash_combine(seed, boost::get<6>(tu));
00162    boost::hash_combine(seed, boost::get<7>(tu));
00163    boost::hash_combine(seed, boost::get<8>(tu));
00164    return seed;
00165 }
00166 
00167 template <typename T0, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9>
00168 inline std::size_t hash_value(const boost::tuple<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9> & tu)
00169 {
00170    std::size_t seed = 0;
00171    boost::hash_combine(seed, boost::get<0>(tu));
00172    boost::hash_combine(seed, boost::get<1>(tu));
00173    boost::hash_combine(seed, boost::get<2>(tu));
00174    boost::hash_combine(seed, boost::get<3>(tu));
00175    boost::hash_combine(seed, boost::get<4>(tu));
00176    boost::hash_combine(seed, boost::get<5>(tu));
00177    boost::hash_combine(seed, boost::get<6>(tu));
00178    boost::hash_combine(seed, boost::get<7>(tu));
00179    boost::hash_combine(seed, boost::get<8>(tu));
00180    boost::hash_combine(seed, boost::get<9>(tu));
00181    return seed;
00182 }
00183 
00184 } // namespace tuples
00185 } // namespace boost
00186 
00187 #endif // _QX_HASH_VALUE_H_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines