first commit

This commit is contained in:
bing
2026-04-03 11:32:07 +08:00
commit 003be19522
1142 changed files with 185854 additions and 0 deletions

View File

@@ -0,0 +1,53 @@
cmake_minimum_required(VERSION 3.1)
project(dll1 LANGUAGES CXX)
include(../../../QxOrm.cmake)
set(CMAKE_AUTOMOC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_DEBUG_POSTFIX "d")
set(HEADERS
./include/precompiled.h
./include/export.h
./include/CPerson.h
./include/TestQtProperty.h
./include/QxPersistable.h
)
set(SRCS
./qx/CPerson.qx.cpp
./src/CPerson.cpp
./src/TestQtProperty.cpp
./src/QxPersistable.cpp
./src/main.cpp
)
add_library(dll1 SHARED ${SRCS} ${HEADERS})
target_compile_definitions(dll1 PRIVATE -D_QX_BUILDING_DLL1)
if(COMMAND target_precompile_headers)
target_precompile_headers(dll1 PRIVATE ./include/precompiled.h)
endif() # (COMMAND target_precompile_headers)
target_link_libraries(dll1 ${QX_LIBRARIES} QxOrm)
set_target_properties(dll1 PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../../_bin"
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../../_bin"
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../../_bin"
ARCHIVE_OUTPUT_DIRECTORY_DEBUG "${CMAKE_CURRENT_SOURCE_DIR}/../../_bin"
LIBRARY_OUTPUT_DIRECTORY_DEBUG "${CMAKE_CURRENT_SOURCE_DIR}/../../_bin"
RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_CURRENT_SOURCE_DIR}/../../_bin"
ARCHIVE_OUTPUT_DIRECTORY_RELEASE "${CMAKE_CURRENT_SOURCE_DIR}/../../_bin"
LIBRARY_OUTPUT_DIRECTORY_RELEASE "${CMAKE_CURRENT_SOURCE_DIR}/../../_bin"
RUNTIME_OUTPUT_DIRECTORY_RELEASE "${CMAKE_CURRENT_SOURCE_DIR}/../../_bin"
ARCHIVE_OUTPUT_DIRECTORY_MINSIZEREL "${CMAKE_CURRENT_SOURCE_DIR}/../../_bin"
LIBRARY_OUTPUT_DIRECTORY_MINSIZEREL "${CMAKE_CURRENT_SOURCE_DIR}/../../_bin"
RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL "${CMAKE_CURRENT_SOURCE_DIR}/../../_bin"
ARCHIVE_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_CURRENT_SOURCE_DIR}/../../_bin"
LIBRARY_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_CURRENT_SOURCE_DIR}/../../_bin"
RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_CURRENT_SOURCE_DIR}/../../_bin"
)

View File

@@ -0,0 +1,7 @@
# git does not allow empty directories.
# Yet, we need to add this empty directory on git.
# To achieve that, we created this .gitignore file, so that the directory will not be empty thus enabling us to commit it.
# Since we want all generated files/folders in this directory to be ignored by git, we add a rule for this.
*
# And then add an exception for this specifc file (so that we can commit it).
!.gitignore

View File

@@ -0,0 +1,38 @@
include(../../../QxOrm.pri)
TEMPLATE = lib
CONFIG += dll
DEFINES += _QX_BUILDING_DLL1
INCLUDEPATH += ../../../../QxOrm/include/
DESTDIR = ../../../../QxOrm/test/_bin/
!contains(DEFINES, _QX_NO_PRECOMPILED_HEADER) {
PRECOMPILED_HEADER = ./include/precompiled.h
} # !contains(DEFINES, _QX_NO_PRECOMPILED_HEADER)
CONFIG(debug, debug|release) {
TARGET = dll1d
} else {
TARGET = dll1
} # CONFIG(debug, debug|release)
LIBS += -L"../../../../QxOrm/lib"
CONFIG(debug, debug|release) {
LIBS += -l"QxOrmd"
} else {
LIBS += -l"QxOrm"
} # CONFIG(debug, debug|release)
HEADERS += ./include/precompiled.h
HEADERS += ./include/export.h
HEADERS += ./include/CPerson.h
HEADERS += ./include/TestQtProperty.h
HEADERS += ./include/QxPersistable.h
SOURCES += ./qx/CPerson.qx.cpp
SOURCES += ./src/CPerson.cpp
SOURCES += ./src/TestQtProperty.cpp
SOURCES += ./src/QxPersistable.cpp
SOURCES += ./src/main.cpp

