| QxOrm 1.4.1 C++ Object Relational Mapping library

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

- File List
- File Members

IxSqlElement.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 _IX_SQL_ELEMENT_H_
    00033 #define _IX_SQL_ELEMENT_H_
    00034
    00035 #ifdef _MSC_VER
    00036 #pragma once
    00037 #endif
    00038
    00046 #ifdef _QX_ENABLE_BOOST_SERIALIZATION
    00047 #include <boost/serialization/serialization.hpp>
    00048 #include <boost/serialization/split_free.hpp>
    00049 #include <boost/serialization/version.hpp>
    00050 #include <boost/serialization/nvp.hpp>
    00051 #endif // _QX_ENABLE_BOOST_SERIALIZATION
    00052
    00053 #include <QtCore/qdatastream.h>
    00054
    00055 #include <QtSql/qsqlquery.h>
    00056
    00057 #include <QxDao/QxSqlGenerator/IxSqlGenerator.h>
    00058
    00059 #include <QxSerialize/Qt/QxSerialize_QList.h>
    00060 #include <QxSerialize/Qt/QxSerialize_QStringList.h>
    00061 #include <QxSerialize/Qt/QxSerialize_QVariant.h>
    00062
    00063 namespace qx {
    00064 namespace dao {
    00065 namespace detail {
    00066 class IxSqlElement;
    00067 } // namespace detail
    00068 } // namespace dao
    00069 } // namespace qx
    00070
    00071 QX_DLL_EXPORT QDataStream & operator<< (QDataStream & stream, const qx::dao::detail::IxSqlElement & t) BOOST_USED;
    00072 QX_DLL_EXPORT QDataStream & operator>> (QDataStream & stream, qx::dao::detail::IxSqlElement & t) BOOST_USED;
    00073
    00074 namespace qx {
    00075 namespace dao {
    00076 namespace detail {
    00077
    00082 class QX_DLL_EXPORT IxSqlElement
    00083 {
    00084
    00085    friend QDataStream & ::operator<< (QDataStream & stream, const qx::dao::detail::IxSqlElement & t);
    00086    friend QDataStream & ::operator>> (QDataStream & stream, qx::dao::detail::IxSqlElement & t);
    00087
    00088 public:
    00089
    00090    enum type_class { _no_type, _sql_compare, _sql_element_temp, _sql_expression, _sql_free_text,
    00091                      _sql_in, _sql_is_between, _sql_is_null, _sql_limit, _sql_sort };
    00092
    00093 protected:
    00094
    00095    int               m_iIndex;
    00096    QStringList       m_lstColumns;
    00097    QStringList       m_lstKeys;
    00098    QList<QVariant>   m_lstValues;
    00099    IxSqlGenerator *  m_pSqlGenerator;
    00100
    00101 public:
    00102
    00103    IxSqlElement(int index);
    00104    virtual ~IxSqlElement();
    00105
    00106    void setColumn(const QString & column);
    00107    void setColumns(const QStringList & columns);
    00108    void setValue(const QVariant & val);
    00109    void setValues(const QVariantList & values);
    00110
    00111    virtual IxSqlElement::type_class getTypeClass() const = 0;
    00112
    00113    virtual QString toString() const = 0;
    00114    virtual void resolve(QSqlQuery & query) const = 0;
    00115    virtual void postProcess(QString & sql) const = 0;
    00116
    00117    virtual void clone(IxSqlElement * other);
    00118
    00119 #ifdef _QX_ENABLE_BOOST_SERIALIZATION
    00120    template <class Archive>
    00121    void qxSave(Archive & ar) const
    00122    {
    00123       QString sExtraSettings = getExtraSettings();
    00124       ar << boost::serialization::make_nvp("index", m_iIndex);
    00125       ar << boost::serialization::make_nvp("list_columns", m_lstColumns);
    00126       ar << boost::serialization::make_nvp("list_keys", m_lstKeys);
    00127       ar << boost::serialization::make_nvp("list_values", m_lstValues);
    00128       ar << boost::serialization::make_nvp("extra_settings", sExtraSettings);
    00129    }
    00130 #endif // _QX_ENABLE_BOOST_SERIALIZATION
    00131
    00132 #ifdef _QX_ENABLE_BOOST_SERIALIZATION
    00133    template <class Archive>
    00134    void qxLoad(Archive & ar)
    00135    {
    00136       QString sExtraSettings;
    00137       ar >> boost::serialization::make_nvp("index", m_iIndex);
    00138       ar >> boost::serialization::make_nvp("list_columns", m_lstColumns);
    00139       ar >> boost::serialization::make_nvp("list_keys", m_lstKeys);
    00140       ar >> boost::serialization::make_nvp("list_values", m_lstValues);
    00141       ar >> boost::serialization::make_nvp("extra_settings", sExtraSettings);
    00142       setExtraSettings(sExtraSettings);
    00143    }
    00144 #endif // _QX_ENABLE_BOOST_SERIALIZATION
    00145
    00146 protected:
    00147
    00148    void updateKeys();
    00149
    00150    virtual QString getExtraSettings() const = 0;
    00151    virtual void setExtraSettings(const QString & s) = 0;
    00152
    00153 };
    00154
    00155 typedef qx_shared_ptr<IxSqlElement> IxSqlElement_ptr;
    00156
    00157 } // namespace detail
    00158 } // namespace dao
    00159 } // namespace qx
    00160
    00161 #endif // _IX_SQL_ELEMENT_H_