QxOrm
1.5.0
C++ Object Relational Mapping library
|
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 _IX_VALIDATOR_X_H_ 00033 #define _IX_VALIDATOR_X_H_ 00034 00035 #ifdef _MSC_VER 00036 #pragma once 00037 #endif 00038 00046 #include <QxCollection/QxCollection.h> 00047 00048 #include <QxValidator/IxValidator.h> 00049 00050 namespace qx { 00051 00052 class IxClass; 00053 class IxDataMember; 00054 class QxInvalidValueX; 00055 00063 class QX_DLL_EXPORT IxValidatorX 00064 { 00065 00066 friend class IxClass; 00067 00068 protected: 00069 00070 typedef QList<IxValidator_ptr> type_lst_validator; 00071 typedef std::shared_ptr<type_lst_validator> type_lst_validator_ptr; 00072 typedef QxCollection<QString, type_lst_validator_ptr> type_lst_validator_ptr_by_group; 00073 00074 type_lst_validator_ptr_by_group m_lstValidatorByGroup; 00075 IxClass * m_pClass; 00076 00077 public: 00078 00079 IxValidatorX(); 00080 virtual ~IxValidatorX() = 0; 00081 00082 QxInvalidValueX validate(void * pOwner, const QString & sGroup = QString()) const; 00083 00084 IxValidator * add_NotNull(const QString & sPropertyKey, const QString & sMessage = QString(), const QString & sGroup = QString()); 00085 IxValidator * add_NotEmpty(const QString & sPropertyKey, const QString & sMessage = QString(), const QString & sGroup = QString()); 00086 IxValidator * add_MinValue(const QString & sPropertyKey, long lMinValue, const QString & sMessage = QString(), const QString & sGroup = QString()); 00087 IxValidator * add_MaxValue(const QString & sPropertyKey, long lMaxValue, const QString & sMessage = QString(), const QString & sGroup = QString()); 00088 IxValidator * add_Range(const QString & sPropertyKey, long lMinValue, long lMaxValue, const QString & sMessage = QString(), const QString & sGroup = QString()); 00089 IxValidator * add_MinDecimal(const QString & sPropertyKey, double dMinValue, const QString & sMessage = QString(), const QString & sGroup = QString()); 00090 IxValidator * add_MaxDecimal(const QString & sPropertyKey, double dMaxValue, const QString & sMessage = QString(), const QString & sGroup = QString()); 00091 IxValidator * add_RangeDecimal(const QString & sPropertyKey, double dMinValue, double dMaxValue, const QString & sMessage = QString(), const QString & sGroup = QString()); 00092 IxValidator * add_MinLength(const QString & sPropertyKey, long lMinLength, const QString & sMessage = QString(), const QString & sGroup = QString()); 00093 IxValidator * add_MaxLength(const QString & sPropertyKey, long lMaxLength, const QString & sMessage = QString(), const QString & sGroup = QString()); 00094 IxValidator * add_Size(const QString & sPropertyKey, long lMinLength, long lMaxLength, const QString & sMessage = QString(), const QString & sGroup = QString()); 00095 IxValidator * add_DatePast(const QString & sPropertyKey, const QString & sMessage = QString(), const QString & sGroup = QString()); 00096 IxValidator * add_DateFuture(const QString & sPropertyKey, const QString & sMessage = QString(), const QString & sGroup = QString()); 00097 IxValidator * add_RegExp(const QString & sPropertyKey, const QString & sPattern, const QString & sMessage = QString(), const QString & sGroup = QString()); 00098 IxValidator * add_EMail(const QString & sPropertyKey, const QString & sMessage = QString(), const QString & sGroup = QString()); 00099 00100 QStringList getAllGroup() const; 00101 QList<IxValidator_ptr> getAllValidatorByGroup(const QString & group) const; 00102 00103 protected: 00104 00105 void setClass(IxClass * p); 00106 void insertIntoGroup(IxValidator_ptr pValidator, const QString & sGroup); 00107 IxValidator_ptr createValidator(IxValidator::validator_type type, const QString & sPropertyKey, const QString & sMessage, const QString & sGroup); 00108 IxDataMember * getDataMember(const QString & sPropertyKey) const; 00109 00110 }; 00111 00112 typedef std::shared_ptr<IxValidatorX> IxValidatorX_ptr; 00113 00114 } // namespace qx 00115 00116 #endif // _IX_VALIDATOR_X_H_