View File

@@ -0,0 +1,66 @@
#ifndef _QX_CLASS_PERSON_H_
#define _QX_CLASS_PERSON_H_
#ifdef _MSC_VER
#pragma once
#endif
#ifdef _QX_NO_PRECOMPILED_HEADER
#ifndef Q_MOC_RUN
#include "../include/precompiled.h" // Need to include precompiled header for the generated moc file
#endif // Q_MOC_RUN
#endif // _QX_NO_PRECOMPILED_HEADER
namespace qx {
namespace test {
class QX_DLL1_EXPORT CPerson : public QObject
{
Q_OBJECT
QX_REGISTER_FRIEND_CLASS(qx::test::CPerson)
public:
enum sex { male, female, unknown };
protected:
long m_lPersonId;
QString m_sFirstName;
QString m_sLastName;
double m_dDouble;
sex m_eSex;
public:
CPerson() : QObject(), m_lPersonId(0), m_sFirstName("toto"), m_dDouble(4.5678), m_eSex(unknown) { ; }
CPerson(long lId) : QObject(), m_lPersonId(lId), m_sFirstName("toto"), m_dDouble(4.5678), m_eSex(unknown) { ; }
virtual ~CPerson() { ; }
long getPersonId() const { return m_lPersonId; }
QString getFirstName() const { return m_sFirstName; }
QString getLastName() const { return m_sLastName; }
double getDouble() const { return m_dDouble; }
sex getSex() const { return m_eSex; }
void setPersonId(long l) { m_lPersonId = l; }
void setFirstName(const QString & s) { m_sFirstName = s; }
void setLastName(const QString & s) { m_sLastName = s; }
void setDouble(double d) { m_dDouble = d; }
void setSex(sex e) { m_eSex = e; }
static int testStaticFct(const QString & s);
private:
void isValid(qx::QxInvalidValueX & invalidValues);
};
} // namespace test
} // namespace qx
QX_REGISTER_COMPLEX_CLASS_NAME_HPP_QX_DLL1(qx::test::CPerson, QObject, 0, qx_test_CPerson)
#endif // _QX_CLASS_PERSON_H_

View File

