| QxOrm 1.1.8 C++ Object Relational Mapping library

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

- File List
- File Members

is_valid_primary_key.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_IS_VALID_PRIMARY_KEY_H_
    00027 #define _QX_IS_VALID_PRIMARY_KEY_H_
    00028
    00029 #ifdef _MSC_VER
    00030 #pragma once
    00031 #endif
    00032
    00040 namespace qx {
    00041 namespace trait {
    00042 namespace detail {
    00043
    00048 template <typename T>
    00049 struct is_valid_primary_key
    00050 { static inline bool get(const T & t) { Q_UNUSED(t); qAssert(false); return false; } };
    00051
    00052 template <>
    00053 struct is_valid_primary_key<short>
    00054 { static inline bool get(const short & t) { return (t != 0); } };
    00055
    00056 template <>
    00057 struct is_valid_primary_key<int>
    00058 { static inline bool get(const int & t) { return (t != 0); } };
    00059
    00060 template <>
    00061 struct is_valid_primary_key<long>
    00062 { static inline bool get(const long & t) { return (t != 0); } };
    00063
    00064 template <>
    00065 struct is_valid_primary_key<long long>
    00066 { static inline bool get(const long long & t) { return (t != 0); } };
    00067
    00068 template <>
    00069 struct is_valid_primary_key<QString>
    00070 { static inline bool get(const QString & t) { return (! t.isEmpty()); } };
    00071
    00072 template <>
    00073 struct is_valid_primary_key<std::string>
    00074 { static inline bool get(const std::string & t) { return (! t.empty()); } };
    00075
    00076 template <>
    00077 struct is_valid_primary_key<std::wstring>
    00078 { static inline bool get(const std::wstring & t) { return (! t.empty()); } };
    00079
    00080 template <>
    00081 struct is_valid_primary_key<QVariant>
    00082 { static inline bool get(const QVariant & t) { return ((t.type() == QVariant::String) ? qx::trait::detail::is_valid_primary_key<QString>::get(t.toString()) : (! t.isNull() && (t.toLongLong() != 0))); } };
    00083
    00084 } // namespace detail
    00085
    00086 template <typename T>
    00087 inline bool is_valid_primary_key(const T & t)
    00088 { return qx::trait::detail::is_valid_primary_key<T>::get(t); }
    00089
    00090 } // namespace trait
    00091 } // namespace qx
    00092
    00093 #endif // _QX_IS_VALID_PRIMARY_KEY_H_

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines