first commit
This commit is contained in:
57
test/qxBlogCompositeKey/include/author.h
Normal file
57
test/qxBlogCompositeKey/include/author.h
Normal file
@@ -0,0 +1,57 @@
|
||||
#ifndef _QX_BLOG_AUTHOR_H_
|
||||
#define _QX_BLOG_AUTHOR_H_
|
||||
|
||||
class blog;
|
||||
|
||||
class QX_BLOG_DLL_EXPORT author
|
||||
{
|
||||
|
||||
QX_REGISTER_FRIEND_CLASS(author)
|
||||
|
||||
public:
|
||||
|
||||
// -- composite key (multi-column primary key in database)
|
||||
typedef std::tuple<QString, long, QString> type_composite_key;
|
||||
static QString str_composite_key() { return "author_id_0|author_id_1|author_id_2"; }
|
||||
|
||||
// -- typedef
|
||||
typedef std::shared_ptr<blog> blog_ptr;
|
||||
typedef std::vector<blog_ptr> list_blog;
|
||||
|
||||
// -- enum
|
||||
enum enum_sex { male, female, unknown };
|
||||
|
||||
// -- properties
|
||||
type_composite_key m_id;
|
||||
QString m_name;
|
||||
QDate m_birthdate;
|
||||
enum_sex m_sex;
|
||||
list_blog m_blogX;
|
||||
|
||||
// -- contructor, virtual destructor
|
||||
author() : m_id("", 0, ""), m_sex(unknown) { ; }
|
||||
virtual ~author() { ; }
|
||||
|
||||
// -- methods
|
||||
int age() const;
|
||||
|
||||
// -- methods "get" to composite key
|
||||
type_composite_key getId() const { return m_id; }
|
||||
QString getId_0() const { return std::get<0>(m_id); }
|
||||
long getId_1() const { return std::get<1>(m_id); }
|
||||
QString getId_2() const { return std::get<2>(m_id); }
|
||||
|
||||
// -- methods "set" to composite key
|
||||
void setId_0(const QString & s) { std::get<0>(m_id) = s; }
|
||||
void setId_1(long l) { std::get<1>(m_id) = l; }
|
||||
void setId_2(const QString & s) { std::get<2>(m_id) = s; }
|
||||
|
||||
};
|
||||
|
||||
QX_REGISTER_PRIMARY_KEY(author, author::type_composite_key)
|
||||
QX_REGISTER_HPP_QX_BLOG(author, qx::trait::no_base_class_defined, 0)
|
||||
|
||||
typedef std::shared_ptr<author> author_ptr;
|
||||
typedef qx::QxCollection<author::type_composite_key, author_ptr> list_author;
|
||||
|
||||
#endif // _QX_BLOG_AUTHOR_H_
|
||||
48
test/qxBlogCompositeKey/include/blog.h
Normal file
48
test/qxBlogCompositeKey/include/blog.h
Normal file
@@ -0,0 +1,48 @@
|
||||
#ifndef _QX_BLOG_BLOG_H_
|
||||
#define _QX_BLOG_BLOG_H_
|
||||
|
||||
#include "author.h"
|
||||
#include "comment.h"
|
||||
#include "category.h"
|
||||
|
||||
class QX_BLOG_DLL_EXPORT blog
|
||||
{
|
||||
|
||||
QX_REGISTER_FRIEND_CLASS(blog)
|
||||
|
||||
public:
|
||||
|
||||
// -- composite key (multi-column primary key in database)
|
||||
typedef QPair<long, QString> type_composite_key;
|
||||
static QString str_composite_key() { return "blog_id_0|blog_id_1"; }
|
||||
|
||||
// -- properties
|
||||
type_composite_key m_id;
|
||||
QString m_text;
|
||||
QDateTime m_dt_creation;
|
||||
author_ptr m_author;
|
||||
list_comment m_commentX;
|
||||
list_category m_categoryX;
|
||||
|
||||
// -- contructor, virtual destructor
|
||||
blog() : m_id(0, "") { ; }
|
||||
virtual ~blog() { ; }
|
||||
|
||||
// -- methods "get" to composite key
|
||||
type_composite_key getId() const { return m_id; }
|
||||
long getId_0() const { return m_id.first; }
|
||||
QString getId_1() const { return m_id.second; }
|
||||
|
||||
// -- methods "set" to composite key
|
||||
void setId_0(long l) { m_id.first = l; }
|
||||
void setId_1(const QString & s) { m_id.second = s; }
|
||||
|
||||
};
|
||||
|
||||
QX_REGISTER_PRIMARY_KEY(blog, blog::type_composite_key)
|
||||
QX_REGISTER_HPP_QX_BLOG(blog, qx::trait::no_base_class_defined, 0)
|
||||
|
||||
typedef std::shared_ptr<blog> blog_ptr;
|
||||
typedef std::vector<blog_ptr> list_blog;
|
||||
|
||||
#endif // _QX_BLOG_BLOG_H_
|
||||
52
test/qxBlogCompositeKey/include/category.h
Normal file
52
test/qxBlogCompositeKey/include/category.h
Normal file
@@ -0,0 +1,52 @@
|
||||
#ifndef _QX_BLOG_CATEGORY_H_
|
||||
#define _QX_BLOG_CATEGORY_H_
|
||||
|
||||
class blog;
|
||||
|
||||
class QX_BLOG_DLL_EXPORT category
|
||||
{
|
||||
|
||||
QX_REGISTER_FRIEND_CLASS(category)
|
||||
|
||||
public:
|
||||
|
||||
// -- composite key (multi-column primary key in database)
|
||||
typedef std::tuple<QString, long, QString, long> type_composite_key;
|
||||
static QString str_composite_key() { return "category_id_0|category_id_1|category_id_2|category_id_3"; }
|
||||
|
||||
// -- typedef
|
||||
typedef std::shared_ptr<blog> blog_ptr;
|
||||
typedef qx::QxCollection<long, blog_ptr> list_blog;
|
||||
|
||||
// -- properties
|
||||
type_composite_key m_id;
|
||||
QString m_name;
|
||||
QString m_desc;
|
||||
list_blog m_blogX;
|
||||
|
||||
// -- contructor, virtual destructor
|
||||
category() : m_id("", 0, "", 0) { ; }
|
||||
virtual ~category() { ; }
|
||||
|
||||
// -- methods "get" to composite key
|
||||
type_composite_key getId() const { return m_id; }
|
||||
QString getId_0() const { return std::get<0>(m_id); }
|
||||
long getId_1() const { return std::get<1>(m_id); }
|
||||
QString getId_2() const { return std::get<2>(m_id); }
|
||||
long getId_3() const { return std::get<3>(m_id); }
|
||||
|
||||
// -- methods "set" to composite key
|
||||
void setId_0(const QString & s) { std::get<0>(m_id) = s; }
|
||||
void setId_1(long l) { std::get<1>(m_id) = l; }
|
||||
void setId_2(const QString & s) { std::get<2>(m_id) = s; }
|
||||
void setId_3(long l) { std::get<3>(m_id) = l; }
|
||||
|
||||
};
|
||||
|
||||
QX_REGISTER_PRIMARY_KEY(category, category::type_composite_key)
|
||||
QX_REGISTER_HPP_QX_BLOG(category, qx::trait::no_base_class_defined, 0)
|
||||
|
||||
typedef QSharedPointer<category> category_ptr;
|
||||
typedef qx::QxCollection<category::type_composite_key, category_ptr> list_category;
|
||||
|
||||
#endif // _QX_BLOG_CATEGORY_H_
|
||||
47
test/qxBlogCompositeKey/include/comment.h
Normal file
47
test/qxBlogCompositeKey/include/comment.h
Normal file
@@ -0,0 +1,47 @@
|
||||
#ifndef _QX_BLOG_COMMENT_H_
|
||||
#define _QX_BLOG_COMMENT_H_
|
||||
|
||||
class blog;
|
||||
|
||||
class QX_BLOG_DLL_EXPORT comment
|
||||
{
|
||||
|
||||
QX_REGISTER_FRIEND_CLASS(comment)
|
||||
|
||||
public:
|
||||
|
||||
// -- composite key (multi-column primary key in database)
|
||||
typedef std::tuple<long, QString> type_composite_key;
|
||||
static QString str_composite_key() { return "comment_id_0|comment_id_1"; }
|
||||
|
||||
// -- typedef
|
||||
typedef std::shared_ptr<blog> blog_ptr;
|
||||
|
||||
// -- properties
|
||||
type_composite_key m_id;
|
||||
QString m_text;
|
||||
QDateTime m_dt_create;
|
||||
blog_ptr m_blog;
|
||||
|
||||
// -- contructor, virtual destructor
|
||||
comment() : m_id(0, "") { ; }
|
||||
virtual ~comment() { ; }
|
||||
|
||||
// -- methods "get" to composite key
|
||||
type_composite_key getId() const { return m_id; }
|
||||
long getId_0() const { return std::get<0>(m_id); }
|
||||
QString getId_1() const { return std::get<1>(m_id); }
|
||||
|
||||
// -- methods "set" to composite key
|
||||
void setId_0(long l) { std::get<0>(m_id) = l; }
|
||||
void setId_1(const QString & s) { std::get<1>(m_id) = s; }
|
||||
|
||||
};
|
||||
|
||||
QX_REGISTER_PRIMARY_KEY(comment, comment::type_composite_key)
|
||||
QX_REGISTER_HPP_QX_BLOG(comment, qx::trait::no_base_class_defined, 0)
|
||||
|
||||
typedef std::shared_ptr<comment> comment_ptr;
|
||||
typedef QList<comment_ptr> list_comment;
|
||||
|
||||
#endif // _QX_BLOG_COMMENT_H_
|
||||
18
test/qxBlogCompositeKey/include/export.h
Normal file
18
test/qxBlogCompositeKey/include/export.h
Normal file
@@ -0,0 +1,18 @@
|
||||
#ifndef _QX_BLOG_EXPORT_H_
|
||||
#define _QX_BLOG_EXPORT_H_
|
||||
|
||||
#ifdef _BUILDING_QX_BLOG
|
||||
#define QX_BLOG_DLL_EXPORT QX_DLL_EXPORT_HELPER
|
||||
#else // _BUILDING_QX_BLOG
|
||||
#define QX_BLOG_DLL_EXPORT QX_DLL_IMPORT_HELPER
|
||||
#endif // _BUILDING_QX_BLOG
|
||||
|
||||
#ifdef _BUILDING_QX_BLOG
|
||||
#define QX_REGISTER_HPP_QX_BLOG QX_REGISTER_HPP_EXPORT_DLL
|
||||
#define QX_REGISTER_CPP_QX_BLOG QX_REGISTER_CPP_EXPORT_DLL
|
||||
#else // _BUILDING_QX_BLOG
|
||||
#define QX_REGISTER_HPP_QX_BLOG QX_REGISTER_HPP_IMPORT_DLL
|
||||
#define QX_REGISTER_CPP_QX_BLOG QX_REGISTER_CPP_IMPORT_DLL
|
||||
#endif // _BUILDING_QX_BLOG
|
||||
|
||||
#endif // _QX_BLOG_EXPORT_H_
|
||||
8
test/qxBlogCompositeKey/include/precompiled.h
Normal file
8
test/qxBlogCompositeKey/include/precompiled.h
Normal file
@@ -0,0 +1,8 @@
|
||||
#ifndef _QX_BLOG_PRECOMPILED_HEADER_H_
|
||||
#define _QX_BLOG_PRECOMPILED_HEADER_H_
|
||||
|
||||
#include <QxOrm.h>
|
||||
|
||||
#include "export.h"
|
||||
|
||||
#endif // _QX_BLOG_PRECOMPILED_HEADER_H_
|
||||
Reference in New Issue
Block a user