@@ -0,0 +1,225 @@
/****************************************************************************
**
** https://www.qxorm.com/
** Copyright (C) 2013 XDL Team (ic-east.com)
**
** This file is part of the QxOrm library
**
** This software is provided 'as-is', without any express or implied
** warranty. In no event will the authors be held liable for any
** damages arising from the use of this software
**
** Commercial Usage
** Licensees holding valid commercial QxOrm licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and XDL Team
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file 'license.gpl3.txt' included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met : http://www.gnu.org/copyleft/gpl.html
**
** If you are unsure which license is appropriate for your use, or
** if you have questions regarding the use of this file, please contact :
** ic-east.com
**
****************************************************************************/
#ifndef _QX_PERSISTABLE_H_
#define _QX_PERSISTABLE_H_
#ifdef _MSC_VER
#pragma once
#endif
#ifdef _QX_NO_PRECOMPILED_HEADER
#ifndef Q_MOC_RUN
#include "../include/precompiled.h" // Need to include precompiled header for the generated moc file
#endif // Q_MOC_RUN
#endif // _QX_NO_PRECOMPILED_HEADER
namespace qx
{
class QxPersistable;
namespace dao
{
namespace detail
{
template <>
struct QxDao_Trigger<qx::QxPersistable>;
} // namespace detail
} // namespace dao
/*!
* \brief qx::QxPersistable : super base class for persistent classes with many features and methods to override (be careful, don't forget to use QX_PERSISTABLE_HPP() and QX_PERSISTABLE_CPP() macros for each derived class)
*/
class QX_DLL1_EXPORT QxPersistable : public QObject, public qx::IxPersistable
{
Q_OBJECT
QX_REGISTER_FRIEND_CLASS(qx::QxPersistable)
QX_PERSISTABLE_HPP(qx::QxPersistable)
Q_PROPERTY(long qxId READ qxGetId WRITE qxSetId)
Q_PROPERTY(QDateTime qxDateCreation READ qxGetDateCreation WRITE qxSetDateCreation)
Q_PROPERTY(QDateTime qxDateModification READ qxGetDateModification WRITE qxSetDateModification)
friend struct qx::dao::detail::QxDao_Trigger<qx::QxPersistable>;
protected:
long m_qxId; //!< Id of current instance stored into database
qx::QxDateTimeNeutral m_qxDateCreation; //!< Creation date-time automatically calculated before INSERT query
qx::QxDateTimeNeutral m_qxDateModification; //!< Modification date-time automatically calculated before INSERT and UPDATE queries
public:
QxPersistable();
virtual ~QxPersistable();
long qxGetId() const;
QDateTime qxGetDateCreation() const;
QDateTime qxGetDateModification() const;
void qxSetId(long l);
void qxSetDateCreation(const QDateTime &dt);
void qxSetDateModification(const QDateTime &dt);
protected:
// -- List of useful protected methods to override into derived class -- //
virtual void qxIsValid(qx::QxInvalidValueX &invalidValues);
virtual void qxOnBeforeInsert(qx::dao::detail::IxDao_Helper *dao);
virtual void qxOnBeforeUpdate(qx::dao::detail::IxDao_Helper *dao);
virtual void qxOnBeforeDelete(qx::dao::detail::IxDao_Helper *dao);
virtual void qxOnBeforeFetch(qx::dao::detail::IxDao_Helper *dao);
virtual void qxOnAfterInsert(qx::dao::detail::IxDao_Helper *dao);
virtual void qxOnAfterUpdate(qx::dao::detail::IxDao_Helper *dao);
virtual void qxOnAfterDelete(qx::dao::detail::IxDao_Helper *dao);
virtual void qxOnAfterFetch(qx::dao::detail::IxDao_Helper *dao);
private:
void qxIsValidInternal(qx::QxInvalidValueX &invalidValues);
Q_SIGNALS:
void qxOnBeforeInsert(qx::QxPersistable *p);
void qxOnBeforeUpdate(qx::QxPersistable *p);
void qxOnBeforeDelete(qx::QxPersistable *p);
void qxOnBeforeFetch(qx::QxPersistable *p);
void qxOnAfterInsert(qx::QxPersistable *p);
void qxOnAfterUpdate(qx::QxPersistable *p);
void qxOnAfterDelete(qx::QxPersistable *p);
void qxOnAfterFetch(qx::QxPersistable *p);
public:
// -- List of useful public methods available from 'qx::IxPersistable' interface (using QX_PERSISTABLE_HPP() and QX_PERSISTABLE_CPP() macros) -- //
/*
virtual long qxCount(const qx::QxSqlQuery & query = qx::QxSqlQuery(), QSqlDatabase * pDatabase = NULL, const QStringList & relation = QStringList());
virtual QSqlError qxFetchById(const QVariant & id = QVariant(), const QStringList & columns = QStringList(), const QStringList & relation = QStringList(), QSqlDatabase * pDatabase = NULL);
virtual QSqlError qxFetchAll(qx::IxCollection & list, const QStringList & columns = QStringList(), const QStringList & relation = QStringList(), QSqlDatabase * pDatabase = NULL);
virtual QSqlError qxFetchByQuery(const qx::QxSqlQuery & query, qx::IxCollection & list, const QStringList & columns = QStringList(), const QStringList & relation = QStringList(), QSqlDatabase * pDatabase = NULL);
virtual QSqlError qxInsert(const QStringList & relation = QStringList(), QSqlDatabase * pDatabase = NULL, bool bUseExecBatch = false);
virtual QSqlError qxUpdate(const qx::QxSqlQuery & query = qx::QxSqlQuery(), const QStringList & columns = QStringList(), const QStringList & relation = QStringList(), QSqlDatabase * pDatabase = NULL, bool bUseExecBatch = false);
virtual QSqlError qxSave(const QStringList & relation = QStringList(), QSqlDatabase * pDatabase = NULL);
virtual QSqlError qxDeleteById(const QVariant & id = QVariant(), QSqlDatabase * pDatabase = NULL, bool bUseExecBatch = false);
virtual QSqlError qxDeleteAll(QSqlDatabase * pDatabase = NULL);
virtual QSqlError qxDeleteByQuery(const qx::QxSqlQuery & query, QSqlDatabase * pDatabase = NULL);
virtual QSqlError qxDestroyById(const QVariant & id = QVariant(), QSqlDatabase * pDatabase = NULL, bool bUseExecBatch = false);
virtual QSqlError qxDestroyAll(QSqlDatabase * pDatabase = NULL);
virtual QSqlError qxDestroyByQuery(const qx::QxSqlQuery & query, QSqlDatabase * pDatabase = NULL);
virtual qx_bool qxExist(const QVariant & id = QVariant(), QSqlDatabase * pDatabase = NULL);
virtual qx::QxInvalidValueX qxValidate(const QStringList & groups = QStringList());
virtual qx::IxPersistableCollection_ptr qxNewPersistableCollection(bool bAsList = false) const;
virtual qx::IxClass * qxClass() const;
*/
};
typedef std::shared_ptr<qx::QxPersistable> QxPersistable_ptr;
} // namespace qx
QX_REGISTER_COMPLEX_CLASS_NAME_HPP_QX_DLL1(qx::QxPersistable, QObject, 0, qx_QxPersistable)
namespace qx
{
namespace dao
{
namespace detail
{
template <>
struct QxDao_Trigger<qx::QxPersistable>
{
static inline void onBeforeInsert(qx::QxPersistable *t, qx::dao::detail::IxDao_Helper *dao)
{
if (t)
{
t->qxOnBeforeInsert(dao);
}
}
static inline void onBeforeUpdate(qx::QxPersistable *t, qx::dao::detail::IxDao_Helper *dao)
{
if (t)
{
t->qxOnBeforeUpdate(dao);
}
}
static inline void onBeforeDelete(qx::QxPersistable *t, qx::dao::detail::IxDao_Helper *dao)
{
if (t)
{
t->qxOnBeforeDelete(dao);
}
}
static inline void onBeforeFetch(qx::QxPersistable *t, qx::dao::detail::IxDao_Helper *dao)
{
if (t)
{
t->qxOnBeforeFetch(dao);
}
}
static inline void onAfterInsert(qx::QxPersistable *t, qx::dao::detail::IxDao_Helper *dao)
{
if (t)
{
t->qxOnAfterInsert(dao);
}
}
static inline void onAfterUpdate(qx::QxPersistable *t, qx::dao::detail::IxDao_Helper *dao)
{
if (t)
{
t->qxOnAfterUpdate(dao);
}
}
static inline void onAfterDelete(qx::QxPersistable *t, qx::dao::detail::IxDao_Helper *dao)
{
if (t)
{
t->qxOnAfterDelete(dao);
}
}
static inline void onAfterFetch(qx::QxPersistable *t, qx::dao::detail::IxDao_Helper *dao)
{
if (t)
{
t->qxOnAfterFetch(dao);
}
}
};
} // namespace detail
} // namespace dao
} // namespace qx
#endif // _QX_PERSISTABLE_H_

