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,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