QxOrm  1.4.9
C++ Object Relational Mapping library
QxInvalidValue.h
Go to the documentation of this file.
00001 /****************************************************************************
00002 **
00003 ** https://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_VALIDATOR_INVALID_VALUE_H_
00033 #define _QX_VALIDATOR_INVALID_VALUE_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/nvp.hpp>
00049 #endif // _QX_ENABLE_BOOST_SERIALIZATION
00050 
00051 #ifndef _QX_NO_JSON
00052 #include <QtCore/qjsonvalue.h>
00053 #endif // _QX_NO_JSON
00054 
00055 #include <QxSerialize/boost/QxSerialize_shared_ptr.h>
00056 
00057 #include <QxSerialize/Qt/QxSerialize_QString.h>
00058 #include <QxSerialize/Qt/QxSerialize_QVariant.h>
00059 #include <QxSerialize/Qt/QxSerialize_QHash.h>
00060 
00061 #include <QxConvert/QxConvert.h>
00062 
00063 #include <QxTraits/get_class_name.h>
00064 
00065 #include <QxCommon/QxPropertyBag.h>
00066 
00067 namespace qx {
00068 class IxValidator;
00069 class QxInvalidValue;
00070 } // namespace qx
00071 
00072 QX_DLL_EXPORT QDataStream & operator<< (QDataStream & stream, const qx::QxInvalidValue & t) QX_USED;
00073 QX_DLL_EXPORT QDataStream & operator>> (QDataStream & stream, qx::QxInvalidValue & t) QX_USED;
00074 
00075 #ifndef _QX_NO_JSON
00076 namespace qx {
00077 namespace cvt {
00078 namespace detail {
00079 template <> struct QxConvert_ToJson< qx::QxInvalidValue >;
00080 template <> struct QxConvert_FromJson< qx::QxInvalidValue >;
00081 QX_DLL_EXPORT QJsonValue QxConvert_ToJson_Helper(const qx::QxInvalidValue & t, const QString & format) QX_USED;
00082 QX_DLL_EXPORT qx_bool QxConvert_FromJson_Helper(const QJsonValue & j, qx::QxInvalidValue & t, const QString & format) QX_USED;
00083 } // namespace detail
00084 } // namespace cvt
00085 } // namespace qx
00086 #endif // _QX_NO_JSON
00087 
00088 namespace qx {
00089 
00097 class QX_DLL_EXPORT QxInvalidValue : public QxPropertyBag
00098 {
00099 
00100 #ifdef _QX_ENABLE_BOOST_SERIALIZATION
00101    friend class boost::serialization::access;
00102 #endif // _QX_ENABLE_BOOST_SERIALIZATION
00103 
00104    friend QX_DLL_EXPORT QDataStream & ::operator<< (QDataStream & stream, const qx::QxInvalidValue & t);
00105    friend QX_DLL_EXPORT QDataStream & ::operator>> (QDataStream & stream, qx::QxInvalidValue & t);
00106 
00107 #ifndef _QX_NO_JSON
00108    friend struct qx::cvt::detail::QxConvert_ToJson< qx::QxInvalidValue >;
00109    friend struct qx::cvt::detail::QxConvert_FromJson< qx::QxInvalidValue >;
00110    friend QX_DLL_EXPORT QJsonValue qx::cvt::detail::QxConvert_ToJson_Helper(const qx::QxInvalidValue & t, const QString & format);
00111    friend QX_DLL_EXPORT qx_bool qx::cvt::detail::QxConvert_FromJson_Helper(const QJsonValue & j, qx::QxInvalidValue & t, const QString & format);
00112 #endif // _QX_NO_JSON
00113 
00114 protected:
00115 
00116    QString m_sMessage;                    
00117    QString m_sPropertyName;               
00118    QString m_sPath;                       
00119    const IxValidator * m_pValidator;      
00120 
00121 public:
00122 
00123    QxInvalidValue();
00124    virtual ~QxInvalidValue();
00125 
00126    QString getMessage() const                   { return m_sMessage; }
00127    QString getPropertyName() const              { return m_sPropertyName; }
00128    QString getPath() const                      { return m_sPath; }
00129    QString getFullName() const;
00130    const IxValidator * getValidator() const;
00131 
00132    void setMessage(const QString & s)           { m_sMessage = s; }
00133    void setPropertyName(const QString & s)      { m_sPropertyName = s; }
00134    void setPath(const QString & s)              { m_sPath = s; }
00135    void setValidator(const IxValidator * p);
00136 
00137 private:
00138 
00139 #ifdef _QX_ENABLE_BOOST_SERIALIZATION
00140    template <class Archive>
00141    void serialize(Archive & ar, const unsigned int file_version)
00142    {
00143       Q_UNUSED(file_version);
00144       ar & boost::serialization::make_nvp("message", m_sMessage);
00145       ar & boost::serialization::make_nvp("property_name", m_sPropertyName);
00146       ar & boost::serialization::make_nvp("path", m_sPath);
00147       ar & boost::serialization::make_nvp("list_property_bag", this->m_lstPropertyBag);
00148    }
00149 #endif // _QX_ENABLE_BOOST_SERIALIZATION
00150 
00151 };
00152 
00153 } // namespace qx
00154 
00155 QX_REGISTER_CLASS_NAME(qx::QxInvalidValue)
00156 
00157 #endif // _QX_VALIDATOR_INVALID_VALUE_H_