View File

@@ -0,0 +1,53 @@
#ifndef _QX_TEST_QT_META_PROPERTY_H_
#define _QX_TEST_QT_META_PROPERTY_H_
#ifdef _MSC_VER
#pragma once
#endif
#ifdef _QX_NO_PRECOMPILED_HEADER
#ifndef Q_MOC_RUN
#include "../include/precompiled.h" // Need to include precompiled header for the generated moc file
#endif // Q_MOC_RUN
#endif // _QX_NO_PRECOMPILED_HEADER
class QX_DLL1_EXPORT TestQtProperty : public QObject
{
Q_OBJECT
Q_PROPERTY(int id READ id WRITE setId)
Q_PROPERTY(long number READ number WRITE setNumber)
Q_PROPERTY(QString desc READ desc WRITE setDesc)
Q_PROPERTY(QDateTime birthDate READ birthDate WRITE setBirthDate)
Q_PROPERTY(QVariant photo READ photo WRITE setPhoto)
protected:
int m_id;
long m_number;
QString m_desc;
QDateTime m_birthDate;
QVariant m_photo;
public:
TestQtProperty() : QObject(), m_id(0), m_number(0) { ; }
virtual ~TestQtProperty() { ; }
int id() const { return m_id; }
long number() const { return m_number; }
QString desc() const { return m_desc; }
QDateTime birthDate() const { return m_birthDate; }
QVariant photo() const { return m_photo; }
void setId(int i) { m_id = i; }
void setNumber(long l) { m_number = l; }
void setDesc(const QString & s) { m_desc = s; }
void setBirthDate(const QDateTime & dt) { m_birthDate = dt; }
void setPhoto(const QVariant & v) { m_photo = v; }
};
QX_REGISTER_HPP_QX_DLL1(TestQtProperty, QObject, 0)
#endif // _QX_TEST_QT_META_PROPERTY_H_

