| QxOrm 1.4.1 C++ Object Relational Mapping library

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

- File List
- File Members

QxHashValue.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_HASH_VALUE_H_
    00033 #define _QX_HASH_VALUE_H_
    00034
    00035 #ifdef _MSC_VER
    00036 #pragma once
    00037 #endif
    00038
    00046 #include <QtCore/qstring.h>
    00047 #include <QtCore/qdatetime.h>
    00048 #include <QtCore/qvariant.h>
    00049 #include <QtCore/qpair.h>
    00050
    00051 #include <boost/tuple/tuple.hpp>
    00052 #include <boost/tuple/tuple_comparison.hpp>
    00053 #include <boost/tuple/tuple_io.hpp>
    00054
    00055 #ifdef _QX_CPP_11_TUPLE
    00056 #ifndef BOOST_NO_CXX11_HDR_TUPLE
    00057 #include <tuple>
    00058 #endif // BOOST_NO_CXX11_HDR_TUPLE
    00059 #endif // _QX_CPP_11_TUPLE
    00060
    00061 inline std::size_t hash_value(const QString & s)      { return qHash(s); }
    00062 inline std::size_t hash_value(const QDate & d)        { return qHash(d.toJulianDay()); }
    00063 inline std::size_t hash_value(const QTime & t)        { return qHash(t.toString()); }
    00064 inline std::size_t hash_value(const QDateTime & dt)   { return qHash(dt.toString()); }
    00065 inline std::size_t hash_value(const QVariant & v)     { return qHash(v.toString()); }
    00066
    00067 template <typename T0, typename T1>
    00068 inline std::size_t hash_value(const QPair<T0, T1> & p)
    00069 {
    00070    std::size_t seed = 0;
    00071    boost::hash_combine(seed, p.first);
    00072    boost::hash_combine(seed, p.second);
    00073    return seed;
    00074 }
    00075
    00076 namespace boost {
    00077 namespace tuples {
    00078
    00079 template <typename T0, typename T1>
    00080 inline std::size_t hash_value(const boost::tuple<T0, T1> & tu)
    00081 {
    00082    std::size_t seed = 0;
    00083    boost::hash_combine(seed, boost::get<0>(tu));
    00084    boost::hash_combine(seed, boost::get<1>(tu));
    00085    return seed;
    00086 }
    00087
    00088 template <typename T0, class T1, typename T2>
    00089 inline std::size_t hash_value(const boost::tuple<T0, T1, T2> & tu)
    00090 {
    00091    std::size_t seed = 0;
    00092    boost::hash_combine(seed, boost::get<0>(tu));
    00093    boost::hash_combine(seed, boost::get<1>(tu));
    00094    boost::hash_combine(seed, boost::get<2>(tu));
    00095    return seed;
    00096 }
    00097
    00098 template <typename T0, typename T1, typename T2, typename T3>
    00099 inline std::size_t hash_value(const boost::tuple<T0, T1, T2, T3> & tu)
    00100 {
    00101    std::size_t seed = 0;
    00102    boost::hash_combine(seed, boost::get<0>(tu));
    00103    boost::hash_combine(seed, boost::get<1>(tu));
    00104    boost::hash_combine(seed, boost::get<2>(tu));
    00105    boost::hash_combine(seed, boost::get<3>(tu));
    00106    return seed;
    00107 }
    00108
    00109 template <typename T0, typename T1, typename T2, typename T3, typename T4>
    00110 inline std::size_t hash_value(const boost::tuple<T0, T1, T2, T3, T4> & 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    return seed;
    00119 }
    00120
    00121 template <typename T0, typename T1, typename T2, typename T3, typename T4, typename T5>
    00122 inline std::size_t hash_value(const boost::tuple<T0, T1, T2, T3, T4, T5> & tu)
    00123 {
    00124    std::size_t seed = 0;
    00125    boost::hash_combine(seed, boost::get<0>(tu));
    00126    boost::hash_combine(seed, boost::get<1>(tu));
    00127    boost::hash_combine(seed, boost::get<2>(tu));
    00128    boost::hash_combine(seed, boost::get<3>(tu));
    00129    boost::hash_combine(seed, boost::get<4>(tu));
    00130    boost::hash_combine(seed, boost::get<5>(tu));
    00131    return seed;
    00132 }
    00133
    00134 template <typename T0, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
    00135 inline std::size_t hash_value(const boost::tuple<T0, T1, T2, T3, T4, T5, T6> & tu)
    00136 {
    00137    std::size_t seed = 0;
    00138    boost::hash_combine(seed, boost::get<0>(tu));
    00139    boost::hash_combine(seed, boost::get<1>(tu));
    00140    boost::hash_combine(seed, boost::get<2>(tu));
    00141    boost::hash_combine(seed, boost::get<3>(tu));
    00142    boost::hash_combine(seed, boost::get<4>(tu));
    00143    boost::hash_combine(seed, boost::get<5>(tu));
    00144    boost::hash_combine(seed, boost::get<6>(tu));
    00145    return seed;
    00146 }
    00147
    00148 template <typename T0, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7>
    00149 inline std::size_t hash_value(const boost::tuple<T0, T1, T2, T3, T4, T5, T6, T7> & tu)
    00150 {
    00151    std::size_t seed = 0;
    00152    boost::hash_combine(seed, boost::get<0>(tu));
    00153    boost::hash_combine(seed, boost::get<1>(tu));
    00154    boost::hash_combine(seed, boost::get<2>(tu));
    00155    boost::hash_combine(seed, boost::get<3>(tu));
    00156    boost::hash_combine(seed, boost::get<4>(tu));
    00157    boost::hash_combine(seed, boost::get<5>(tu));
    00158    boost::hash_combine(seed, boost::get<6>(tu));
    00159    boost::hash_combine(seed, boost::get<7>(tu));
    00160    return seed;
    00161 }
    00162
    00163 template <typename T0, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8>
    00164 inline std::size_t hash_value(const boost::tuple<T0, T1, T2, T3, T4, T5, T6, T7, T8> & tu)
    00165 {
    00166    std::size_t seed = 0;
    00167    boost::hash_combine(seed, boost::get<0>(tu));
    00168    boost::hash_combine(seed, boost::get<1>(tu));
    00169    boost::hash_combine(seed, boost::get<2>(tu));
    00170    boost::hash_combine(seed, boost::get<3>(tu));
    00171    boost::hash_combine(seed, boost::get<4>(tu));
    00172    boost::hash_combine(seed, boost::get<5>(tu));
    00173    boost::hash_combine(seed, boost::get<6>(tu));
    00174    boost::hash_combine(seed, boost::get<7>(tu));
    00175    boost::hash_combine(seed, boost::get<8>(tu));
    00176    return seed;
    00177 }
    00178
    00179 template <typename T0, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9>
    00180 inline std::size_t hash_value(const boost::tuple<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9> & tu)
    00181 {
    00182    std::size_t seed = 0;
    00183    boost::hash_combine(seed, boost::get<0>(tu));
    00184    boost::hash_combine(seed, boost::get<1>(tu));
    00185    boost::hash_combine(seed, boost::get<2>(tu));
    00186    boost::hash_combine(seed, boost::get<3>(tu));
    00187    boost::hash_combine(seed, boost::get<4>(tu));
    00188    boost::hash_combine(seed, boost::get<5>(tu));
    00189    boost::hash_combine(seed, boost::get<6>(tu));
    00190    boost::hash_combine(seed, boost::get<7>(tu));
    00191    boost::hash_combine(seed, boost::get<8>(tu));
    00192    boost::hash_combine(seed, boost::get<9>(tu));
    00193    return seed;
    00194 }
    00195
    00196 } // namespace tuples
    00197 } // namespace boost
    00198
    00199 #ifdef _QX_CPP_11_TUPLE
    00200 #ifndef BOOST_NO_CXX11_HDR_TUPLE
    00201
    00202 template <typename T0, typename T1>
    00203 inline std::size_t hash_value(const std::tuple<T0, T1> & tu)
    00204 {
    00205    std::size_t seed = 0;
    00206    boost::hash_combine(seed, std::get<0>(tu));
    00207    boost::hash_combine(seed, std::get<1>(tu));
    00208    return seed;
    00209 }
    00210
    00211 template <typename T0, class T1, typename T2>
    00212 inline std::size_t hash_value(const std::tuple<T0, T1, T2> & tu)
    00213 {
    00214    std::size_t seed = 0;
    00215    boost::hash_combine(seed, std::get<0>(tu));
    00216    boost::hash_combine(seed, std::get<1>(tu));
    00217    boost::hash_combine(seed, std::get<2>(tu));
    00218    return seed;
    00219 }
    00220
    00221 template <typename T0, typename T1, typename T2, typename T3>
    00222 inline std::size_t hash_value(const std::tuple<T0, T1, T2, T3> & tu)
    00223 {
    00224    std::size_t seed = 0;
    00225    boost::hash_combine(seed, std::get<0>(tu));
    00226    boost::hash_combine(seed, std::get<1>(tu));
    00227    boost::hash_combine(seed, std::get<2>(tu));
    00228    boost::hash_combine(seed, std::get<3>(tu));
    00229    return seed;
    00230 }
    00231
    00232 template <typename T0, typename T1, typename T2, typename T3, typename T4>
    00233 inline std::size_t hash_value(const std::tuple<T0, T1, T2, T3, T4> & tu)
    00234 {
    00235    std::size_t seed = 0;
    00236    boost::hash_combine(seed, std::get<0>(tu));
    00237    boost::hash_combine(seed, std::get<1>(tu));
    00238    boost::hash_combine(seed, std::get<2>(tu));
    00239    boost::hash_combine(seed, std::get<3>(tu));
    00240    boost::hash_combine(seed, std::get<4>(tu));
    00241    return seed;
    00242 }
    00243
    00244 template <typename T0, typename T1, typename T2, typename T3, typename T4, typename T5>
    00245 inline std::size_t hash_value(const std::tuple<T0, T1, T2, T3, T4, T5> & tu)
    00246 {
    00247    std::size_t seed = 0;
    00248    boost::hash_combine(seed, std::get<0>(tu));
    00249    boost::hash_combine(seed, std::get<1>(tu));
    00250    boost::hash_combine(seed, std::get<2>(tu));
    00251    boost::hash_combine(seed, std::get<3>(tu));
    00252    boost::hash_combine(seed, std::get<4>(tu));
    00253    boost::hash_combine(seed, std::get<5>(tu));
    00254    return seed;
    00255 }
    00256
    00257 template <typename T0, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
    00258 inline std::size_t hash_value(const std::tuple<T0, T1, T2, T3, T4, T5, T6> & tu)
    00259 {
    00260    std::size_t seed = 0;
    00261    boost::hash_combine(seed, std::get<0>(tu));
    00262    boost::hash_combine(seed, std::get<1>(tu));
    00263    boost::hash_combine(seed, std::get<2>(tu));
    00264    boost::hash_combine(seed, std::get<3>(tu));
    00265    boost::hash_combine(seed, std::get<4>(tu));
    00266    boost::hash_combine(seed, std::get<5>(tu));
    00267    boost::hash_combine(seed, std::get<6>(tu));
    00268    return seed;
    00269 }
    00270
    00271 template <typename T0, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7>
    00272 inline std::size_t hash_value(const std::tuple<T0, T1, T2, T3, T4, T5, T6, T7> & tu)
    00273 {
    00274    std::size_t seed = 0;
    00275    boost::hash_combine(seed, std::get<0>(tu));
    00276    boost::hash_combine(seed, std::get<1>(tu));
    00277    boost::hash_combine(seed, std::get<2>(tu));
    00278    boost::hash_combine(seed, std::get<3>(tu));
    00279    boost::hash_combine(seed, std::get<4>(tu));
    00280    boost::hash_combine(seed, std::get<5>(tu));
    00281    boost::hash_combine(seed, std::get<6>(tu));
    00282    boost::hash_combine(seed, std::get<7>(tu));
    00283    return seed;
    00284 }
    00285
    00286 template <typename T0, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8>
    00287 inline std::size_t hash_value(const std::tuple<T0, T1, T2, T3, T4, T5, T6, T7, T8> & tu)
    00288 {
    00289    std::size_t seed = 0;
    00290    boost::hash_combine(seed, std::get<0>(tu));
    00291    boost::hash_combine(seed, std::get<1>(tu));
    00292    boost::hash_combine(seed, std::get<2>(tu));
    00293    boost::hash_combine(seed, std::get<3>(tu));
    00294    boost::hash_combine(seed, std::get<4>(tu));
    00295    boost::hash_combine(seed, std::get<5>(tu));
    00296    boost::hash_combine(seed, std::get<6>(tu));
    00297    boost::hash_combine(seed, std::get<7>(tu));
    00298    boost::hash_combine(seed, std::get<8>(tu));
    00299    return seed;
    00300 }
    00301
    00302 template <typename T0, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9>
    00303 inline std::size_t hash_value(const std::tuple<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9> & tu)
    00304 {
    00305    std::size_t seed = 0;
    00306    boost::hash_combine(seed, std::get<0>(tu));
    00307    boost::hash_combine(seed, std::get<1>(tu));
    00308    boost::hash_combine(seed, std::get<2>(tu));
    00309    boost::hash_combine(seed, std::get<3>(tu));
    00310    boost::hash_combine(seed, std::get<4>(tu));
    00311    boost::hash_combine(seed, std::get<5>(tu));
    00312    boost::hash_combine(seed, std::get<6>(tu));
    00313    boost::hash_combine(seed, std::get<7>(tu));
    00314    boost::hash_combine(seed, std::get<8>(tu));
    00315    boost::hash_combine(seed, std::get<9>(tu));
    00316    return seed;
    00317 }
    00318
    00319 #endif // BOOST_NO_CXX11_HDR_TUPLE
    00320 #endif // _QX_CPP_11_TUPLE
    00321
    00322 #endif // _QX_HASH_VALUE_H_