first commit
This commit is contained in:
7
test/qxDllSample/CMakeLists.txt
Normal file
7
test/qxDllSample/CMakeLists.txt
Normal file
@@ -0,0 +1,7 @@
|
||||
cmake_minimum_required(VERSION 3.1)
|
||||
|
||||
project(qxDllSample LANGUAGES CXX)
|
||||
|
||||
add_subdirectory(dll1)
|
||||
add_subdirectory(dll2)
|
||||
add_subdirectory(exe)
|
||||
53
test/qxDllSample/dll1/CMakeLists.txt
Normal file
53
test/qxDllSample/dll1/CMakeLists.txt
Normal 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"
|
||||
)
|
||||
7
test/qxDllSample/dll1/debug/.gitignore
vendored
Normal file
7
test/qxDllSample/dll1/debug/.gitignore
vendored
Normal 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
|
||||
38
test/qxDllSample/dll1/dll1.pro
Normal file
38
test/qxDllSample/dll1/dll1.pro
Normal 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
|
||||
66
test/qxDllSample/dll1/include/CPerson.h
Normal file
66
test/qxDllSample/dll1/include/CPerson.h
Normal 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_
|
||||
225
test/qxDllSample/dll1/include/QxPersistable.h
Normal file
225
test/qxDllSample/dll1/include/QxPersistable.h
Normal 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_
|
||||
53
test/qxDllSample/dll1/include/TestQtProperty.h
Normal file
53
test/qxDllSample/dll1/include/TestQtProperty.h
Normal 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_
|
||||
26
test/qxDllSample/dll1/include/export.h
Normal file
26
test/qxDllSample/dll1/include/export.h
Normal 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_
|
||||
12
test/qxDllSample/dll1/include/precompiled.h
Normal file
12
test/qxDllSample/dll1/include/precompiled.h
Normal 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_
|
||||
7
test/qxDllSample/dll1/qt/moc/.gitignore
vendored
Normal file
7
test/qxDllSample/dll1/qt/moc/.gitignore
vendored
Normal 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
|
||||
7
test/qxDllSample/dll1/qt/rcc/src/.gitignore
vendored
Normal file
7
test/qxDllSample/dll1/qt/rcc/src/.gitignore
vendored
Normal 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
|
||||
7
test/qxDllSample/dll1/qt/ui/include/.gitignore
vendored
Normal file
7
test/qxDllSample/dll1/qt/ui/include/.gitignore
vendored
Normal 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
|
||||
7
test/qxDllSample/dll1/qt/ui/src/.gitignore
vendored
Normal file
7
test/qxDllSample/dll1/qt/ui/src/.gitignore
vendored
Normal 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
|
||||
70
test/qxDllSample/dll1/qx/CPerson.qx.cpp
Normal file
70
test/qxDllSample/dll1/qx/CPerson.qx.cpp
Normal 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);
|
||||
}
|
||||
|
||||
// ********************************************************************************************************
|
||||
// ********************************************************************************************************
|
||||
7
test/qxDllSample/dll1/release/.gitignore
vendored
Normal file
7
test/qxDllSample/dll1/release/.gitignore
vendored
Normal 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
|
||||
31
test/qxDllSample/dll1/src/CPerson.cpp
Normal file
31
test/qxDllSample/dll1/src/CPerson.cpp
Normal 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
|
||||
132
test/qxDllSample/dll1/src/QxPersistable.cpp
Normal file
132
test/qxDllSample/dll1/src/QxPersistable.cpp
Normal 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
|
||||
24
test/qxDllSample/dll1/src/TestQtProperty.cpp
Normal file
24
test/qxDllSample/dll1/src/TestQtProperty.cpp
Normal 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 ?
|
||||
*/
|
||||
20
test/qxDllSample/dll1/src/main.cpp
Normal file
20
test/qxDllSample/dll1/src/main.cpp
Normal 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
|
||||
63
test/qxDllSample/dll2/CMakeLists.txt
Normal file
63
test/qxDllSample/dll2/CMakeLists.txt
Normal file
@@ -0,0 +1,63 @@
|
||||
cmake_minimum_required(VERSION 3.1)
|
||||
|
||||
project(dll2 LANGUAGES CXX)
|
||||
|
||||
include(../../../QxOrm.cmake)
|
||||
|
||||
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core Sql Gui REQUIRED)
|
||||
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
set(CMAKE_DEBUG_POSTFIX "d")
|
||||
|
||||
set(HEADERS
|
||||
./include/precompiled.h
|
||||
./include/export.h
|
||||
./include/CUser.h
|
||||
./include/CTestAll.h
|
||||
./include/Bar.h
|
||||
./include/Foo.h
|
||||
./include/BaseClassTrigger.h
|
||||
)
|
||||
|
||||
set(SRCS
|
||||
./qx/CUser.qx.cpp
|
||||
./qx/CTestAll.qx.cpp
|
||||
./qx/Bar.qx.cpp
|
||||
./qx/Foo.qx.cpp
|
||||
./qx/BaseClassTrigger.qx.cpp
|
||||
./src/CUser.cpp
|
||||
./src/CTestAll.cpp
|
||||
./src/Bar.cpp
|
||||
./src/Foo.cpp
|
||||
./src/BaseClassTrigger.cpp
|
||||
./src/main.cpp
|
||||
)
|
||||
|
||||
add_library(dll2 SHARED ${SRCS} ${HEADERS})
|
||||
|
||||
target_compile_definitions(dll2 PRIVATE -D_QX_BUILDING_DLL2)
|
||||
|
||||
if(COMMAND target_precompile_headers)
|
||||
target_precompile_headers(dll2 PRIVATE ./include/precompiled.h)
|
||||
endif() # (COMMAND target_precompile_headers)
|
||||
|
||||
target_link_libraries(dll2 ${QX_LIBRARIES} Qt${QT_VERSION_MAJOR}::Gui QxOrm dll1)
|
||||
|
||||
set_target_properties(dll2 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"
|
||||
)
|
||||
7
test/qxDllSample/dll2/debug/.gitignore
vendored
Normal file
7
test/qxDllSample/dll2/debug/.gitignore
vendored
Normal 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
|
||||
50
test/qxDllSample/dll2/dll2.pro
Normal file
50
test/qxDllSample/dll2/dll2.pro
Normal file
@@ -0,0 +1,50 @@
|
||||
include(../../../QxOrm.pri)
|
||||
|
||||
TEMPLATE = lib
|
||||
CONFIG += dll
|
||||
DEFINES += _QX_BUILDING_DLL2
|
||||
INCLUDEPATH += ../../../../QxOrm/include/
|
||||
DESTDIR = ../../../../QxOrm/test/_bin/
|
||||
QT += gui
|
||||
|
||||
!contains(DEFINES, _QX_NO_PRECOMPILED_HEADER) {
|
||||
PRECOMPILED_HEADER = ./include/precompiled.h
|
||||
} # !contains(DEFINES, _QX_NO_PRECOMPILED_HEADER)
|
||||
|
||||
CONFIG(debug, debug|release) {
|
||||
TARGET = dll2d
|
||||
} else {
|
||||
TARGET = dll2
|
||||
} # CONFIG(debug, debug|release)
|
||||
|
||||
LIBS += -L"../../../../QxOrm/lib"
|
||||
LIBS += -L"../../../../QxOrm/test/_bin"
|
||||
|
||||
CONFIG(debug, debug|release) {
|
||||
LIBS += -l"QxOrmd"
|
||||
LIBS += -l"dll1d"
|
||||
} else {
|
||||
LIBS += -l"QxOrm"
|
||||
LIBS += -l"dll1"
|
||||
} # CONFIG(debug, debug|release)
|
||||
|
||||
HEADERS += ./include/precompiled.h
|
||||
HEADERS += ./include/export.h
|
||||
HEADERS += ./include/CUser.h
|
||||
HEADERS += ./include/CTestAll.h
|
||||
HEADERS += ./include/Bar.h
|
||||
HEADERS += ./include/Foo.h
|
||||
HEADERS += ./include/BaseClassTrigger.h
|
||||
|
||||
SOURCES += ./qx/CUser.qx.cpp
|
||||
SOURCES += ./qx/CTestAll.qx.cpp
|
||||
SOURCES += ./qx/Bar.qx.cpp
|
||||
SOURCES += ./qx/Foo.qx.cpp
|
||||
SOURCES += ./qx/BaseClassTrigger.qx.cpp
|
||||
|
||||
SOURCES += ./src/CUser.cpp
|
||||
SOURCES += ./src/CTestAll.cpp
|
||||
SOURCES += ./src/Bar.cpp
|
||||
SOURCES += ./src/Foo.cpp
|
||||
SOURCES += ./src/BaseClassTrigger.cpp
|
||||
SOURCES += ./src/main.cpp
|
||||
48
test/qxDllSample/dll2/include/Bar.h
Normal file
48
test/qxDllSample/dll2/include/Bar.h
Normal file
@@ -0,0 +1,48 @@
|
||||
#ifndef _QX_BAR_H_
|
||||
#define _QX_BAR_H_
|
||||
|
||||
#include "../include/BaseClassTrigger.h"
|
||||
|
||||
class Foo;
|
||||
|
||||
class QX_DLL2_EXPORT Bar : public BaseClassTrigger
|
||||
{
|
||||
|
||||
QX_REGISTER_FRIEND_CLASS(Bar)
|
||||
QX_PERSISTABLE_HPP(Bar)
|
||||
|
||||
public:
|
||||
|
||||
typedef std::shared_ptr<Foo> Foo_ptr;
|
||||
|
||||
protected:
|
||||
|
||||
QString m_sCode;
|
||||
QString m_sValue;
|
||||
Foo_ptr m_pFoo;
|
||||
|
||||
public:
|
||||
|
||||
Bar() : BaseClassTrigger() { ; }
|
||||
virtual ~Bar() { ; }
|
||||
|
||||
virtual void makeAbstractClass() { ; }
|
||||
|
||||
QString getCode() const { return m_sCode; }
|
||||
QString getValue() const { return m_sValue; }
|
||||
Foo_ptr getFoo() const { return m_pFoo; }
|
||||
|
||||
void setCode(const QString & s) { m_sCode = s; }
|
||||
void setValue(const QString & s) { m_sValue = s; }
|
||||
void setFoo(Foo_ptr p) { m_pFoo = p; }
|
||||
void setFoo(long l);
|
||||
|
||||
};
|
||||
|
||||
QX_REGISTER_HPP_QX_DLL2(Bar, BaseClassTrigger, 0)
|
||||
|
||||
typedef std::shared_ptr<Bar> Bar_ptr;
|
||||
typedef std::vector<Bar_ptr> BarX;
|
||||
typedef std::shared_ptr<BarX> BarX_ptr;
|
||||
|
||||
#endif // _QX_BAR_H_
|
||||
67
test/qxDllSample/dll2/include/BaseClassTrigger.h
Normal file
67
test/qxDllSample/dll2/include/BaseClassTrigger.h
Normal file
@@ -0,0 +1,67 @@
|
||||
#ifndef _QX_BASE_CLASS_TRIGGER_H_
|
||||
#define _QX_BASE_CLASS_TRIGGER_H_
|
||||
|
||||
class QX_DLL2_EXPORT BaseClassTrigger : public qx::IxPersistable
|
||||
{
|
||||
|
||||
QX_REGISTER_FRIEND_CLASS(BaseClassTrigger)
|
||||
|
||||
protected:
|
||||
|
||||
long m_id;
|
||||
QDateTime m_dateCreation;
|
||||
QDateTime m_dateModification;
|
||||
QString m_userCreation;
|
||||
QString m_userModification;
|
||||
|
||||
public:
|
||||
|
||||
BaseClassTrigger() : m_id(0) { ; }
|
||||
virtual ~BaseClassTrigger() { ; }
|
||||
|
||||
virtual void makeAbstractClass() = 0;
|
||||
|
||||
long getId() const { return m_id; }
|
||||
QDateTime getDateCreation() const { return m_dateCreation; }
|
||||
QDateTime getDateModification() const { return m_dateModification; }
|
||||
QString getUserCreation() const { return m_userCreation; }
|
||||
QString getUserModification() const { return m_userModification; }
|
||||
|
||||
void setId(long l) { m_id = l; }
|
||||
void setDateCreation(const QDateTime & dt) { m_dateCreation = dt; }
|
||||
void setDateModification(const QDateTime & dt) { m_dateModification = dt; }
|
||||
void setUserCreation(const QString & s) { m_userCreation = s; }
|
||||
void setUserModification(const QString & s) { m_userModification = s; }
|
||||
|
||||
void onBeforeInsert(qx::dao::detail::IxDao_Helper * dao);
|
||||
void onBeforeUpdate(qx::dao::detail::IxDao_Helper * dao);
|
||||
|
||||
};
|
||||
|
||||
QX_REGISTER_ABSTRACT_CLASS(BaseClassTrigger)
|
||||
QX_REGISTER_HPP_QX_DLL2(BaseClassTrigger, qx::trait::no_base_class_defined, 0)
|
||||
|
||||
namespace qx {
|
||||
namespace dao {
|
||||
namespace detail {
|
||||
|
||||
template <>
|
||||
struct QxDao_Trigger<BaseClassTrigger>
|
||||
{
|
||||
|
||||
static inline void onBeforeInsert(BaseClassTrigger * t, qx::dao::detail::IxDao_Helper * dao) { if (t) { t->onBeforeInsert(dao); } }
|
||||
static inline void onBeforeUpdate(BaseClassTrigger * t, qx::dao::detail::IxDao_Helper * dao) { if (t) { t->onBeforeUpdate(dao); } }
|
||||
static inline void onBeforeDelete(BaseClassTrigger * t, qx::dao::detail::IxDao_Helper * dao) { Q_UNUSED(t); Q_UNUSED(dao); }
|
||||
static inline void onBeforeFetch(BaseClassTrigger * t, qx::dao::detail::IxDao_Helper * dao) { Q_UNUSED(t); Q_UNUSED(dao); }
|
||||
static inline void onAfterInsert(BaseClassTrigger * t, qx::dao::detail::IxDao_Helper * dao) { Q_UNUSED(t); Q_UNUSED(dao); }
|
||||
static inline void onAfterUpdate(BaseClassTrigger * t, qx::dao::detail::IxDao_Helper * dao) { Q_UNUSED(t); Q_UNUSED(dao); }
|
||||
static inline void onAfterDelete(BaseClassTrigger * t, qx::dao::detail::IxDao_Helper * dao) { Q_UNUSED(t); Q_UNUSED(dao); }
|
||||
static inline void onAfterFetch(BaseClassTrigger * t, qx::dao::detail::IxDao_Helper * dao) { Q_UNUSED(t); Q_UNUSED(dao); }
|
||||
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
} // namespace dao
|
||||
} // namespace qx
|
||||
|
||||
#endif // _QX_BASE_CLASS_TRIGGER_H_
|
||||
105
test/qxDllSample/dll2/include/CTestAll.h
Normal file
105
test/qxDllSample/dll2/include/CTestAll.h
Normal file
@@ -0,0 +1,105 @@
|
||||
#ifndef _QX_CLASS_TEST_ALL_H_
|
||||
#define _QX_CLASS_TEST_ALL_H_
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <QtGui/qcolor.h>
|
||||
#include <QtGui/qfont.h>
|
||||
#include <QtGui/qimage.h>
|
||||
#include <QtGui/qbrush.h>
|
||||
#include <QtGui/qpicture.h>
|
||||
#include <QtGui/qpixmap.h>
|
||||
#include <QtGui/qregion.h>
|
||||
|
||||
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
|
||||
#include <QtGui/qmatrix.h>
|
||||
#endif // (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
|
||||
|
||||
#include "../../dll1/include/CPerson.h"
|
||||
#include "../../dll2/include/CUser.h"
|
||||
|
||||
class QX_DLL2_EXPORT CTestAll
|
||||
{
|
||||
|
||||
QX_REGISTER_FRIEND_CLASS(CTestAll)
|
||||
|
||||
protected:
|
||||
|
||||
long m_lId;
|
||||
qx_bool m_oQxBool;
|
||||
|
||||
std::string m_oStdString;
|
||||
std::pair<QPoint, QRect> m_oStdPair;
|
||||
std::vector< QSharedPointer<qx::test::CPerson> > m_oStdVector;
|
||||
std::list<QDateTime> m_oStdList;
|
||||
std::map<std::string, QSharedPointer<CUser> > m_oStdMap;
|
||||
std::shared_ptr<QObject> m_oBoostSharedPtr;
|
||||
|
||||
#ifdef _QX_ENABLE_BOOST
|
||||
boost::tuple<QTime, QPoint, QUrl> m_oBoostTuple;
|
||||
boost::scoped_ptr<QSize> m_oBoostScopedPtr;
|
||||
boost::weak_ptr<CTestAll> m_oBoostWeakPtr;
|
||||
boost::unordered_map<long, std::string> m_oBoostUnorderedMap;
|
||||
#endif // _QX_ENABLE_BOOST
|
||||
|
||||
QString m_oQString;
|
||||
QObject m_oQObject;
|
||||
QBrush m_oQBrush;
|
||||
QByteArray m_oQByteArray;
|
||||
QColor m_oQColor;
|
||||
QDate m_oQDate;
|
||||
QDateTime m_oQDateTime;
|
||||
QTime m_oQTime;
|
||||
QFont m_oQFont;
|
||||
QImage m_oQImage;
|
||||
QPicture m_oQPicture;
|
||||
QPoint m_oQPoint;
|
||||
QRect m_oQRect;
|
||||
QSize m_oQSize;
|
||||
QRegion m_oQRegion;
|
||||
QUrl m_oQUrl;
|
||||
QVariant m_oQVariant;
|
||||
QStringList m_oQStringList;
|
||||
|
||||
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
|
||||
QMatrix m_oQMatrix;
|
||||
#endif // (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
|
||||
|
||||
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
|
||||
QRegExp m_oQRegExp;
|
||||
#endif // (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
|
||||
|
||||
QHash<long, QString> m_oQHash;
|
||||
QMultiHash<QString, std::shared_ptr<qx::test::CPerson> > m_oQMultiHash;
|
||||
QMap<double, std::string> m_oQMap;
|
||||
QMultiMap<std::string, QSharedPointer<CUser> > m_oQMultiMap;
|
||||
qx::QxCollection<QString, std::tuple<long, qx::test::CPerson *> > m_oQxCollection;
|
||||
|
||||
QList<float> m_oQList;
|
||||
QVector<CUser *> m_oQVector;
|
||||
QSharedPointer<std::tuple<int, std::string, std::shared_ptr<qx::test::CPerson> > > m_oQSharedPointer;
|
||||
QPair<QString, QPoint> m_oQPair;
|
||||
|
||||
#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 0))
|
||||
QLinkedList<QString> m_oQLinkedList;
|
||||
#endif // (QT_VERSION < QT_VERSION_CHECK(5, 15, 0))
|
||||
|
||||
public:
|
||||
|
||||
CTestAll() { init(); }
|
||||
virtual ~CTestAll() { terminate(); }
|
||||
|
||||
static void test();
|
||||
|
||||
private:
|
||||
|
||||
void init();
|
||||
void terminate();
|
||||
|
||||
};
|
||||
|
||||
QX_REGISTER_HPP_QX_DLL2(CTestAll, qx::trait::no_base_class_defined, 1)
|
||||
|
||||
#endif // _QX_CLASS_TEST_ALL_H_
|
||||
54
test/qxDllSample/dll2/include/CUser.h
Normal file
54
test/qxDllSample/dll2/include/CUser.h
Normal file
@@ -0,0 +1,54 @@
|
||||
#ifndef _QX_CLASS_USER_H_
|
||||
#define _QX_CLASS_USER_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
|
||||
|
||||
#include "../../dll1/include/CPerson.h"
|
||||
|
||||
class QX_DLL2_EXPORT CUser : public qx::test::CPerson
|
||||
{
|
||||
|
||||
Q_OBJECT
|
||||
QX_REGISTER_FRIEND_CLASS(CUser)
|
||||
|
||||
protected:
|
||||
|
||||
long m_lUserId;
|
||||
QString m_sProfil;
|
||||
qx_bool m_bIsAdmin;
|
||||
QDateTime m_dtModif;
|
||||
qx::test::CPerson * m_pBrother;
|
||||
|
||||
public:
|
||||
|
||||
CUser() : qx::test::CPerson(), m_lUserId(0), m_pBrother(NULL) { ; }
|
||||
CUser(long lId) : qx::test::CPerson(), m_lUserId(lId), m_pBrother(NULL) { ; }
|
||||
virtual ~CUser() { if (m_pBrother) { delete m_pBrother; m_pBrother = NULL; } }
|
||||
|
||||
void test();
|
||||
|
||||
long getUserId() const { return m_lUserId; }
|
||||
QString getProfil() const { return m_sProfil; }
|
||||
qx_bool getIsAdmin() const { return m_bIsAdmin; }
|
||||
QDateTime getDateModif() const { return m_dtModif; }
|
||||
qx::test::CPerson * getBrother() const { return m_pBrother; }
|
||||
|
||||
void setUserId(long l) { m_lUserId = l; }
|
||||
void setProfil(const QString & s) { m_sProfil = s; }
|
||||
void setIsAdmin(qx_bool b) { m_bIsAdmin = b; }
|
||||
void setDateModif(const QDateTime & dt) { m_dtModif = dt; }
|
||||
void setBrother(qx::test::CPerson * p) { if (m_pBrother) { delete m_pBrother; } m_pBrother = p; }
|
||||
|
||||
};
|
||||
|
||||
QX_REGISTER_HPP_QX_DLL2(CUser, qx::test::CPerson, 2)
|
||||
|
||||
#endif // _QX_CLASS_USER_H_
|
||||
67
test/qxDllSample/dll2/include/Foo.h
Normal file
67
test/qxDllSample/dll2/include/Foo.h
Normal file
@@ -0,0 +1,67 @@
|
||||
#ifndef _QX_FOO_H_
|
||||
#define _QX_FOO_H_
|
||||
|
||||
#include "../include/BaseClassTrigger.h"
|
||||
#include "../include/Bar.h"
|
||||
|
||||
class QX_DLL2_EXPORT Foo : public BaseClassTrigger
|
||||
{
|
||||
|
||||
QX_REGISTER_FRIEND_CLASS(Foo)
|
||||
QX_PERSISTABLE_HPP(Foo)
|
||||
|
||||
protected:
|
||||
|
||||
QString m_sName;
|
||||
QVariant m_sDesc;
|
||||
BarX_ptr m_pBarX;
|
||||
|
||||
qx::QxDateNeutral m_oDateNeutral;
|
||||
qx::QxTimeNeutral m_oTimeNeutral;
|
||||
qx::QxDateTimeNeutral m_oDateTimeNeutral;
|
||||
|
||||
#ifdef _QX_ENABLE_BOOST
|
||||
boost::optional<int> m_optInt;
|
||||
boost::optional<QString> m_optString;
|
||||
#endif // _QX_ENABLE_BOOST
|
||||
|
||||
public:
|
||||
|
||||
Foo() : BaseClassTrigger() { ; }
|
||||
virtual ~Foo() { ; }
|
||||
|
||||
virtual void makeAbstractClass() { ; }
|
||||
|
||||
QString getName() const { return m_sName; }
|
||||
QVariant getDesc() const { return m_sDesc; }
|
||||
BarX * getBarX() const { return m_pBarX.get(); }
|
||||
QDate getDate() const { return m_oDateNeutral.toDate(); }
|
||||
QTime getTime() const { return m_oTimeNeutral.toTime(); }
|
||||
QDateTime getDateTime() const { return m_oDateTimeNeutral.toDateTime(); }
|
||||
|
||||
#ifdef _QX_ENABLE_BOOST
|
||||
boost::optional<int> getOptInt() const { return m_optInt; }
|
||||
boost::optional<QString> getOptString() const { return m_optString; }
|
||||
#endif // _QX_ENABLE_BOOST
|
||||
|
||||
void setName(const QString & s) { m_sName = s; }
|
||||
void setDesc(const QVariant & s) { m_sDesc = s; }
|
||||
void setBarX(BarX_ptr p) { m_pBarX = p; }
|
||||
void setDate(const QDate & d) { m_oDateNeutral.setDate(d); }
|
||||
void setTime(const QTime & t) { m_oTimeNeutral.setTime(t); }
|
||||
void setDateTime(const QDateTime & dt) { m_oDateTimeNeutral.setDateTime(dt); }
|
||||
|
||||
#ifdef _QX_ENABLE_BOOST
|
||||
void setOptInt(const boost::optional<int> & opt) { m_optInt = opt; }
|
||||
void setOptString(const boost::optional<QString> & opt) { m_optString = opt; }
|
||||
#endif // _QX_ENABLE_BOOST
|
||||
|
||||
};
|
||||
|
||||
QX_REGISTER_HPP_QX_DLL2(Foo, BaseClassTrigger, 0)
|
||||
|
||||
typedef std::shared_ptr<Foo> Foo_ptr;
|
||||
typedef qx::QxCollection<long, Foo_ptr> FooX;
|
||||
typedef std::shared_ptr<FooX> FooX_ptr;
|
||||
|
||||
#endif // _QX_FOO_H_
|
||||
28
test/qxDllSample/dll2/include/export.h
Normal file
28
test/qxDllSample/dll2/include/export.h
Normal file
@@ -0,0 +1,28 @@
|
||||
#ifndef _QX_DLL2_EXPORT_H_
|
||||
#define _QX_DLL2_EXPORT_H_
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "../../dll1/include/export.h"
|
||||
|
||||
#ifdef _QX_BUILDING_DLL2
|
||||
#define QX_DLL2_EXPORT QX_DLL_EXPORT_HELPER
|
||||
#else // _QX_BUILDING_DLL2
|
||||
#define QX_DLL2_EXPORT QX_DLL_IMPORT_HELPER
|
||||
#endif // _QX_BUILDING_DLL2
|
||||
|
||||
#ifdef _QX_BUILDING_DLL2
|
||||
#define QX_REGISTER_HPP_QX_DLL2 QX_REGISTER_HPP_EXPORT_DLL
|
||||
#define QX_REGISTER_CPP_QX_DLL2 QX_REGISTER_CPP_EXPORT_DLL
|
||||
#define QX_REGISTER_COMPLEX_CLASS_NAME_HPP_QX_DLL2 QX_REGISTER_COMPLEX_CLASS_NAME_HPP_EXPORT_DLL
|
||||
#define QX_REGISTER_COMPLEX_CLASS_NAME_CPP_QX_DLL2 QX_REGISTER_COMPLEX_CLASS_NAME_CPP_EXPORT_DLL
|
||||
#else // _QX_BUILDING_DLL2
|
||||
#define QX_REGISTER_HPP_QX_DLL2 QX_REGISTER_HPP_IMPORT_DLL
|
||||
#define QX_REGISTER_CPP_QX_DLL2 QX_REGISTER_CPP_IMPORT_DLL
|
||||
#define QX_REGISTER_COMPLEX_CLASS_NAME_HPP_QX_DLL2 QX_REGISTER_COMPLEX_CLASS_NAME_HPP_IMPORT_DLL
|
||||
#define QX_REGISTER_COMPLEX_CLASS_NAME_CPP_QX_DLL2 QX_REGISTER_COMPLEX_CLASS_NAME_CPP_IMPORT_DLL
|
||||
#endif // _QX_BUILDING_DLL2
|
||||
|
||||
#endif // _QX_DLL2_EXPORT_H_
|
||||
12
test/qxDllSample/dll2/include/precompiled.h
Normal file
12
test/qxDllSample/dll2/include/precompiled.h
Normal file
@@ -0,0 +1,12 @@
|
||||
#ifndef _QX_DLL2_PRECOMPILED_HEADER_H_
|
||||
#define _QX_DLL2_PRECOMPILED_HEADER_H_
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <QxOrm.h>
|
||||
|
||||
#include "../include/export.h"
|
||||
|
||||
#endif // _QX_DLL2_PRECOMPILED_HEADER_H_
|
||||
7
test/qxDllSample/dll2/qt/moc/.gitignore
vendored
Normal file
7
test/qxDllSample/dll2/qt/moc/.gitignore
vendored
Normal 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
|
||||
7
test/qxDllSample/dll2/qt/rcc/src/.gitignore
vendored
Normal file
7
test/qxDllSample/dll2/qt/rcc/src/.gitignore
vendored
Normal 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
|
||||
7
test/qxDllSample/dll2/qt/ui/include/.gitignore
vendored
Normal file
7
test/qxDllSample/dll2/qt/ui/include/.gitignore
vendored
Normal 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
|
||||
7
test/qxDllSample/dll2/qt/ui/src/.gitignore
vendored
Normal file
7
test/qxDllSample/dll2/qt/ui/src/.gitignore
vendored
Normal 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
|
||||
23
test/qxDllSample/dll2/qx/Bar.qx.cpp
Normal file
23
test/qxDllSample/dll2/qx/Bar.qx.cpp
Normal file
@@ -0,0 +1,23 @@
|
||||
#include "../include/precompiled.h"
|
||||
|
||||
#include "../include/Bar.h"
|
||||
#include "../include/Foo.h"
|
||||
|
||||
#include <QxOrm_Impl.h>
|
||||
|
||||
QX_REGISTER_CPP_QX_DLL2(Bar)
|
||||
QX_PERSISTABLE_CPP(Bar)
|
||||
|
||||
namespace qx {
|
||||
template <> void register_class(QxClass<Bar> & t)
|
||||
{
|
||||
IxDataMember * pData = NULL;
|
||||
IxSqlRelation * pRelation = NULL;
|
||||
|
||||
t.setSoftDelete(qx::QxSoftDelete("deleted_at"));
|
||||
|
||||
pData = t.data(& Bar::m_sCode, "code");
|
||||
pData = t.data(& Bar::m_sValue, "value");
|
||||
|
||||
pRelation = t.relationManyToOne(& Bar::m_pFoo, "foo_id");
|
||||
}}
|
||||
20
test/qxDllSample/dll2/qx/BaseClassTrigger.qx.cpp
Normal file
20
test/qxDllSample/dll2/qx/BaseClassTrigger.qx.cpp
Normal file
@@ -0,0 +1,20 @@
|
||||
#include "../include/precompiled.h"
|
||||
|
||||
#include "../include/BaseClassTrigger.h"
|
||||
|
||||
#include <QxOrm_Impl.h>
|
||||
|
||||
QX_REGISTER_CPP_QX_DLL2(BaseClassTrigger)
|
||||
|
||||
namespace qx {
|
||||
template <> void register_class(QxClass<BaseClassTrigger> & t)
|
||||
{
|
||||
IxDataMember * pData = NULL;
|
||||
|
||||
pData = t.id(& BaseClassTrigger::m_id, "id");
|
||||
|
||||
pData = t.data(& BaseClassTrigger::m_dateCreation, "date_creation");
|
||||
pData = t.data(& BaseClassTrigger::m_dateModification, "date_modification");
|
||||
pData = t.data(& BaseClassTrigger::m_userCreation, "user_creation");
|
||||
pData = t.data(& BaseClassTrigger::m_userModification, "user_modification");
|
||||
}}
|
||||
75
test/qxDllSample/dll2/qx/CTestAll.qx.cpp
Normal file
75
test/qxDllSample/dll2/qx/CTestAll.qx.cpp
Normal file
@@ -0,0 +1,75 @@
|
||||
#include "../include/precompiled.h"
|
||||
|
||||
#include "../include/CTestAll.h"
|
||||
|
||||
#include <QxOrm_Impl.h>
|
||||
|
||||
QX_REGISTER_CPP_QX_DLL2(CTestAll)
|
||||
|
||||
namespace qx {
|
||||
template <> void register_class(QxClass<CTestAll> & t)
|
||||
{
|
||||
IxDataMember * pData = NULL;
|
||||
|
||||
pData = t.id(& CTestAll::m_lId, "m_lId");
|
||||
|
||||
pData = t.data(& CTestAll::m_oQxBool, "m_oQxBool");
|
||||
pData = t.data(& CTestAll::m_oStdString, "m_oStdString");
|
||||
pData = t.data(& CTestAll::m_oStdPair, "m_oStdPair");
|
||||
pData = t.data(& CTestAll::m_oStdVector, "m_oStdVector");
|
||||
pData = t.data(& CTestAll::m_oStdList, "m_oStdList");
|
||||
pData = t.data(& CTestAll::m_oStdMap, "m_oStdMap");
|
||||
pData = t.data(& CTestAll::m_oQString, "m_oQString");
|
||||
pData = t.data(& CTestAll::m_oQObject, "m_oQObject");
|
||||
pData = t.data(& CTestAll::m_oQByteArray, "m_oQByteArray");
|
||||
pData = t.data(& CTestAll::m_oQDate, "m_oQDate");
|
||||
pData = t.data(& CTestAll::m_oQDateTime, "m_oQDateTime");
|
||||
pData = t.data(& CTestAll::m_oQTime, "m_oQTime");
|
||||
|
||||
#ifdef _QX_ENABLE_BOOST
|
||||
pData = t.data(& CTestAll::m_oBoostTuple, "m_oBoostTuple");
|
||||
pData = t.data(& CTestAll::m_oBoostScopedPtr, "m_oBoostScopedPtr", 1);
|
||||
pData = t.data(& CTestAll::m_oBoostUnorderedMap, "m_oBoostUnorderedMap", 1);
|
||||
#endif // _QX_ENABLE_BOOST
|
||||
|
||||
#ifdef _QX_ENABLE_QT_GUI
|
||||
pData = t.data(& CTestAll::m_oQBrush, "m_oQBrush");
|
||||
pData = t.data(& CTestAll::m_oQColor, "m_oQColor");
|
||||
pData = t.data(& CTestAll::m_oQFont, "m_oQFont", 0);
|
||||
pData = t.data(& CTestAll::m_oQImage, "m_oQImage", 0);
|
||||
pData = t.data(& CTestAll::m_oQPicture, "m_oQPicture", 0);
|
||||
pData = t.data(& CTestAll::m_oQRegion, "m_oQRegion", 0);
|
||||
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
|
||||
pData = t.data(& CTestAll::m_oQMatrix, "m_oQMatrix", 1);
|
||||
#endif // (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
|
||||
#endif // _QX_ENABLE_QT_GUI
|
||||
|
||||
#if (0) /* ((! defined(Q_OS_WIN)) || (! defined(__GNUC__))) // MinGW memory bug ? */
|
||||
pData = t.data(& CTestAll::m_oQPoint, "m_oQPoint", 0);
|
||||
pData = t.data(& CTestAll::m_oQRect, "m_oQRect", 0);
|
||||
pData = t.data(& CTestAll::m_oQUrl, "m_oQUrl", 0);
|
||||
pData = t.data(& CTestAll::m_oQVariant, "m_oQVariant", 0);
|
||||
pData = t.data(& CTestAll::m_oQStringList, "m_oQStringList", 0);
|
||||
pData = t.data(& CTestAll::m_oQHash, "m_oQHash", 0);
|
||||
pData = t.data(& CTestAll::m_oQMultiHash, "m_oQMultiHash", 0);
|
||||
|
||||
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
|
||||
pData = t.data(& CTestAll::m_oQRegExp, "m_oQRegExp", 0);
|
||||
#endif // (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
|
||||
|
||||
pData = t.data(& CTestAll::m_oQMap, "m_oQMap", 1);
|
||||
pData = t.data(& CTestAll::m_oQMultiMap, "m_oQMultiMap", 1);
|
||||
pData = t.data(& CTestAll::m_oQxCollection, "m_oQxCollection", 1);
|
||||
pData = t.data(& CTestAll::m_oQList, "m_oQList", 1);
|
||||
pData = t.data(& CTestAll::m_oQVector, "m_oQVector", 1);
|
||||
pData = t.data(& CTestAll::m_oQPair, "m_oQPair", 1);
|
||||
pData = t.data(& CTestAll::m_oBoostSharedPtr, "m_oBoostSharedPtr", 1);
|
||||
pData = t.data(& CTestAll::m_oQSharedPointer, "m_oQSharedPointer", 1);
|
||||
pData = t.data(& CTestAll::m_oQSize, "m_oQSize", 1);
|
||||
|
||||
#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 0))
|
||||
pData = t.data(& CTestAll::m_oQLinkedList, "m_oQLinkedList", 1);
|
||||
#endif // (QT_VERSION < QT_VERSION_CHECK(5, 15, 0))
|
||||
|
||||
#endif // ((! defined(Q_OS_WIN)) || (! defined(__GNUC__)))
|
||||
}}
|
||||
26
test/qxDllSample/dll2/qx/CUser.qx.cpp
Normal file
26
test/qxDllSample/dll2/qx/CUser.qx.cpp
Normal file
@@ -0,0 +1,26 @@
|
||||
#include "../include/precompiled.h"
|
||||
|
||||
#include "../include/CUser.h"
|
||||
|
||||
#include <QxOrm_Impl.h>
|
||||
|
||||
QX_REGISTER_CPP_QX_DLL2(CUser)
|
||||
|
||||
namespace qx {
|
||||
template <> void register_class(QxClass<CUser> & t)
|
||||
{
|
||||
IxDataMember * pData = NULL;
|
||||
IxSqlRelation * pRelation = NULL;
|
||||
IxValidator * pValidator = NULL;
|
||||
|
||||
pData = t.data(& CUser::m_lUserId, "idUser", 0);
|
||||
pData = t.data(& CUser::m_sProfil, "profil", 0); pData->setSqlAlias("profil");
|
||||
pData = t.data(& CUser::m_bIsAdmin, "isAdmin", 1);
|
||||
pData = t.data(& CUser::m_dtModif, "dtModif", 1);
|
||||
|
||||
pRelation = t.relationManyToOne(& CUser::m_pBrother, "brother", 2);
|
||||
|
||||
QxValidatorX<CUser> * pAllValidator = t.getAllValidator();
|
||||
if (! pAllValidator) { qAssert(false); return; }
|
||||
pValidator = pAllValidator->add_RecursiveValidator<qx::test::CPerson *>("brother");
|
||||
}}
|
||||
28
test/qxDllSample/dll2/qx/Foo.qx.cpp
Normal file
28
test/qxDllSample/dll2/qx/Foo.qx.cpp
Normal file
@@ -0,0 +1,28 @@
|
||||
#include "../include/precompiled.h"
|
||||
|
||||
#include "../include/Foo.h"
|
||||
|
||||
#include <QxOrm_Impl.h>
|
||||
|
||||
QX_REGISTER_CPP_QX_DLL2(Foo)
|
||||
QX_PERSISTABLE_CPP(Foo)
|
||||
|
||||
namespace qx {
|
||||
template <> void register_class(QxClass<Foo> & t)
|
||||
{
|
||||
IxDataMember * pData = NULL;
|
||||
IxSqlRelation * pRelation = NULL;
|
||||
|
||||
pData = t.data(& Foo::m_sName, "name");
|
||||
pData = t.data(& Foo::m_sDesc, "desc");
|
||||
pData = t.data(& Foo::m_oDateNeutral, "date_neutral");
|
||||
pData = t.data(& Foo::m_oTimeNeutral, "time_neutral");
|
||||
pData = t.data(& Foo::m_oDateTimeNeutral, "dt_neutral");
|
||||
|
||||
#ifdef _QX_ENABLE_BOOST
|
||||
pData = t.data(& Foo::m_optInt, "optional_int");
|
||||
pData = t.data(& Foo::m_optString, "optional_string");
|
||||
#endif // _QX_ENABLE_BOOST
|
||||
|
||||
pRelation = t.relationOneToMany(& Foo::m_pBarX, "lstBar", "foo_id");
|
||||
}}
|
||||
7
test/qxDllSample/dll2/release/.gitignore
vendored
Normal file
7
test/qxDllSample/dll2/release/.gitignore
vendored
Normal 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
|
||||
12
test/qxDllSample/dll2/src/Bar.cpp
Normal file
12
test/qxDllSample/dll2/src/Bar.cpp
Normal file
@@ -0,0 +1,12 @@
|
||||
#include "../include/precompiled.h"
|
||||
|
||||
#include "../include/Bar.h"
|
||||
#include "../include/Foo.h"
|
||||
|
||||
#include <QxOrm_Impl.h>
|
||||
|
||||
void Bar::setFoo(long l)
|
||||
{
|
||||
m_pFoo.reset(new Foo());
|
||||
m_pFoo->setId(l);
|
||||
}
|
||||
21
test/qxDllSample/dll2/src/BaseClassTrigger.cpp
Normal file
21
test/qxDllSample/dll2/src/BaseClassTrigger.cpp
Normal file
@@ -0,0 +1,21 @@
|
||||
#include "../include/precompiled.h"
|
||||
|
||||
#include "../include/BaseClassTrigger.h"
|
||||
|
||||
#include <QxOrm_Impl.h>
|
||||
|
||||
void BaseClassTrigger::onBeforeInsert(qx::dao::detail::IxDao_Helper * dao)
|
||||
{
|
||||
Q_UNUSED(dao);
|
||||
m_dateCreation = QDateTime::currentDateTime();
|
||||
m_dateModification = QDateTime::currentDateTime();
|
||||
m_userCreation = "current_user_1";
|
||||
m_userModification = "current_user_1";
|
||||
}
|
||||
|
||||
void BaseClassTrigger::onBeforeUpdate(qx::dao::detail::IxDao_Helper * dao)
|
||||
{
|
||||
Q_UNUSED(dao);
|
||||
m_dateModification = QDateTime::currentDateTime();
|
||||
m_userModification = "current_user_2";
|
||||
}
|
||||
89
test/qxDllSample/dll2/src/CTestAll.cpp
Normal file
89
test/qxDllSample/dll2/src/CTestAll.cpp
Normal file
@@ -0,0 +1,89 @@
|
||||
#include "../include/precompiled.h"
|
||||
|
||||
#include "../include/CTestAll.h"
|
||||
|
||||
#include <QxOrm_Impl.h>
|
||||
|
||||
void CTestAll::init()
|
||||
{
|
||||
m_lId = 56;
|
||||
m_oQxBool = qx_bool(true, "qx_bool description");
|
||||
m_oStdString = "std::string text";
|
||||
|
||||
m_oQString = "QString text\nwith a new line";
|
||||
m_oQDate = QDate::currentDate();
|
||||
m_oQDateTime = QDateTime::currentDateTime();
|
||||
m_oQTime = QTime::currentTime();
|
||||
m_oQColor = QColor(255, 200, 200);
|
||||
m_oQFont.setBold(true);
|
||||
m_oQFont.setFamily("font family from qx test");
|
||||
m_oQPoint = QPoint(8, 11);
|
||||
m_oQRect = QRect(QPoint(52, 3), QPoint(574, 1112));
|
||||
m_oQSize = QSize(1024, 768);
|
||||
m_oQUrl = QUrl("www.qxorm.com");
|
||||
m_oQStringList << "str1" << "str2" << "str3" << "str4";
|
||||
m_oQByteArray = QByteArray("QByteArray t\0ext\nwith a new line\0and null multi\0ple null char\0", 55);
|
||||
m_oQVariant = QVariant(0.437);
|
||||
m_oQObject.setProperty("prop_1", 1);
|
||||
m_oQObject.setProperty("prop_2", 2);
|
||||
|
||||
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
|
||||
m_oQRegExp = QRegExp("qt reg exp");
|
||||
#endif // (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
|
||||
|
||||
QSharedPointer<CUser> u1(new CUser());
|
||||
QSharedPointer<CUser> u2(new CUser());
|
||||
|
||||
m_oStdPair = std::make_pair(QPoint(2, 6), QRect(99, 55, 44, 22));
|
||||
m_oStdList.push_back(QDateTime());
|
||||
m_oStdList.push_back(QDateTime::currentDateTime());
|
||||
m_oStdList.push_back(QDateTime());
|
||||
m_oStdMap.insert(std::make_pair("1", u1));
|
||||
m_oStdMap.insert(std::make_pair("2", u2));
|
||||
|
||||
m_oStdVector.push_back(QSharedPointer<qx::test::CPerson>(new qx::test::CPerson()));
|
||||
m_oStdVector.push_back(QSharedPointer<qx::test::CPerson>(new CUser()));
|
||||
}
|
||||
|
||||
void CTestAll::terminate()
|
||||
{
|
||||
Q_FOREACH(CUser * p2, m_oQVector) { if (p2) { delete p2; } }
|
||||
}
|
||||
|
||||
void CTestAll::test()
|
||||
{
|
||||
std::shared_ptr<CTestAll> o1; o1.reset(new CTestAll());
|
||||
std::shared_ptr<CTestAll> o2; o2.reset(new CTestAll());
|
||||
|
||||
qx::QxCollection<long, std::shared_ptr<CTestAll> > coll;
|
||||
coll.insert(0, o1);
|
||||
coll.insert(1, o2);
|
||||
|
||||
#if _QX_SERIALIZE_POLYMORPHIC
|
||||
qx::serialization::polymorphic_xml::to_file(coll, "test_all.xml");
|
||||
qx::serialization::polymorphic_xml::from_file(coll, "test_all.xml");
|
||||
#endif // _QX_SERIALIZE_POLYMORPHIC
|
||||
|
||||
#if _QX_SERIALIZE_BINARY
|
||||
qx::serialization::binary::to_file(coll, "test_all.bin");
|
||||
qx::serialization::binary::from_file(coll, "test_all.bin");
|
||||
#endif // _QX_SERIALIZE_BINARY
|
||||
|
||||
#if _QX_SERIALIZE_XML
|
||||
qx::serialization::xml::to_file(coll, "test_all.xml");
|
||||
qx::serialization::xml::from_file(coll, "test_all.xml");
|
||||
#endif // _QX_SERIALIZE_XML
|
||||
|
||||
#if _QX_SERIALIZE_PORTABLE_BINARY
|
||||
qx::serialization::portable_binary::to_file(coll, "test_all.bin2", 0);
|
||||
qx::serialization::portable_binary::from_file(coll, "test_all.bin2", 0);
|
||||
#endif // _QX_SERIALIZE_PORTABLE_BINARY
|
||||
|
||||
#ifndef _QX_NO_JSON
|
||||
qx::serialization::json::to_file(coll, "test_all.json");
|
||||
qx::serialization::json::from_file(coll, "test_all.json");
|
||||
#endif // _QX_NO_JSON
|
||||
|
||||
qx::clone(coll);
|
||||
qx::create("CTestAll");
|
||||
}
|
||||
126
test/qxDllSample/dll2/src/CUser.cpp
Normal file
126
test/qxDllSample/dll2/src/CUser.cpp
Normal file
@@ -0,0 +1,126 @@
|
||||
#include "../include/precompiled.h"
|
||||
|
||||
#include "../include/CUser.h"
|
||||
|
||||
#include <QxOrm_Impl.h>
|
||||
|
||||
void CUser::test()
|
||||
{
|
||||
std::shared_ptr<QObject> ptrTmp;
|
||||
ptrTmp.reset(new CUser());
|
||||
qx::clone(ptrTmp);
|
||||
|
||||
#if _QX_SERIALIZE_POLYMORPHIC
|
||||
qx::serialization::polymorphic_xml::to_file(ptrTmp, "pointer_from_CUser.xml");
|
||||
qx::serialization::polymorphic_xml::from_file(ptrTmp, "pointer_from_CUser.xml");
|
||||
#endif // _QX_SERIALIZE_POLYMORPHIC
|
||||
|
||||
#if _QX_SERIALIZE_XML
|
||||
qx::serialization::xml::to_file(ptrTmp, "pointer_from_CUser.xml");
|
||||
qx::serialization::xml::from_file(ptrTmp, "pointer_from_CUser.xml");
|
||||
#endif // _QX_SERIALIZE_XML
|
||||
|
||||
#ifndef _QX_NO_JSON
|
||||
qx::serialization::json::to_file(ptrTmp, "pointer_from_CUser.json");
|
||||
qx::serialization::json::from_file(ptrTmp, "pointer_from_CUser.json");
|
||||
#endif // _QX_NO_JSON
|
||||
|
||||
qx::test::CPerson person;
|
||||
qx::clone(person);
|
||||
qx::create("qx::test::CPerson");
|
||||
|
||||
#if _QX_SERIALIZE_POLYMORPHIC
|
||||
qx::serialization::polymorphic_binary::to_file(person, "person.bin");
|
||||
qx::serialization::polymorphic_binary::from_file(person, "person.bin");
|
||||
qx::serialization::polymorphic_xml::to_file(person, "person.xml");
|
||||
qx::serialization::polymorphic_xml::from_file(person, "person.xml");
|
||||
#endif // _QX_SERIALIZE_POLYMORPHIC
|
||||
|
||||
#if _QX_SERIALIZE_BINARY
|
||||
qx::serialization::binary::to_file(person, "person.bin");
|
||||
qx::serialization::binary::from_file(person, "person.bin");
|
||||
#endif // _QX_SERIALIZE_BINARY
|
||||
|
||||
#if _QX_SERIALIZE_TEXT
|
||||
qx::serialization::text::to_file(person, "person.txt");
|
||||
qx::serialization::text::from_file(person, "person.txt");
|
||||
#endif // _QX_SERIALIZE_TEXT
|
||||
|
||||
#if _QX_SERIALIZE_XML
|
||||
qx::serialization::xml::to_file(person, "person.xml");
|
||||
qx::serialization::xml::from_file(person, "person.xml");
|
||||
#endif // _QX_SERIALIZE_XML
|
||||
|
||||
#ifndef _QX_NO_JSON
|
||||
qx::serialization::json::to_file(person, "person.json");
|
||||
qx::serialization::json::from_file(person, "person.json");
|
||||
#endif // _QX_NO_JSON
|
||||
|
||||
#if _QX_SERIALIZE_PORTABLE_BINARY
|
||||
qx::serialization::portable_binary::to_file(person, "person.bin2", 0);
|
||||
qx::serialization::portable_binary::from_file(person, "person.bin2", 0);
|
||||
#endif // _QX_SERIALIZE_PORTABLE_BINARY
|
||||
|
||||
#ifdef _QX_ENABLE_BOOST_SERIALIZATION
|
||||
qx::serialization::to_string(person);
|
||||
qx::serialization::to_file_compressed(person, "person.zip");
|
||||
qx::serialization::from_file_compressed(person, "person.zip");
|
||||
#else // _QX_ENABLE_BOOST_SERIALIZATION
|
||||
qx::serialization::qt::to_string(person);
|
||||
qx::serialization::qt::to_file_compressed(person, "person.zip");
|
||||
qx::serialization::qt::from_file_compressed(person, "person.zip");
|
||||
#endif // _QX_ENABLE_BOOST_SERIALIZATION
|
||||
|
||||
//--------------------------------
|
||||
|
||||
CUser user;
|
||||
qx::clone(user);
|
||||
qx::create("CUser");
|
||||
|
||||
#if _QX_SERIALIZE_POLYMORPHIC
|
||||
qx::serialization::polymorphic_binary::to_file(user, "user.bin");
|
||||
qx::serialization::polymorphic_binary::from_file(user, "user.bin");
|
||||
qx::serialization::polymorphic_xml::to_file(user, "user.xml");
|
||||
qx::serialization::polymorphic_xml::from_file(user, "user.xml");
|
||||
#endif // _QX_SERIALIZE_POLYMORPHIC
|
||||
|
||||
#if _QX_SERIALIZE_BINARY
|
||||
qx::serialization::binary::to_file(user, "user.bin");
|
||||
qx::serialization::binary::from_file(user, "user.bin");
|
||||
#endif // _QX_SERIALIZE_BINARY
|
||||
|
||||
#if _QX_SERIALIZE_TEXT
|
||||
qx::serialization::text::to_file(user, "user.txt");
|
||||
qx::serialization::text::from_file(user, "user.txt");
|
||||
#endif // _QX_SERIALIZE_TEXT
|
||||
|
||||
#if _QX_SERIALIZE_XML
|
||||
qx::serialization::xml::to_file(user, "user.xml");
|
||||
qx::serialization::xml::from_file(user, "user.xml");
|
||||
#endif // _QX_SERIALIZE_XML
|
||||
|
||||
#ifndef _QX_NO_JSON
|
||||
qx::serialization::json::to_file(user, "user.json");
|
||||
qx::serialization::json::from_file(user, "user.json");
|
||||
#endif // _QX_NO_JSON
|
||||
|
||||
#if _QX_SERIALIZE_PORTABLE_BINARY
|
||||
qx::serialization::portable_binary::to_file(user, "user.bin2", 0);
|
||||
qx::serialization::portable_binary::from_file(user, "user.bin2", 0);
|
||||
#endif // _QX_SERIALIZE_PORTABLE_BINARY
|
||||
|
||||
#ifdef _QX_ENABLE_BOOST_SERIALIZATION
|
||||
qx::serialization::to_string(user);
|
||||
qx::serialization::to_file_compressed(user, "user.zip");
|
||||
qx::serialization::from_file_compressed(user, "user.zip");
|
||||
#else // _QX_ENABLE_BOOST_SERIALIZATION
|
||||
qx::serialization::qt::to_string(user);
|
||||
qx::serialization::qt::to_file_compressed(user, "user.zip");
|
||||
qx::serialization::qt::from_file_compressed(user, "user.zip");
|
||||
#endif // _QX_ENABLE_BOOST_SERIALIZATION
|
||||
|
||||
//--------------------------------
|
||||
|
||||
qx::test::CPerson * pPerson = new qx::test::CPerson(); // You find a memory leak !!!
|
||||
Q_UNUSED(pPerson);
|
||||
}
|
||||
5
test/qxDllSample/dll2/src/Foo.cpp
Normal file
5
test/qxDllSample/dll2/src/Foo.cpp
Normal file
@@ -0,0 +1,5 @@
|
||||
#include "../include/precompiled.h"
|
||||
|
||||
#include "../include/Foo.h"
|
||||
|
||||
#include <QxOrm_Impl.h>
|
||||
20
test/qxDllSample/dll2/src/main.cpp
Normal file
20
test/qxDllSample/dll2/src/main.cpp
Normal 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("dll2.DllMain() ---> DLL_PROCESS_ATTACH\n"); break;
|
||||
case DLL_PROCESS_DETACH: ::OutputDebugStringA("dll2.DllMain() ---> DLL_PROCESS_DETACH\n"); break;
|
||||
case DLL_THREAD_ATTACH: ::OutputDebugStringA("dll2.DllMain() ---> DLL_THREAD_ATTACH\n"); break;
|
||||
case DLL_THREAD_DETACH: ::OutputDebugStringA("dll2.DllMain() ---> DLL_THREAD_DETACH\n"); break;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif // _MSC_VER
|
||||
50
test/qxDllSample/exe/CMakeLists.txt
Normal file
50
test/qxDllSample/exe/CMakeLists.txt
Normal file
@@ -0,0 +1,50 @@
|
||||
cmake_minimum_required(VERSION 3.1)
|
||||
|
||||
project(exe LANGUAGES CXX)
|
||||
|
||||
include(../../../QxOrm.cmake)
|
||||
|
||||
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core Sql Gui Widgets REQUIRED)
|
||||
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
set(CMAKE_DEBUG_POSTFIX "d")
|
||||
|
||||
set(HEADERS
|
||||
./include/precompiled.h
|
||||
./include/export.h
|
||||
)
|
||||
|
||||
set(SRCS
|
||||
./src/main.cpp
|
||||
)
|
||||
|
||||
add_executable(exe ${SRCS} ${HEADERS})
|
||||
|
||||
target_compile_definitions(exe PRIVATE -D_QX_BUILDING_EXE)
|
||||
|
||||
if(COMMAND target_precompile_headers)
|
||||
target_precompile_headers(exe PRIVATE ./include/precompiled.h)
|
||||
endif() # (COMMAND target_precompile_headers)
|
||||
|
||||
target_link_libraries(exe ${QX_LIBRARIES} Qt${QT_VERSION_MAJOR}::Gui Qt${QT_VERSION_MAJOR}::Widgets QxOrm dll1 dll2)
|
||||
|
||||
set_target_properties(exe 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"
|
||||
)
|
||||
|
||||
set_target_properties(exe PROPERTIES DEBUG_POSTFIX ${CMAKE_DEBUG_POSTFIX})
|
||||
7
test/qxDllSample/exe/debug/.gitignore
vendored
Normal file
7
test/qxDllSample/exe/debug/.gitignore
vendored
Normal 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
|
||||
39
test/qxDllSample/exe/exe.pro
Normal file
39
test/qxDllSample/exe/exe.pro
Normal file
@@ -0,0 +1,39 @@
|
||||
include(../../../QxOrm.pri)
|
||||
|
||||
TEMPLATE = app
|
||||
DEFINES += _QX_BUILDING_EXE
|
||||
INCLUDEPATH += ../../../../QxOrm/include/
|
||||
DESTDIR = ../../../../QxOrm/test/_bin/
|
||||
|
||||
QT += gui
|
||||
greaterThan(QT_MAJOR_VERSION, 4) { QT += widgets }
|
||||
|
||||
!contains(DEFINES, _QX_NO_PRECOMPILED_HEADER) {
|
||||
PRECOMPILED_HEADER = ./include/precompiled.h
|
||||
} # !contains(DEFINES, _QX_NO_PRECOMPILED_HEADER)
|
||||
|
||||
macx:CONFIG-=app_bundle
|
||||
|
||||
CONFIG(debug, debug|release) {
|
||||
TARGET = exed
|
||||
} else {
|
||||
TARGET = exe
|
||||
} # CONFIG(debug, debug|release)
|
||||
|
||||
LIBS += -L"../../../../QxOrm/lib"
|
||||
LIBS += -L"../../../../QxOrm/test/_bin"
|
||||
|
||||
CONFIG(debug, debug|release) {
|
||||
LIBS += -l"QxOrmd"
|
||||
LIBS += -l"dll1d"
|
||||
LIBS += -l"dll2d"
|
||||
} else {
|
||||
LIBS += -l"QxOrm"
|
||||
LIBS += -l"dll1"
|
||||
LIBS += -l"dll2"
|
||||
} # CONFIG(debug, debug|release)
|
||||
|
||||
HEADERS += ./include/precompiled.h
|
||||
HEADERS += ./include/export.h
|
||||
|
||||
SOURCES += ./src/main.cpp
|
||||
23
test/qxDllSample/exe/include/export.h
Normal file
23
test/qxDllSample/exe/include/export.h
Normal file
@@ -0,0 +1,23 @@
|
||||
#ifndef _QX_EXE_EXPORT_H_
|
||||
#define _QX_EXE_EXPORT_H_
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "../../dll1/include/export.h"
|
||||
#include "../../dll2/include/export.h"
|
||||
|
||||
#ifdef _QX_BUILDING_EXE
|
||||
#define QX_REGISTER_HPP_QX_EXE QX_REGISTER_HPP_EXPORT_DLL
|
||||
#define QX_REGISTER_CPP_QX_EXE QX_REGISTER_CPP_EXPORT_DLL
|
||||
#define QX_REGISTER_COMPLEX_CLASS_NAME_HPP_QX_EXE QX_REGISTER_COMPLEX_CLASS_NAME_HPP_EXPORT_DLL
|
||||
#define QX_REGISTER_COMPLEX_CLASS_NAME_CPP_QX_EXE QX_REGISTER_COMPLEX_CLASS_NAME_CPP_EXPORT_DLL
|
||||
#else // _QX_BUILDING_EXE
|
||||
#define QX_REGISTER_HPP_QX_EXE QX_REGISTER_HPP_IMPORT_DLL
|
||||
#define QX_REGISTER_CPP_QX_EXE QX_REGISTER_CPP_IMPORT_DLL
|
||||
#define QX_REGISTER_COMPLEX_CLASS_NAME_HPP_QX_EXE QX_REGISTER_COMPLEX_CLASS_NAME_HPP_EXPORT_DLL
|
||||
#define QX_REGISTER_COMPLEX_CLASS_NAME_CPP_QX_EXE QX_REGISTER_COMPLEX_CLASS_NAME_CPP_EXPORT_DLL
|
||||
#endif // _QX_BUILDING_EXE
|
||||
|
||||
#endif // _QX_EXE_EXPORT_H_
|
||||
14
test/qxDllSample/exe/include/precompiled.h
Normal file
14
test/qxDllSample/exe/include/precompiled.h
Normal file
@@ -0,0 +1,14 @@
|
||||
#ifndef _QX_EXE_PRECOMPILED_HEADER_H_
|
||||
#define _QX_EXE_PRECOMPILED_HEADER_H_
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <QxOrm.h>
|
||||
#include <QxModelView.h>
|
||||
#include <QxDaoRepository.h>
|
||||
|
||||
#include "../include/export.h"
|
||||
|
||||
#endif // _QX_EXE_PRECOMPILED_HEADER_H_
|
||||
7
test/qxDllSample/exe/qt/moc/.gitignore
vendored
Normal file
7
test/qxDllSample/exe/qt/moc/.gitignore
vendored
Normal 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
|
||||
7
test/qxDllSample/exe/qt/rcc/src/.gitignore
vendored
Normal file
7
test/qxDllSample/exe/qt/rcc/src/.gitignore
vendored
Normal 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
|
||||
7
test/qxDllSample/exe/qt/ui/include/.gitignore
vendored
Normal file
7
test/qxDllSample/exe/qt/ui/include/.gitignore
vendored
Normal 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
|
||||
7
test/qxDllSample/exe/qt/ui/src/.gitignore
vendored
Normal file
7
test/qxDllSample/exe/qt/ui/src/.gitignore
vendored
Normal 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
|
||||
7
test/qxDllSample/exe/qx/.gitignore
vendored
Normal file
7
test/qxDllSample/exe/qx/.gitignore
vendored
Normal 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
|
||||
7
test/qxDllSample/exe/release/.gitignore
vendored
Normal file
7
test/qxDllSample/exe/release/.gitignore
vendored
Normal 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
|
||||
555
test/qxDllSample/exe/src/main.cpp
Normal file
555
test/qxDllSample/exe/src/main.cpp
Normal file
@@ -0,0 +1,555 @@
|
||||
#include <QtCore/qglobal.h>
|
||||
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
|
||||
#include <QtWidgets/qapplication.h>
|
||||
#else // (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
|
||||
#include <QtGui/qapplication.h>
|
||||
#endif // (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
|
||||
|
||||
#include "../include/precompiled.h"
|
||||
|
||||
#include "../../dll1/include/CPerson.h"
|
||||
#include "../../dll1/include/TestQtProperty.h"
|
||||
|
||||
#include "../../dll2/include/CUser.h"
|
||||
#include "../../dll2/include/CTestAll.h"
|
||||
#include "../../dll2/include/Bar.h"
|
||||
#include "../../dll2/include/Foo.h"
|
||||
|
||||
#include <QxOrm_Impl.h>
|
||||
|
||||
void test_fct() { qDebug("[QxOrm] %s", "'test_fct()' called by 'qx::IxFunction()'"); }
|
||||
struct test_class_fct { int class_fct() { qDebug("[QxOrm] %s", "'test_class_fct::class_fct()' called by 'qx::IxFunction()'"); return 123; }; };
|
||||
|
||||
int main(int argc, char * argv[])
|
||||
{
|
||||
QApplication app(argc, argv);
|
||||
|
||||
//--------------------------------
|
||||
|
||||
std::shared_ptr<QObject> ptrTmp;
|
||||
ptrTmp.reset(new CUser());
|
||||
qx::clone(ptrTmp);
|
||||
|
||||
#if _QX_SERIALIZE_POLYMORPHIC
|
||||
qx::serialization::polymorphic_xml::to_file(ptrTmp, "pointer_from_main.xml");
|
||||
qx::serialization::polymorphic_xml::from_file(ptrTmp, "pointer_from_main.xml");
|
||||
#endif // _QX_SERIALIZE_POLYMORPHIC
|
||||
|
||||
#if _QX_SERIALIZE_XML
|
||||
qx::serialization::xml::to_file(ptrTmp, "pointer_from_main.xml");
|
||||
qx::serialization::xml::from_file(ptrTmp, "pointer_from_main.xml");
|
||||
#endif // _QX_SERIALIZE_XML
|
||||
|
||||
#ifndef _QX_NO_JSON
|
||||
qx::serialization::json::to_file(ptrTmp, "pointer_from_main.json");
|
||||
qx::serialization::json::from_file(ptrTmp, "pointer_from_main.json");
|
||||
#endif // _QX_NO_JSON
|
||||
|
||||
//--------------------------------
|
||||
|
||||
qx::test::CPerson person;
|
||||
std::shared_ptr<qx::test::CPerson> personClone = qx::clone(person);
|
||||
qx::any a = qx::create("qx::test::CPerson");
|
||||
|
||||
#if _QX_SERIALIZE_POLYMORPHIC
|
||||
qx::serialization::polymorphic_binary::to_file(person, "person.bin");
|
||||
qx::serialization::polymorphic_binary::from_file(person, "person.bin");
|
||||
qx::serialization::polymorphic_xml::to_file(person, "person.xml");
|
||||
qx::serialization::polymorphic_xml::from_file(person, "person.xml");
|
||||
#endif // _QX_SERIALIZE_POLYMORPHIC
|
||||
|
||||
#if _QX_SERIALIZE_BINARY
|
||||
qx::serialization::binary::to_file(person, "person.bin");
|
||||
qx::serialization::binary::from_file(person, "person.bin");
|
||||
#endif // _QX_SERIALIZE_BINARY
|
||||
|
||||
#if _QX_SERIALIZE_TEXT
|
||||
qx::serialization::text::to_file(person, "person.txt");
|
||||
qx::serialization::text::from_file(person, "person.txt");
|
||||
#endif // _QX_SERIALIZE_TEXT
|
||||
|
||||
#if _QX_SERIALIZE_XML
|
||||
qx::serialization::xml::to_file(person, "person.xml");
|
||||
qx::serialization::xml::from_file(person, "person.xml");
|
||||
#endif // _QX_SERIALIZE_XML
|
||||
|
||||
#ifndef _QX_NO_JSON
|
||||
qx::serialization::json::to_file(person, "person.json");
|
||||
qx::serialization::json::from_file(person, "person.json");
|
||||
#endif // _QX_NO_JSON
|
||||
|
||||
#if _QX_SERIALIZE_PORTABLE_BINARY
|
||||
qx::serialization::portable_binary::to_file(person, "person.bin2", 0);
|
||||
qx::serialization::portable_binary::from_file(person, "person.bin2", 0);
|
||||
#endif // _QX_SERIALIZE_PORTABLE_BINARY
|
||||
|
||||
#ifdef _QX_ENABLE_BOOST_SERIALIZATION
|
||||
qx::serialization::to_string(person);
|
||||
qx::serialization::to_file_compressed(person, "person.zip");
|
||||
qx::serialization::from_file_compressed(person, "person.zip");
|
||||
#else // _QX_ENABLE_BOOST_SERIALIZATION
|
||||
qx::serialization::qt::to_string(person);
|
||||
qx::serialization::qt::to_file_compressed(person, "person.zip");
|
||||
qx::serialization::qt::from_file_compressed(person, "person.zip");
|
||||
#endif // _QX_ENABLE_BOOST_SERIALIZATION
|
||||
|
||||
//--------------------------------
|
||||
|
||||
CUser user;
|
||||
std::shared_ptr<CUser> userClone = qx::clone(user);
|
||||
qx::create("CUserXXX");
|
||||
|
||||
qx::cache::max_cost(2);
|
||||
qx::cache::set("user", userClone);
|
||||
qx::cache::set("object", ptrTmp);
|
||||
qx::cache::set("person", personClone);
|
||||
qAssert(qx::cache::count() == 2);
|
||||
ptrTmp = qx::cache::get< std::shared_ptr<QObject> >("object");
|
||||
qx_bool bCacheOk = qx::cache::get("user", userClone);
|
||||
qAssert(! bCacheOk && (ptrTmp.get() != NULL));
|
||||
|
||||
std::shared_ptr<qx::test::CPerson> personValidate = qx::clone(person);
|
||||
if (! personValidate) { personValidate.reset(new qx::test::CPerson()); }
|
||||
personValidate->setLastName("admin");
|
||||
personValidate->setDouble(305.86);
|
||||
qx::QxInvalidValueX invalidValues = qx::validate(personValidate);
|
||||
QString sInvalidValues = invalidValues.text();
|
||||
qDebug("[QxOrm] test 'QxValidator' module :\n%s", qPrintable(sInvalidValues));
|
||||
|
||||
#if _QX_SERIALIZE_POLYMORPHIC
|
||||
qx::serialization::polymorphic_binary::to_file(user, "user.bin");
|
||||
qx::serialization::polymorphic_binary::from_file(user, "user.bin");
|
||||
qx::serialization::polymorphic_xml::to_file(user, "user.xml");
|
||||
qx::serialization::polymorphic_xml::from_file(user, "user.xml");
|
||||
#endif // _QX_SERIALIZE_POLYMORPHIC
|
||||
|
||||
#if _QX_SERIALIZE_BINARY
|
||||
qx::serialization::binary::to_file(user, "user.bin");
|
||||
qx::serialization::binary::from_file(user, "user.bin");
|
||||
#endif // _QX_SERIALIZE_BINARY
|
||||
|
||||
#if _QX_SERIALIZE_TEXT
|
||||
qx::serialization::text::to_file(user, "user.txt");
|
||||
qx::serialization::text::from_file(user, "user.txt");
|
||||
#endif // _QX_SERIALIZE_TEXT
|
||||
|
||||
#if _QX_SERIALIZE_XML
|
||||
qx::serialization::xml::to_file(user, "user.xml");
|
||||
qx::serialization::xml::from_file(user, "user.xml");
|
||||
#endif // _QX_SERIALIZE_XML
|
||||
|
||||
#ifndef _QX_NO_JSON
|
||||
qx::serialization::json::to_file(user, "user.json");
|
||||
qx::serialization::json::from_file(user, "user.json");
|
||||
#endif // _QX_NO_JSON
|
||||
|
||||
#if _QX_SERIALIZE_PORTABLE_BINARY
|
||||
qx::serialization::portable_binary::to_file(user, "user.bin2", 0);
|
||||
qx::serialization::portable_binary::from_file(user, "user.bin2", 0);
|
||||
#endif // _QX_SERIALIZE_PORTABLE_BINARY
|
||||
|
||||
#ifdef _QX_ENABLE_BOOST_SERIALIZATION
|
||||
qx::serialization::to_string(user);
|
||||
qx::serialization::to_file_compressed(user, "user.zip");
|
||||
qx::serialization::from_file_compressed(user, "user.zip");
|
||||
#else // _QX_ENABLE_BOOST_SERIALIZATION
|
||||
qx::serialization::qt::to_string(user);
|
||||
qx::serialization::qt::to_file_compressed(user, "user.zip");
|
||||
qx::serialization::qt::from_file_compressed(user, "user.zip");
|
||||
#endif // _QX_ENABLE_BOOST_SERIALIZATION
|
||||
|
||||
//--------------------------------
|
||||
|
||||
qx::any resultInvoke;
|
||||
CUser * pUser = new CUser(); // You find a memory leak !!!
|
||||
pUser->test();
|
||||
qx_bool bInvokeOk = qx::QxClass<CUser>::invoke("fct_getPersonId", pUser); qAssert(bInvokeOk);
|
||||
bInvokeOk = qx::QxClassX::invoke("CUser", "fct_getPersonId", pUser); qAssert(bInvokeOk);
|
||||
bInvokeOk = qx::QxClassX::invokeStatic("CUser", "fct_testStaticFct", "182", (& resultInvoke)); qAssert(bInvokeOk.getValue() && (qx::any_cast<int>(resultInvoke) == 182));
|
||||
|
||||
// Other way to invoke a function with parameters encapsulated in a list of qx::any : std::vector<qx::any>
|
||||
resultInvoke = qx::any();
|
||||
std::vector<qx::any> lstParams;
|
||||
QString invokeParam1 = "238";
|
||||
lstParams.push_back(invokeParam1);
|
||||
bInvokeOk = qx::QxClassX::invokeStatic("CUser", "fct_testStaticFct", lstParams, (& resultInvoke));
|
||||
qAssert(bInvokeOk.getValue() && (qx::any_cast<int>(resultInvoke) == 238));
|
||||
|
||||
//--------------------------------
|
||||
|
||||
typedef QSharedPointer<CUser> CUser_ptr;
|
||||
qx::QxCollection<long, CUser_ptr> coll;
|
||||
CUser_ptr p1(new CUser());
|
||||
CUser_ptr p2(new CUser());
|
||||
coll.insert(0, p1);
|
||||
coll.insert(1, p2);
|
||||
|
||||
{
|
||||
// Test qx::IxCollection interface using a smart-pointer (test also qx::any_cast_dynamic<T>::get(...) function)
|
||||
QSharedPointer<QObject> pTestIxCollection = coll._get< QSharedPointer<QObject> >(1);
|
||||
Q_UNUSED(pTestIxCollection);
|
||||
}
|
||||
|
||||
#if _QX_SERIALIZE_POLYMORPHIC
|
||||
qx::serialization::polymorphic_xml::to_file(coll, "collection.xml");
|
||||
#endif // _QX_SERIALIZE_POLYMORPHIC
|
||||
|
||||
#if _QX_SERIALIZE_XML
|
||||
qx::serialization::xml::to_file(coll, "collection.xml");
|
||||
#endif // _QX_SERIALIZE_XML
|
||||
|
||||
#ifndef _QX_NO_JSON
|
||||
qx::serialization::json::to_file(coll, "collection.json");
|
||||
#endif // _QX_NO_JSON
|
||||
|
||||
//--------------------------------
|
||||
|
||||
qx::any any_ret;
|
||||
qx::IxFunction_ptr pFct1 = qx::function::bind_fct_0<void, void>(& test_fct);
|
||||
qx_bool bInvoke = pFct1->invoke();
|
||||
|
||||
qx::IxFunction_ptr pFct2 = qx::function::bind_member_fct_0<test_class_fct, int>(std::mem_fn(& test_class_fct::class_fct)); // 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)
|
||||
test_class_fct o_test_class_fct;
|
||||
bInvoke = pFct2->invoke(& o_test_class_fct, "", (& any_ret));
|
||||
int iReturnByInvoke = qx::any_cast<int>(any_ret);
|
||||
Q_UNUSED(iReturnByInvoke);
|
||||
|
||||
//--------------------------------
|
||||
|
||||
CTestAll::test();
|
||||
|
||||
//--------------------------------
|
||||
|
||||
QString sTestCvt = qx::cvt::to_string(18, "%03d");
|
||||
sTestCvt = qx::cvt::to_string(int(4));
|
||||
sTestCvt = qx::cvt::to_string(QDateTime::currentDateTime());
|
||||
sTestCvt = qx::cvt::to_string(pUser);
|
||||
sTestCvt = qx::cvt::to_string(p1, "%08d");
|
||||
QObject dummy_01; Q_UNUSED(dummy_01); // sTestCvt = qx::cvt::to_string(dummy_01);
|
||||
CTestAll dummy_02; sTestCvt = qx::cvt::to_string(dummy_02);
|
||||
|
||||
qx_bool bCvtOk = qx::cvt::from_string("34", pUser);
|
||||
sTestCvt = qx::cvt::to_string(pUser);
|
||||
|
||||
QVariant sTestCvtVar = qx::cvt::to_variant(QTime::currentTime());
|
||||
QVariant dummy_03; bCvtOk = qx::cvt::from_variant(dummy_03, p1);
|
||||
|
||||
QVector< std::shared_ptr<CUser> > lstCvtTest;
|
||||
std::shared_ptr<CUser> pp1; pp1.reset(new CUser()); lstCvtTest.push_back(pp1);
|
||||
std::shared_ptr<CUser> pp2; lstCvtTest.push_back(pp2);
|
||||
std::shared_ptr<CUser> pp3; pp3.reset(new CUser()); lstCvtTest.push_back(pp3);
|
||||
sTestCvt = qx::cvt::to_string(lstCvtTest);
|
||||
lstCvtTest.remove(1);
|
||||
bCvtOk = qx::cvt::from_string(sTestCvt, lstCvtTest);
|
||||
qAssert(lstCvtTest.size() == 3);
|
||||
|
||||
//--------------------------------
|
||||
|
||||
QFile::remove("./database.db");
|
||||
|
||||
qx::QxSqlDatabase::getSingleton()->setDriverName("QSQLITE");
|
||||
qx::QxSqlDatabase::getSingleton()->setDatabaseName("database.db");
|
||||
qx::QxSqlDatabase::getSingleton()->setHostName("localhost");
|
||||
qx::QxSqlDatabase::getSingleton()->setUserName("root");
|
||||
qx::QxSqlDatabase::getSingleton()->setPassword("");
|
||||
qx::QxSqlDatabase::getSingleton()->setSqlPlaceHolderStyle(qx::QxSqlDatabase::ph_style_2_point_name);
|
||||
qx::QxSqlDatabase::getSingleton()->setTraceSqlQuery(true);
|
||||
qx::QxSqlDatabase::getSingleton()->setTraceSqlRecord(false);
|
||||
|
||||
// Only for debug purpose : assert if invalid offset detected fetching a relation
|
||||
qx::QxSqlDatabase::getSingleton()->setVerifyOffsetRelation(true);
|
||||
|
||||
qx::test::CPerson * pBrother = new qx::test::CPerson();
|
||||
pBrother->setFirstName("brother firstname");
|
||||
pBrother->setLastName("brother lastname");
|
||||
pUser->setBrother(pBrother);
|
||||
pUser->setLastName("user lastname");
|
||||
|
||||
QSqlError daoError = qx::dao::create_table<CUser>();
|
||||
daoError = qx::dao::create_table<qx::test::CPerson>();
|
||||
daoError = qx::dao::insert(pBrother);
|
||||
long lBrotherId = pBrother->getPersonId();
|
||||
daoError = qx::dao::insert(pUser);
|
||||
long lDaoCount = qx::dao::count<CUser>(); qAssert(lDaoCount == 1);
|
||||
pUser->setBrother(NULL);
|
||||
daoError = qx::dao::fetch_by_id(pUser); qAssert(pUser->getBrother() && (pUser->getBrother()->getPersonId() == lBrotherId));
|
||||
pUser->setBrother(NULL);
|
||||
daoError = qx::dao::fetch_by_id_with_relation("brother", pUser); qAssert(pUser->getBrother() && (pUser->getBrother()->getFirstName() == "brother firstname"));
|
||||
qx_bool bDaoExist = qx::dao::exist(pUser); qAssert(bDaoExist);
|
||||
daoError = qx::dao::update(pUser);
|
||||
daoError = qx::dao::delete_by_id(pUser);
|
||||
lDaoCount = qx::dao::count<CUser>(); qAssert(lDaoCount == 0);
|
||||
daoError = qx::dao::save(pUser);
|
||||
daoError = qx::dao::save(pUser);
|
||||
lDaoCount = qx::dao::count<CUser>(); qAssert(lDaoCount == 1);
|
||||
daoError = qx::dao::delete_all<CUser>();
|
||||
bDaoExist = qx::dao::exist(pUser); qAssert(! bDaoExist);
|
||||
pUser->setBrother(NULL);
|
||||
|
||||
typedef qx::QxCollection< long, std::shared_ptr<CUser> > type_lstUser;
|
||||
std::shared_ptr<CUser> ppp1; ppp1.reset(new CUser(53));
|
||||
ppp1->setProfil("profil 10");
|
||||
ppp1->setLastName("ppp1 lastname");
|
||||
std::shared_ptr<CUser> ppp2; ppp2.reset(new CUser(108));
|
||||
ppp2->setDateModif(QDateTime::currentDateTime());
|
||||
ppp2->setLastName("ppp1 lastname");
|
||||
type_lstUser lstUser;
|
||||
lstUser.insert(ppp1->getUserId(), ppp1);
|
||||
lstUser.insert(ppp2->getUserId(), ppp2);
|
||||
|
||||
QString sQuery1 = "WHERE profil LIKE '%pro%'";
|
||||
QString sQuery2 = "LIMIT 1";
|
||||
qx::QxSqlQuery qxQuery1("WHERE profil LIKE :profil");
|
||||
qxQuery1.bind(":profil", "%pro%");
|
||||
|
||||
daoError = qx::dao::insert(lstUser);
|
||||
lDaoCount = qx::dao::count<CUser>(); qAssert(lDaoCount == 2);
|
||||
lDaoCount = qx::dao::count<CUser>(sQuery1); qAssert(lDaoCount == 1);
|
||||
lDaoCount = qx::dao::count<CUser>(qxQuery1); qAssert(lDaoCount == 1);
|
||||
daoError = qx::dao::fetch_by_id(lstUser);
|
||||
bDaoExist = qx::dao::exist(lstUser); qAssert(bDaoExist);
|
||||
daoError = qx::dao::update(lstUser);
|
||||
daoError = qx::dao::delete_by_id(lstUser);
|
||||
lDaoCount = qx::dao::count<CUser>(); qAssert(lDaoCount == 0);
|
||||
daoError = qx::dao::save(lstUser);
|
||||
|
||||
pBrother = new qx::test::CPerson();
|
||||
pBrother->setFirstName("brother firstname from collection");
|
||||
pBrother->setLastName("brother lastname from collection");
|
||||
lstUser.getByIndex(0)->setBrother(pBrother);
|
||||
|
||||
daoError = qx::dao::insert(pBrother);
|
||||
lBrotherId = pBrother->getPersonId();
|
||||
daoError = qx::dao::save(lstUser);
|
||||
daoError = qx::dao::fetch_by_query(sQuery2, lstUser); qAssert(lstUser.size() == 1);
|
||||
daoError = qx::dao::fetch_all_with_all_relation(lstUser); qAssert((lstUser.size() == 2) && lstUser.getByIndex(0)->getBrother() && (lstUser.getByIndex(0)->getBrother()->getLastName() == "brother lastname from collection"));
|
||||
lDaoCount = qx::dao::count<CUser>(); qAssert(lDaoCount == 2);
|
||||
daoError = qx::dao::fetch_all(lstUser); qAssert(lstUser.size() == 2);
|
||||
daoError = qx::dao::delete_by_query<CUser>(sQuery1);
|
||||
lDaoCount = qx::dao::count<CUser>(); qAssert(lDaoCount == 1);
|
||||
daoError = qx::dao::delete_all<CUser>();
|
||||
bDaoExist = qx::dao::exist(lstUser); qAssert(! bDaoExist);
|
||||
daoError = qx::dao::fetch_all(lstUser); qAssert(lstUser.size() == 0);
|
||||
|
||||
//--------------------------------
|
||||
|
||||
daoError = qx::dao::create_table<Bar>();
|
||||
daoError = qx::dao::create_table<Foo>();
|
||||
|
||||
Foo_ptr pFoo;
|
||||
pFoo.reset(new Foo()); pFoo->setName("name1"); pFoo->setDesc("desc1"); daoError = qx::dao::save(pFoo); qAssert(pFoo->getId() == 1);
|
||||
pFoo.reset(new Foo()); pFoo->setName("name2"); pFoo->setDesc("desc2"); daoError = qx::dao::save(pFoo); qAssert(pFoo->getId() == 2);
|
||||
pFoo.reset(new Foo()); pFoo->setName("name3"); pFoo->setDesc("desc3"); daoError = qx::dao::save(pFoo); qAssert(pFoo->getId() == 3);
|
||||
pFoo.reset(new Foo()); pFoo->setName("name4"); pFoo->setDesc("desc4"); daoError = qx::dao::save(pFoo); qAssert(pFoo->getId() == 4);
|
||||
pFoo.reset(new Foo()); pFoo->setName("name5"); pFoo->setDesc("desc5"); daoError = qx::dao::save(pFoo); qAssert(pFoo->getId() == 5);
|
||||
pFoo.reset(new Foo()); pFoo->setName("name6"); pFoo->setDesc("desc6"); daoError = qx::dao::save(pFoo); qAssert(pFoo->getId() == 6);
|
||||
pFoo.reset(new Foo()); pFoo->setName("name7"); pFoo->setDesc("desc7"); daoError = qx::dao::save(pFoo); qAssert(pFoo->getId() == 7);
|
||||
|
||||
// Test qx::IxPersistable interface
|
||||
daoError = pFoo->qxFetchById(); qAssert(! daoError.isValid());
|
||||
daoError = pFoo->qxUpdate(); qAssert(! daoError.isValid());
|
||||
lDaoCount = pFoo->qxCount(); qAssert(lDaoCount == 7);
|
||||
invalidValues = pFoo->qxValidate(); qAssert(invalidValues.count() == 0);
|
||||
|
||||
#ifndef _QX_NO_JSON
|
||||
QString fooAsJson = pFoo->toJson(); qDebug("[QxOrm] qx::IxPersistable::toJson() test 1 :\n%s", qPrintable(fooAsJson));
|
||||
qx::IxPersistable * pFooPersistable = static_cast<qx::IxPersistable *>(pFoo.get());
|
||||
fooAsJson = qx::serialization::json::to_string(* pFooPersistable);
|
||||
qDebug("[QxOrm] qx::IxPersistable::toJson() test 2 :\n%s", qPrintable(fooAsJson));
|
||||
|
||||
qx::IxPersistableCollection_ptr pFooPersistableCollection = qx::IxPersistable::qxFetchAll("Foo");
|
||||
qAssert(pFooPersistableCollection && (pFooPersistableCollection->__count() != 0));
|
||||
fooAsJson = pFooPersistableCollection->toJson();
|
||||
qDebug("[QxOrm] qx::IxPersistableCollection::toJson() test 3 :\n%s", qPrintable(fooAsJson));
|
||||
daoError = pFooPersistableCollection->qxSave(); qAssert(! daoError.isValid());
|
||||
|
||||
QStringList emptyColumnsRelations;
|
||||
pFooPersistableCollection = qx::IxPersistable::qxFetchAll("Foo", emptyColumnsRelations, emptyColumnsRelations, NULL, true);
|
||||
qAssert(pFooPersistableCollection && (pFooPersistableCollection->__count() != 0));
|
||||
fooAsJson = pFooPersistableCollection->toJson();
|
||||
qDebug("[QxOrm] qx::IxPersistableCollection::toJson() test 4 :\n%s", qPrintable(fooAsJson));
|
||||
daoError = pFooPersistableCollection->qxSave(); qAssert(! daoError.isValid());
|
||||
#endif // _QX_NO_JSON
|
||||
|
||||
Bar_ptr pBar;
|
||||
pBar.reset(new Bar()); pBar->setCode("code1"); pBar->setValue("value1"); pBar->setFoo(3); daoError = qx::dao::save(pBar); qAssert(pBar->getId() == 1);
|
||||
pBar.reset(new Bar()); pBar->setCode("code2"); pBar->setValue("value2"); pBar->setFoo(3); daoError = qx::dao::save(pBar); qAssert(pBar->getId() == 2);
|
||||
pBar.reset(new Bar()); pBar->setCode("code3"); pBar->setValue("value3"); pBar->setFoo(2); daoError = qx::dao::save(pBar); qAssert(pBar->getId() == 3);
|
||||
pBar.reset(new Bar()); pBar->setCode("code4"); pBar->setValue("value4"); pBar->setFoo(3); daoError = qx::dao::save(pBar); qAssert(pBar->getId() == 4);
|
||||
pBar.reset(new Bar()); pBar->setCode("code5"); pBar->setValue("value5"); pBar->setFoo(2); daoError = qx::dao::save(pBar); qAssert(pBar->getId() == 5);
|
||||
pBar.reset(new Bar()); pBar->setCode("code6"); pBar->setValue("value6"); pBar->setFoo(6); daoError = qx::dao::save(pBar); qAssert(pBar->getId() == 6);
|
||||
pBar.reset(new Bar()); pBar->setCode("code7"); pBar->setValue("value7"); pBar->setFoo(3); daoError = qx::dao::save(pBar); qAssert(pBar->getId() == 7);
|
||||
|
||||
// Test inserting a complex QVariant in database
|
||||
pFoo.reset(new Foo()); pFoo->setId(3); daoError = pFoo->qxFetchById(); qAssert(! daoError.isValid());
|
||||
QMap<QString, QVariant> testComplexVariant; testComplexVariant.insert("key_1", QVariant(QString("val_1")));
|
||||
QList<QVariant> testComplexVariantItem; testComplexVariantItem.append(QVariant(QString("val_2_inside_QVariantList")));
|
||||
testComplexVariantItem.append(QVariant(QString("val_3_inside_QVariantList")));
|
||||
testComplexVariant.insert("key_2", QVariant(testComplexVariantItem));
|
||||
pFoo->setDesc(testComplexVariant);
|
||||
daoError = pFoo->qxUpdate(); qAssert(! daoError.isValid());
|
||||
|
||||
pFoo.reset(new Foo()); pFoo->setId(3);
|
||||
daoError = qx::dao::fetch_by_id_with_relation("lstBar", pFoo); qAssert(pFoo->getBarX() && (pFoo->getBarX()->size() == 4)); qx::dump((* pFoo), true);
|
||||
pFoo.reset(new Foo()); pFoo->setId(4);
|
||||
daoError = qx::dao::fetch_by_id_with_relation("lstBar", pFoo); qAssert(! pFoo->getBarX() || (pFoo->getBarX()->size() == 0));
|
||||
pFoo.reset(new Foo()); pFoo->setId(2);
|
||||
daoError = qx::dao::fetch_by_id_with_relation("lstBar", pFoo); qAssert(pFoo->getBarX() && (pFoo->getBarX()->size() == 2));
|
||||
|
||||
FooX_ptr pFooX; pFooX.reset(new FooX());
|
||||
daoError = qx::dao::fetch_all_with_all_relation(pFooX); qAssert(pFooX->size() == 7);
|
||||
pFoo = pFooX->getByKey(3); qAssert(pFoo->getBarX() && (pFoo->getBarX()->size() == 4));
|
||||
pFoo = pFooX->getByKey(4); qAssert(! pFoo->getBarX() || (pFoo->getBarX()->size() == 0));
|
||||
pFoo = pFooX->getByKey(2); qAssert(pFoo->getBarX() && (pFoo->getBarX()->size() == 2));
|
||||
|
||||
{
|
||||
// Test eager fetching an instance (with relationships) which is not a pointer or smart-pointer
|
||||
QList<Foo> pFooX1; daoError = qx::dao::fetch_all_with_all_relation(pFooX1); qAssert(pFooX1.size() == 7);
|
||||
QHash<long, Foo> pFooX2; daoError = qx::dao::fetch_all_with_all_relation(pFooX2); qAssert(pFooX2.size() == 7);
|
||||
qx::QxCollection<long, Foo> pFooX3; daoError = qx::dao::fetch_all_with_all_relation(pFooX3); qAssert(pFooX3.size() == 7);
|
||||
|
||||
#ifdef _QX_ENABLE_BOOST
|
||||
#if (BOOST_VERSION >= 105000)
|
||||
boost::unordered_map<long, Foo> pFooX4; daoError = qx::dao::fetch_all_with_all_relation(pFooX4); qAssert(pFooX4.size() == 7);
|
||||
#endif // (BOOST_VERSION >= 105000)
|
||||
#endif // _QX_ENABLE_BOOST
|
||||
|
||||
std::vector<Foo> pFooX5; daoError = qx::dao::fetch_all_with_all_relation(pFooX5); qAssert(pFooX5.size() == 7);
|
||||
QSet<Foo *> pFooX6; daoError = qx::dao::fetch_all_with_all_relation(pFooX6); qAssert(pFooX6.size() == 7); Q_FOREACH(Foo * pFooTemp, pFooX6) { delete pFooTemp; }
|
||||
std::set<Foo_ptr> pFooX7; daoError = qx::dao::fetch_all_with_all_relation(pFooX7); qAssert(pFooX7.size() == 7);
|
||||
|
||||
#ifdef _QX_ENABLE_BOOST
|
||||
boost::unordered_set<Foo_ptr> pFooX8; daoError = qx::dao::fetch_all_with_all_relation(pFooX8); qAssert(pFooX8.size() == 7);
|
||||
#endif // _QX_ENABLE_BOOST
|
||||
}
|
||||
|
||||
pBar.reset(new Bar()); pBar->setId(7);
|
||||
daoError = qx::dao::fetch_by_id_with_relation("foo_id", pBar); qAssert(pBar->getFoo() && (pBar->getFoo()->getName() == "name3"));
|
||||
pFoo = pBar->getFoo(); if (pFoo) { pFoo->setDate(QDate::currentDate()); pFoo->setTime(QTime::currentTime()); pFoo->setDateTime(QDateTime::currentDateTime()); }
|
||||
qx::dump(pBar, false);
|
||||
qx::dump(pBar, true);
|
||||
|
||||
// Test soft delete behavior
|
||||
pBar.reset(new Bar());
|
||||
pBar->setId(5);
|
||||
daoError = qx::dao::delete_by_id(pBar); qAssert(! daoError.isValid()); // This Bar item is now soft-deleted in database
|
||||
bDaoExist = qx::dao::exist(pBar); qAssert(! bDaoExist);
|
||||
daoError = qx::dao::delete_all<Bar>(); qAssert(! daoError.isValid()); // All Bar items are now soft-deleted in database
|
||||
long lBarCount = qx::dao::count<Bar>(); qAssert(lBarCount == 0); Q_UNUSED(lBarCount);
|
||||
|
||||
{
|
||||
// Fetch soft-deleted items from database using session and ignoreSoftDelete() behavior
|
||||
qx::QxSession session;
|
||||
session.ignoreSoftDelete(); // The second parameter allows to select classes to ignore soft delete behavior (by default, if empty, then all classes are ignored)
|
||||
BarX lstOfSoftDeletedBars;
|
||||
daoError = session.fetchAll(lstOfSoftDeletedBars);
|
||||
qAssert((! daoError.isValid()) && (lstOfSoftDeletedBars.size() > 0));
|
||||
lBarCount = session.count<Bar>(); qAssert(lBarCount > 0); Q_UNUSED(lBarCount);
|
||||
|
||||
// Try to fetch soft-deleted items from database through relationships
|
||||
pFooX.reset(new FooX());
|
||||
daoError = session.fetchAll(pFooX, QStringList(), QStringList() << "lstBar");
|
||||
qAssert((! daoError.isValid()) && (pFooX->size() == 7));
|
||||
pFoo = pFooX->getByKey(3); qAssert(pFoo->getBarX() && (pFoo->getBarX()->size() == 4));
|
||||
pFoo = pFooX->getByKey(4); qAssert(! pFoo->getBarX() || (pFoo->getBarX()->size() == 0));
|
||||
pFoo = pFooX->getByKey(2); qAssert(pFoo->getBarX() && (pFoo->getBarX()->size() == 2));
|
||||
|
||||
// Remove physically items in database even if a soft delete behavior has been defined (using destroy functions)
|
||||
daoError = session.destroyAll<Bar>(); qAssert(! daoError.isValid());
|
||||
daoError = session.fetchAll(lstOfSoftDeletedBars);
|
||||
qAssert((! daoError.isValid()) && (lstOfSoftDeletedBars.size() == 0));
|
||||
lBarCount = session.count<Bar>(); qAssert(lBarCount == 0); Q_UNUSED(lBarCount);
|
||||
}
|
||||
|
||||
{
|
||||
pFoo.reset(new Foo()); pFoo->setName("name10"); pFoo->setDesc("desc10");
|
||||
pFoo->setDate(QDate::currentDate()); pFoo->setTime(QTime::currentTime()); pFoo->setDateTime(QDateTime::currentDateTime());
|
||||
#ifdef _QX_ENABLE_BOOST
|
||||
boost::optional<QString> optionalString("test boost optional"); pFoo->setOptString(optionalString);
|
||||
#endif // _QX_ENABLE_BOOST
|
||||
|
||||
// Test session to manage automatically database transactions (using C++ RAII)
|
||||
qx::QxSession session;
|
||||
session += qx::dao::insert(pFoo, session.database());
|
||||
session += qx::dao::update(pFoo, session.database());
|
||||
session += qx::dao::fetch_by_id(pFoo, session.database());
|
||||
session += qx::dao::delete_by_id(pFoo, session.database());
|
||||
qAssert(session.isValid());
|
||||
}
|
||||
|
||||
//--------------------------------
|
||||
|
||||
// Dump all registered classes into QxOrm context (introspection engine)
|
||||
qx::QxClassX::dumpAllClasses();
|
||||
|
||||
pBar.reset(new Bar());
|
||||
qx::IxDataMember * pDataMember = qx::QxClassX::getDataMember("Bar", "code"); qAssert(pDataMember != NULL);
|
||||
bool bIntrospectionOk = pDataMember->setValue<QString>(pBar.get(), QString("test introspection engine")); qAssert(bIntrospectionOk);
|
||||
QString sIntrospectionTest = pDataMember->getValue<QString>(pBar.get(), (& bIntrospectionOk));
|
||||
qAssert(bIntrospectionOk && (sIntrospectionTest == "test introspection engine"));
|
||||
qAssert(pBar->getCode() == "test introspection engine");
|
||||
|
||||
//--------------------------------
|
||||
|
||||
daoError = qx::dao::create_table<TestQtProperty>();
|
||||
TestQtProperty testQtMetaProperty;
|
||||
QString sQtPropertyDesc = "test Qt introspection engine : meta-property using Q_PROPERTY() macro";
|
||||
testQtMetaProperty.setDesc(sQtPropertyDesc);
|
||||
testQtMetaProperty.setBirthDate(QDateTime::currentDateTime());
|
||||
daoError = qx::dao::insert(testQtMetaProperty); qAssert(! daoError.isValid());
|
||||
daoError = qx::dao::fetch_by_id(testQtMetaProperty); qAssert(! daoError.isValid());
|
||||
qx::IxDataMember * pQtMetaProperty = qx::QxClassX::getDataMember("TestQtProperty", "desc"); Q_UNUSED(pQtMetaProperty);
|
||||
qAssert(pQtMetaProperty && pQtMetaProperty->getValue<QString>(& testQtMetaProperty) == sQtPropertyDesc);
|
||||
qx::dump(testQtMetaProperty, false);
|
||||
qx::dump(testQtMetaProperty, true);
|
||||
|
||||
//--------------------------------
|
||||
|
||||
QDateTime queryDT1, queryDT2;
|
||||
qx_query queryToTest;
|
||||
queryToTest.where("sex").isEqualTo("female")
|
||||
.and_("age").isGreaterThan(38)
|
||||
.or_("last_name").isNotEqualTo("Dupont")
|
||||
.or_("first_name").like("Alfred")
|
||||
.and_OpenParenthesis("id").isLessThanOrEqualTo(999)
|
||||
.and_("birth_date").isBetween(queryDT1, queryDT2)
|
||||
.closeParenthesis()
|
||||
.or_("id").in(50, 999, 11, 23, 78945)
|
||||
.and_("is_deleted").isNotNull()
|
||||
.orderAsc("last_name", "first_name", "sex")
|
||||
.limit(50, 150);
|
||||
|
||||
QString sQueryToTest = queryToTest.query();
|
||||
qDebug("[QxOrm] test SQL query using C++ syntax : '%s'", qPrintable(sQueryToTest));
|
||||
|
||||
//--------------------------------
|
||||
|
||||
qx::QxRepository<Foo> repositoryFoo;
|
||||
pFooX.reset(new FooX());
|
||||
daoError = repositoryFoo.fetchAll(pFooX);
|
||||
qAssert(! daoError.isValid());
|
||||
Foo_ptr pFooTmp;
|
||||
pFooTmp.reset(repositoryFoo.fetchById(3));
|
||||
if (pFooTmp)
|
||||
{
|
||||
pFooTmp->setDesc("desc_modified");
|
||||
daoError = repositoryFoo.save(pFooTmp);
|
||||
qAssert(! daoError.isValid());
|
||||
}
|
||||
|
||||
//--------------------------------
|
||||
|
||||
// Just to check compilation of model/view template class
|
||||
qx::IxModel * pModel = new qx::QxModel<Foo>();
|
||||
Q_UNUSED(pModel);
|
||||
|
||||
//--------------------------------
|
||||
|
||||
qAssert(qx::QxClassX::implementIxPersistable("qx::QxPersistable"));
|
||||
qAssert(qx::QxClassX::implementIxPersistable("Bar"));
|
||||
|
||||
qx::cache::clear();
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user