View File

@@ -0,0 +1,26 @@
#ifndef _QX_DLL1_EXPORT_H_
#define _QX_DLL1_EXPORT_H_
#ifdef _MSC_VER
#pragma once
#endif
#ifdef _QX_BUILDING_DLL1
#define QX_DLL1_EXPORT QX_DLL_EXPORT_HELPER
#else // _QX_BUILDING_DLL1
#define QX_DLL1_EXPORT QX_DLL_IMPORT_HELPER
#endif // _QX_BUILDING_DLL1
#ifdef _QX_BUILDING_DLL1
#define QX_REGISTER_HPP_QX_DLL1 QX_REGISTER_HPP_EXPORT_DLL
#define QX_REGISTER_CPP_QX_DLL1 QX_REGISTER_CPP_EXPORT_DLL
#define QX_REGISTER_COMPLEX_CLASS_NAME_HPP_QX_DLL1 QX_REGISTER_COMPLEX_CLASS_NAME_HPP_EXPORT_DLL
#define QX_REGISTER_COMPLEX_CLASS_NAME_CPP_QX_DLL1 QX_REGISTER_COMPLEX_CLASS_NAME_CPP_EXPORT_DLL
#else // _QX_BUILDING_DLL1
#define QX_REGISTER_HPP_QX_DLL1 QX_REGISTER_HPP_IMPORT_DLL
#define QX_REGISTER_CPP_QX_DLL1 QX_REGISTER_CPP_IMPORT_DLL
#define QX_REGISTER_COMPLEX_CLASS_NAME_HPP_QX_DLL1 QX_REGISTER_COMPLEX_CLASS_NAME_HPP_IMPORT_DLL
#define QX_REGISTER_COMPLEX_CLASS_NAME_CPP_QX_DLL1 QX_REGISTER_COMPLEX_CLASS_NAME_CPP_IMPORT_DLL
#endif // _QX_BUILDING_DLL1
#endif // _QX_DLL1_EXPORT_H_

View File

@@ -0,0 +1,12 @@
#ifndef _QX_DLL1_PRECOMPILED_HEADER_H_
#define _QX_DLL1_PRECOMPILED_HEADER_H_
#ifdef _MSC_VER
#pragma once
#endif
#include <QxOrm.h>
#include "../include/export.h"
#endif // _QX_DLL1_PRECOMPILED_HEADER_H_

View File

@@ -0,0 +1,7 @@
# git does not allow empty directories.
# Yet, we need to add this empty directory on git.
# To achieve that, we created this .gitignore file, so that the directory will not be empty thus enabling us to commit it.
# Since we want all generated files/folders in this directory to be ignored by git, we add a rule for this.
*
# And then add an exception for this specifc file (so that we can commit it).
!.gitignore

View File

@@ -0,0 +1,7 @@
# git does not allow empty directories.
# Yet, we need to add this empty directory on git.
# To achieve that, we created this .gitignore file, so that the directory will not be empty thus enabling us to commit it.
# Since we want all generated files/folders in this directory to be ignored by git, we add a rule for this.
*
# And then add an exception for this specifc file (so that we can commit it).
!.gitignore

View File

@@ -0,0 +1,7 @@
# git does not allow empty directories.
# Yet, we need to add this empty directory on git.
# To achieve that, we created this .gitignore file, so that the directory will not be empty thus enabling us to commit it.
# Since we want all generated files/folders in this directory to be ignored by git, we add a rule for this.
*
# And then add an exception for this specifc file (so that we can commit it).
!.gitignore

