![]() |
QxOrm
1.2.3
C++ Object Relational Mapping library
|
00001 /**************************************************************************** 00002 ** 00003 ** http://www.qxorm.com/ 00004 ** http://sourceforge.net/projects/qxorm/ 00005 ** Original file by Lionel Marty 00006 ** 00007 ** This file is part of the QxOrm library 00008 ** 00009 ** This software is provided 'as-is', without any express or implied 00010 ** warranty. In no event will the authors be held liable for any 00011 ** damages arising from the use of this software. 00012 ** 00013 ** GNU Lesser General Public License Usage 00014 ** This file must be used under the terms of the GNU Lesser 00015 ** General Public License version 2.1 as published by the Free Software 00016 ** Foundation and appearing in the file 'license.lgpl.txt' included in the 00017 ** packaging of this file. Please review the following information to 00018 ** ensure the GNU Lesser General Public License version 2.1 requirements 00019 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 00020 ** 00021 ** If you have questions regarding the use of this file, please contact : 00022 ** contact@qxorm.com 00023 ** 00024 ****************************************************************************/ 00025 00026 #ifndef _QX_VALIDATOR_X_H_ 00027 #define _QX_VALIDATOR_X_H_ 00028 00029 #ifdef _MSC_VER 00030 #pragma once 00031 #endif 00032 00040 #include <QxValidator/IxValidatorX.h> 00041 #include <QxValidator/QxValidator.h> 00042 00043 #include <QxRegister/QxClassX.h> 00044 00045 namespace qx { 00046 00054 template <class T> 00055 class QxValidatorX : public IxValidatorX 00056 { 00057 00058 public: 00059 00060 QxValidatorX() : IxValidatorX() { ; } 00061 virtual ~QxValidatorX() { ; } 00062 00063 template <class DataType> 00064 IxValidator * add_RecursiveValidator(const QString & sPropertyKey, const QString & sGroup = QString()) 00065 { 00066 IxValidator_ptr pValidator; 00067 pValidator.reset(new QxValidator_Recursive<DataType, T>()); 00068 pValidator->setGroup(sGroup); 00069 pValidator->setDataMember(getDataMember(sPropertyKey)); 00070 insertIntoGroup(pValidator, sGroup); 00071 return pValidator.get(); 00072 } 00073 00074 IxValidator * add_CustomValidator(typename QxValidator<T>::type_fct_custom_validator_member fct, const QString & sGroup = QString()) 00075 { return add_CustomValidator_Helper(new QxValidator<T>(), fct, "", sGroup); } 00076 00077 IxValidator * add_CustomValidator_QVariant(typename QxValidator<T>::type_fct_custom_validator_variant_validator fct, const QString & sPropertyKey, const QString & sGroup = QString()) 00078 { return add_CustomValidator_Helper(new QxValidator<T>(), fct, sPropertyKey, sGroup); } 00079 00080 template <class DataType> 00081 IxValidator * add_CustomValidator_DataType(typename QxValidator_WithDataType<DataType, T>::type_fct_custom_validator_data_type_validator fct, const QString & sPropertyKey, const QString & sGroup = QString()) 00082 { return add_CustomValidator_Helper(new QxValidator_WithDataType<DataType, T>(), fct, sPropertyKey, sGroup); } 00083 00084 private: 00085 00086 template <class Validator, class FunctionType> 00087 IxValidator * add_CustomValidator_Helper(Validator * validator, FunctionType fct, const QString & sPropertyKey, const QString & sGroup) 00088 { 00089 if (! validator) { qAssert(false); return NULL; } 00090 IxValidator_ptr pValidator; 00091 pValidator.reset(validator); 00092 validator->setGroup(sGroup); 00093 validator->setFunction(fct); 00094 validator->setDataMember(getDataMember(sPropertyKey)); 00095 insertIntoGroup(pValidator, sGroup); 00096 return pValidator.get(); 00097 } 00098 00099 }; 00100 00101 } // namespace qx 00102 00103 #endif // _QX_VALIDATOR_X_H_