QxOrm 1.4.9
C++ Object Relational Mapping library
Loading...
Searching...
No Matches
QxInvalidValue.h
Go to the documentation of this file.
1/****************************************************************************
2**
3** https://www.qxorm.com/
4** Copyright (C) 2013 Lionel Marty (contact@qxorm.com)
5**
6** This file is part of the QxOrm library
7**
8** This software is provided 'as-is', without any express or implied
9** warranty. In no event will the authors be held liable for any
10** damages arising from the use of this software
11**
12** Commercial Usage
13** Licensees holding valid commercial QxOrm licenses may use this file in
14** accordance with the commercial license agreement provided with the
15** Software or, alternatively, in accordance with the terms contained in
16** a written agreement between you and Lionel Marty
17**
18** GNU General Public License Usage
19** Alternatively, this file may be used under the terms of the GNU
20** General Public License version 3.0 as published by the Free Software
21** Foundation and appearing in the file 'license.gpl3.txt' included in the
22** packaging of this file. Please review the following information to
23** ensure the GNU General Public License version 3.0 requirements will be
24** met : http://www.gnu.org/copyleft/gpl.html
25**
26** If you are unsure which license is appropriate for your use, or
27** if you have questions regarding the use of this file, please contact :
28** contact@qxorm.com
29**
30****************************************************************************/
31
32#ifndef _QX_VALIDATOR_INVALID_VALUE_H_
33#define _QX_VALIDATOR_INVALID_VALUE_H_
34
35#ifdef _MSC_VER
36#pragma once
37#endif
38
46#ifdef _QX_ENABLE_BOOST_SERIALIZATION
47#include <boost/serialization/serialization.hpp>
48#include <boost/serialization/nvp.hpp>
49#endif // _QX_ENABLE_BOOST_SERIALIZATION
50
51#ifndef _QX_NO_JSON
52#include <QtCore/qjsonvalue.h>
53#endif // _QX_NO_JSON
54
56
60
61#include <QxConvert/QxConvert.h>
62
64
66
67namespace qx {
68class IxValidator;
69class QxInvalidValue;
70} // namespace qx
71
72QX_DLL_EXPORT QDataStream & operator<< (QDataStream & stream, const qx::QxInvalidValue & t) QX_USED;
73QX_DLL_EXPORT QDataStream & operator>> (QDataStream & stream, qx::QxInvalidValue & t) QX_USED;
74
75#ifndef _QX_NO_JSON
76namespace qx {
77namespace cvt {
78namespace detail {
79template <> struct QxConvert_ToJson< qx::QxInvalidValue >;
80template <> struct QxConvert_FromJson< qx::QxInvalidValue >;
81QX_DLL_EXPORT QJsonValue QxConvert_ToJson_Helper(const qx::QxInvalidValue & t, const QString & format) QX_USED;
82QX_DLL_EXPORT qx_bool QxConvert_FromJson_Helper(const QJsonValue & j, qx::QxInvalidValue & t, const QString & format) QX_USED;
83} // namespace detail
84} // namespace cvt
85} // namespace qx
86#endif // _QX_NO_JSON
87
88namespace qx {
89
98{
99
100#ifdef _QX_ENABLE_BOOST_SERIALIZATION
101 friend class boost::serialization::access;
102#endif // _QX_ENABLE_BOOST_SERIALIZATION
103
104 friend QX_DLL_EXPORT QDataStream & ::operator<< (QDataStream & stream, const qx::QxInvalidValue & t);
105 friend QX_DLL_EXPORT QDataStream & ::operator>> (QDataStream & stream, qx::QxInvalidValue & t);
106
107#ifndef _QX_NO_JSON
109 friend struct qx::cvt::detail::QxConvert_FromJson< qx::QxInvalidValue >;
110 friend QX_DLL_EXPORT QJsonValue qx::cvt::detail::QxConvert_ToJson_Helper(const qx::QxInvalidValue & t, const QString & format);
111 friend QX_DLL_EXPORT qx_bool qx::cvt::detail::QxConvert_FromJson_Helper(const QJsonValue & j, qx::QxInvalidValue & t, const QString & format);
112#endif // _QX_NO_JSON
113
114protected:
115
116 QString m_sMessage;
117 QString m_sPropertyName;
118 QString m_sPath;
119 const IxValidator * m_pValidator;
120
121public:
122
124 virtual ~QxInvalidValue();
125
126 QString getMessage() const { return m_sMessage; }
127 QString getPropertyName() const { return m_sPropertyName; }
128 QString getPath() const { return m_sPath; }
129 QString getFullName() const;
130 const IxValidator * getValidator() const;
131
132 void setMessage(const QString & s) { m_sMessage = s; }
133 void setPropertyName(const QString & s) { m_sPropertyName = s; }
134 void setPath(const QString & s) { m_sPath = s; }
135 void setValidator(const IxValidator * p);
136
137private:
138
139#ifdef _QX_ENABLE_BOOST_SERIALIZATION
140 template <class Archive>
141 void serialize(Archive & ar, const unsigned int file_version)
142 {
143 Q_UNUSED(file_version);
144 ar & boost::serialization::make_nvp("message", m_sMessage);
145 ar & boost::serialization::make_nvp("property_name", m_sPropertyName);
146 ar & boost::serialization::make_nvp("path", m_sPath);
147 ar & boost::serialization::make_nvp("list_property_bag", this->m_lstPropertyBag);
148 }
149#endif // _QX_ENABLE_BOOST_SERIALIZATION
150
151};
152
153} // namespace qx
154
156
157#endif // _QX_VALIDATOR_INVALID_VALUE_H_
qx::cvt : namespace to provide global functions to convert any kind of objects to/from QString and QV...
QX_DLL_EXPORT QDataStream & operator>>(QDataStream &stream, qx::QxInvalidValue &t) QX_USED
QX_DLL_EXPORT QDataStream & operator<<(QDataStream &stream, const qx::QxInvalidValue &t) QX_USED
#define QX_USED
Definition QxMacro.h:244
#define QX_DLL_EXPORT
Definition QxMacro.h:182
Used by introspection engine (IxClass, IxDataMember, IxFunction, etc.) to add meta-data (property bag...
qx::IxValidator : common interface for validator engine
Definition IxValidator.h:61
qx_bool : boolean type with code and description message when an error occured
Definition QxBool.h:71
qx::QxInvalidValue : invalid value when a property fails to pass a constraint
void serialize(Archive &ar, const unsigned int file_version)
void setPath(const QString &s)
QString getFullName() const
QString getPropertyName() const
void setValidator(const IxValidator *p)
const IxValidator * getValidator() const
QString getPath() const
void setPropertyName(const QString &s)
void setMessage(const QString &s)
qx::QxPropertyBag : used by introspection engine (IxClass, IxDataMember, IxFunction,...
qx::trait::get_class_name<T>::get() : return class name of type T under const char * format,...
#define QX_REGISTER_CLASS_NAME(className)
QX_DLL_EXPORT QJsonValue QxConvert_ToJson_Helper(const qx::dao::detail::IxSqlElement &t, const QString &format) QX_USED
QX_DLL_EXPORT qx_bool QxConvert_FromJson_Helper(const QJsonValue &j, qx::dao::detail::IxSqlElement &t, const QString &format) QX_USED
Root namespace for all QxOrm library features.