View File

@@ -0,0 +1,7 @@
# git does not allow empty directories.
# Yet, we need to add this empty directory on git.
# To achieve that, we created this .gitignore file, so that the directory will not be empty thus enabling us to commit it.
# Since we want all generated files/folders in this directory to be ignored by git, we add a rule for this.
*
# And then add an exception for this specifc file (so that we can commit it).
!.gitignore

View File

@@ -0,0 +1,70 @@
#include "../include/precompiled.h"
#include "../include/CPerson.h"
#include <QxOrm_Impl.h>
void myGlobalValidator_1(const QVariant & value, const qx::IxValidator * validator, qx::QxInvalidValueX & invalidValues);
void myGlobalValidator_2(const QString & value, const qx::IxValidator * validator, qx::QxInvalidValueX & invalidValues);
QX_REGISTER_COMPLEX_CLASS_NAME_CPP_QX_DLL1(qx::test::CPerson, qx_test_CPerson)
namespace qx {
template <> void register_class(QxClass<qx::test::CPerson> & t)
{
IxDataMember * pData = NULL;
IxFunction * pFct = NULL;
IxValidator * pValidator = NULL;
t.setName("CPerson");
pData = t.id(& qx::test::CPerson::m_lPersonId, "idPerson", 0);
pData = t.data(& qx::test::CPerson::m_sFirstName, "firstName", 0);
pData = t.data(& qx::test::CPerson::m_sLastName, "lastName", 0);
pData = t.data(& qx::test::CPerson::m_dDouble, "double", 0);
pData = t.data(& qx::test::CPerson::m_eSex, "sex", 0);
pFct = t.fct_0<long>(std::mem_fn(& qx::test::CPerson::getPersonId), "fct_getPersonId"); // using std::mem_fn() here is just a workaround for an issue with some versions of MSVC, it is not required with a full compliant C++11 compiler (http://stackoverflow.com/questions/23778883/vs2013-stdfunction-with-member-function)
pFct = t.fct_0<QString>(std::mem_fn(& qx::test::CPerson::getFirstName), "fct_getFirstName");
pFct = t.fct_1<void, long>(std::mem_fn(& qx::test::CPerson::setPersonId), "fct_setPersonId");
pFct = t.fctStatic_1<int, const QString &>(& qx::test::CPerson::testStaticFct, "fct_testStaticFct");
QxValidatorX<qx::test::CPerson> * pAllValidator = t.getAllValidator();
if (! pAllValidator) { qAssert(false); return; }
pValidator = pAllValidator->add_NotEmpty("firstName", "a person must have a firstname");
pValidator = pAllValidator->add_NotEmpty("lastName");
pValidator = pAllValidator->add_MinDecimal("double", 0.5, "'double' field must be greater than or equal to '0.5'");
pValidator = pAllValidator->add_MaxDecimal("double", 103.19);
pValidator = pAllValidator->add_CustomValidator(std::mem_fn(& qx::test::CPerson::isValid)); // using std::mem_fn() here is just a workaround for an issue with some versions of MSVC, it is not required with a full compliant C++11 compiler (http://stackoverflow.com/questions/23778883/vs2013-stdfunction-with-member-function)
pValidator = pAllValidator->add_CustomValidator_QVariant(& myGlobalValidator_1, "firstName");
pValidator = pAllValidator->add_CustomValidator_DataType<QString>(& myGlobalValidator_2, "lastName");
}}
// ********************************************************************************************************
// ********************************************************************************************************
// Example of global functions 'myGlobalValidator_1' and 'myGlobalValidator_2' used by 'QxValidator' module
// Those functions will be called automatically by validator engine of QxOrm library :
// - when you try to insert or update using 'qx::dao::xxx' functions
// - when you call 'qx::validate()' function
void myGlobalValidator_1(const QVariant & value, const qx::IxValidator * validator, qx::QxInvalidValueX & invalidValues)
{
// Here you can test the value (converted to QVariant type)
// If an invalid value is detected, just add a message into 'invalidValues' collection
Q_UNUSED(value); Q_UNUSED(validator); Q_UNUSED(invalidValues);
}
void myGlobalValidator_2(const QString & value, const qx::IxValidator * validator, qx::QxInvalidValueX & invalidValues)
{
// Here you can test the value (with its real type, in this example, the data-member is a 'QString' type)
// If an invalid value is detected, just add a message into 'invalidValues' collection
Q_UNUSED(value); Q_UNUSED(validator); Q_UNUSED(invalidValues);
}
// ********************************************************************************************************
// ********************************************************************************************************

