QxOrm  1.4.5
C++ Object Relational Mapping library
QxInvalidValueX.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_X_H_
00033 #define _QX_VALIDATOR_INVALID_VALUE_X_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/Qt/QxSerialize_QString.h>
00056 #include <QxSerialize/Qt/QxSerialize_QList.h>
00057 
00058 #include <QxValidator/QxInvalidValue.h>
00059 
00060 #include <QxConvert/QxConvert.h>
00061 
00062 #include <QxTraits/get_class_name.h>
00063 
00064 namespace qx {
00065 class QxInvalidValueX;
00066 } // namespace qx
00067 
00068 QX_DLL_EXPORT QDataStream & operator<< (QDataStream & stream, const qx::QxInvalidValueX & t) QX_USED;
00069 QX_DLL_EXPORT QDataStream & operator>> (QDataStream & stream, qx::QxInvalidValueX & t) QX_USED;
00070 
00071 #ifndef _QX_NO_JSON
00072 namespace qx {
00073 namespace cvt {
00074 namespace detail {
00075 template <> struct QxConvert_ToJson< qx::QxInvalidValueX >;
00076 template <> struct QxConvert_FromJson< qx::QxInvalidValueX >;
00077 QX_DLL_EXPORT QJsonValue QxConvert_ToJson_Helper(const qx::QxInvalidValueX & t, const QString & format) QX_USED;
00078 QX_DLL_EXPORT qx_bool QxConvert_FromJson_Helper(const QJsonValue & j, qx::QxInvalidValueX & t, const QString & format) QX_USED;
00079 } // namespace detail
00080 } // namespace cvt
00081 } // namespace qx
00082 #endif // _QX_NO_JSON
00083 
00084 namespace qx {
00085 
00093 class QX_DLL_EXPORT QxInvalidValueX
00094 {
00095 
00096 #ifdef _QX_ENABLE_BOOST_SERIALIZATION
00097    friend class boost::serialization::access;
00098 #endif // _QX_ENABLE_BOOST_SERIALIZATION
00099 
00100    friend QX_DLL_EXPORT QDataStream & ::operator<< (QDataStream & stream, const qx::QxInvalidValueX & t);
00101    friend QX_DLL_EXPORT QDataStream & ::operator>> (QDataStream & stream, qx::QxInvalidValueX & t);
00102 
00103 #ifndef _QX_NO_JSON
00104    friend struct qx::cvt::detail::QxConvert_ToJson< qx::QxInvalidValueX >;
00105    friend struct qx::cvt::detail::QxConvert_FromJson< qx::QxInvalidValueX >;
00106    friend QX_DLL_EXPORT QJsonValue qx::cvt::detail::QxConvert_ToJson_Helper(const qx::QxInvalidValueX & t, const QString & format);
00107    friend QX_DLL_EXPORT qx_bool qx::cvt::detail::QxConvert_FromJson_Helper(const QJsonValue & j, qx::QxInvalidValueX & t, const QString & format);
00108 #endif // _QX_NO_JSON
00109 
00110 protected:
00111 
00112    QList<QxInvalidValue> m_lstInvalidValues;    
00113    QString m_sCurrentPath;                      
00114 
00115 public:
00116 
00117    QxInvalidValueX();
00118    virtual ~QxInvalidValueX();
00119 
00120    QString getCurrentPath() const;
00121    void setCurrentPath(const QString & s);
00122 
00123    long count() const;
00124    QxInvalidValue at(long l) const;
00125    void insert(const IxValidator * pValidator);
00126    void insert(const QString & sMessage);
00127    void insert(const QxInvalidValue & invalidValue);
00128    void insert(const QxInvalidValueX & other);
00129 
00130    QString text() const;
00131    void dump() const;
00132 
00133    inline operator bool() const
00134    { return (m_lstInvalidValues.count() == 0); }
00135 
00136 private:
00137 
00138 #ifdef _QX_ENABLE_BOOST_SERIALIZATION
00139    template <class Archive>
00140    void serialize(Archive & ar, const unsigned int file_version)
00141    {
00142       Q_UNUSED(file_version);
00143       ar & boost::serialization::make_nvp("list_invalid_values", m_lstInvalidValues);
00144       ar & boost::serialization::make_nvp("current_path", m_sCurrentPath);
00145    }
00146 #endif // _QX_ENABLE_BOOST_SERIALIZATION
00147 
00148 };
00149 
00150 } // namespace qx
00151 
00152 QX_REGISTER_CLASS_NAME(qx::QxInvalidValueX)
00153 
00154 #endif // _QX_VALIDATOR_INVALID_VALUE_X_H_