View File

@@ -0,0 +1,7 @@
# git does not allow empty directories.
# Yet, we need to add this empty directory on git.
# To achieve that, we created this .gitignore file, so that the directory will not be empty thus enabling us to commit it.
# Since we want all generated files/folders in this directory to be ignored by git, we add a rule for this.
*
# And then add an exception for this specifc file (so that we can commit it).
!.gitignore

View File

@@ -0,0 +1,31 @@
#include "../include/precompiled.h"
#include "../include/CPerson.h"
#include <QxOrm_Impl.h>
namespace qx {
namespace test {
void CPerson::isValid(qx::QxInvalidValueX & invalidValues)
{
// This method is called automatically by 'QxValidator' module (validator engine of QxOrm library) :
// - when you try to insert or update using 'qx::dao::xxx' functions
// - when you call 'qx::validate()' function
// For registration, see 'pAllValidator->add_CustomValidator(& qx::test::CPerson::isValid);' into 'qx::register_class<T>()' function
// Here, you can verify some values of your instance
// If a value is not valid, you must add an invalid value into the collection 'invalidValues'
if ((m_sFirstName == "admin") || (m_sLastName == "admin"))
{ invalidValues.insert("you cannot set 'admin' for the name of a person"); }
}
int CPerson::testStaticFct(const QString & s)
{
return s.toInt();
}
} // namespace test
} // namespace qx

View File

@@ -0,0 +1,132 @@
/****************************************************************************
**
** https://www.qxorm.com/
** Copyright (C) 2013 XDL Team (ic-east.com)
**
** This file is part of the QxOrm library
**
** This software is provided 'as-is', without any express or implied
** warranty. In no event will the authors be held liable for any
** damages arising from the use of this software
**
** Commercial Usage
** Licensees holding valid commercial QxOrm licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and XDL Team
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file 'license.gpl3.txt' included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met : http://www.gnu.org/copyleft/gpl.html
**
** If you are unsure which license is appropriate for your use, or
** if you have questions regarding the use of this file, please contact :
** ic-east.com
**
****************************************************************************/
#include "../include/precompiled.h"
#include "../include/QxPersistable.h"
#include <QxOrm_Impl.h>
QX_REGISTER_COMPLEX_CLASS_NAME_CPP_QX_DLL1(qx::QxPersistable, qx_QxPersistable)
namespace qx
{
template <>
void register_class(QxClass<qx::QxPersistable> &t)
{
t.setPropertyBag("QX_NOT_PERSISTABLE", "1");
t.setSoftDelete(qx::QxSoftDelete("qx_deleted_at"));
t.id(&qx::QxPersistable::m_qxId, "qx_id");
t.data(&qx::QxPersistable::m_qxDateCreation, "qx_date_creation");
t.data(&qx::QxPersistable::m_qxDateModification, "qx_date_modification");
QxValidatorX<qx::QxPersistable> *pAllValidator = t.getAllValidator();
pAllValidator->add_CustomValidator(std::mem_fn(&qx::QxPersistable::qxIsValidInternal)); // using std::mem_fn() here is just a workaround for an issue with some versions of MSVC, it is not required with a full compliant C++11 compiler (http://stackoverflow.com/questions/23778883/vs2013-stdfunction-with-member-function)
}
QX_PERSISTABLE_CPP(QxPersistable)
QxPersistable::QxPersistable() : QObject(), qx::IxPersistable(), m_qxId(0) { ; }
QxPersistable::~QxPersistable() { ; }
long QxPersistable::qxGetId() const { return m_qxId; }
QDateTime QxPersistable::qxGetDateCreation() const { return m_qxDateCreation.toDateTime(); }
QDateTime QxPersistable::qxGetDateModification() const { return m_qxDateModification.toDateTime(); }
void QxPersistable::qxSetId(long l) { m_qxId = l; }
void QxPersistable::qxSetDateCreation(const QDateTime &dt) { m_qxDateCreation.fromDateTime(dt); }
void QxPersistable::qxSetDateModification(const QDateTime &dt) { m_qxDateModification.fromDateTime(dt); }
void QxPersistable::qxIsValidInternal(qx::QxInvalidValueX &invalidValues) { this->qxIsValid(invalidValues); }
void QxPersistable::qxIsValid(qx::QxInvalidValueX &invalidValues) { Q_UNUSED(invalidValues); }
void QxPersistable::qxOnBeforeInsert(qx::dao::detail::IxDao_Helper *dao)
{
Q_UNUSED(dao);
m_qxDateCreation.fromDateTime(QDateTime::currentDateTime());
m_qxDateModification = m_qxDateCreation;
Q_EMIT qxOnBeforeInsert(this);
}
void QxPersistable::qxOnBeforeUpdate(qx::dao::detail::IxDao_Helper *dao)
{
Q_UNUSED(dao);
m_qxDateModification.fromDateTime(QDateTime::currentDateTime());
Q_EMIT qxOnBeforeUpdate(this);
}
void QxPersistable::qxOnBeforeDelete(qx::dao::detail::IxDao_Helper *dao)
{
Q_UNUSED(dao);
Q_EMIT qxOnBeforeDelete(this);
}
void QxPersistable::qxOnBeforeFetch(qx::dao::detail::IxDao_Helper *dao)
{
Q_UNUSED(dao);
Q_EMIT qxOnBeforeFetch(this);
}
void QxPersistable::qxOnAfterInsert(qx::dao::detail::IxDao_Helper *dao)
{
Q_UNUSED(dao);
Q_EMIT qxOnAfterInsert(this);
}
void QxPersistable::qxOnAfterUpdate(qx::dao::detail::IxDao_Helper *dao)
{
Q_UNUSED(dao);
Q_EMIT qxOnAfterUpdate(this);
}
void QxPersistable::qxOnAfterDelete(qx::dao::detail::IxDao_Helper *dao)
{
Q_UNUSED(dao);
Q_EMIT qxOnAfterDelete(this);
}
void QxPersistable::qxOnAfterFetch(qx::dao::detail::IxDao_Helper *dao)
{
Q_UNUSED(dao);
Q_EMIT qxOnAfterFetch(this);
}
} // namespace qx

View File

@@ -0,0 +1,24 @@
#include "../include/precompiled.h"
#include "../include/TestQtProperty.h"
#include <QxOrm_Impl.h>
QX_REGISTER_CPP_QX_DLL1(TestQtProperty)
QX_REGISTER_ALL_QT_PROPERTIES(TestQtProperty, "id")
/*
Instead of using 'QX_REGISTER_ALL_QT_PROPERTIES(...)' macro, it's also
possible to write classic 'void qx::register_class<T>(...)' function, like this :
namespace qx {
template <> void register_class(QxClass<MyQObject> & t)
{ qx::register_all_qt_properties<MyQObject>(t, "my_id"); }
} // namespace qx
So, you can mix Qt meta-properties and classic registration data-member.
All is stored using the same interface : 'qx::IxDataMember *'.
To more details about advantages and disadvantages of using Qt meta-property,
go to the FAQ of QxOrm library :
- How to register automatically Qt meta-properties to QxOrm context ?
*/

View File

@@ -0,0 +1,20 @@
#ifdef _MSC_VER
#include <windows.h>
extern "C"
int WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /* lpReservedt */)
{
(void)hInstance;
switch (dwReason)
{
case DLL_PROCESS_ATTACH: ::OutputDebugStringA("dll1.DllMain() ---> DLL_PROCESS_ATTACH\n"); break;
case DLL_PROCESS_DETACH: ::OutputDebugStringA("dll1.DllMain() ---> DLL_PROCESS_DETACH\n"); break;
case DLL_THREAD_ATTACH: ::OutputDebugStringA("dll1.DllMain() ---> DLL_THREAD_ATTACH\n"); break;
case DLL_THREAD_DETACH: ::OutputDebugStringA("dll1.DllMain() ---> DLL_THREAD_DETACH\n"); break;
}
return 1;
}
#endif // _MSC_VER