-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
CPPORMMacro.h
163 lines (120 loc) · 7.43 KB
/
CPPORMMacro.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
//
// Created by qiuwenchen on 2022/8/27.
//
/*
* Tencent is pleased to support the open source community by making
* WCDB available.
*
* Copyright (C) 2017 THL A29 Limited, a Tencent company.
* All rights reserved.
*
* Licensed under the BSD 3-Clause License (the "License"); you may not use
* this file except in compliance with the License. You may obtain a copy of
* the License at
*
* https://opensource.org/licenses/BSD-3-Clause
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include "CPPBindingMacro.h"
#include "CPPColumnConstraintMacro.h"
#include "CPPFieldMacro.h"
#include "CPPIndexMacro.h"
#include "CPPTableConstraintMacro.h"
#include "CPPVirtualTableMacro.h"
#include "Macro.h"
#define WCDB_FIELD(memberPointer) WCDB::Field(&memberPointer)
#define WCDB_CPP_ORM_DECLARATION(className) \
public: \
__WCDB_CPP_ORM_COMMON_DECLARATION(className) \
static const WCDB::Fields &allFields(); \
static const WCDB::Binding &getObjectRelationBinding();
#define WCDB_CPP_ORM_DECLARE_AND_START_IMPLEMENT(className) \
public: \
__WCDB_CPP_ORM_COMMON_DECLARATION(className) \
static const WCDB::Fields &allFields() \
__WCDB_CPP_ORM_ALL_PROPERTIES_IMPLEMENTATION static const WCDB::Binding & \
getObjectRelationBinding() __WCDB_CPP_ORM_GET_BINDING_IMPLEMENTATIONP_START
#define WCDB_CPP_ORM_IMPLEMENTATION_BEGIN(className) \
using _wcdb_orm_##className = className; \
const WCDB::Fields &_wcdb_orm_##className::allFields() \
__WCDB_CPP_ORM_ALL_PROPERTIES_IMPLEMENTATION const WCDB::Binding &_wcdb_orm_##className::getObjectRelationBinding() \
__WCDB_CPP_ORM_GET_BINDING_IMPLEMENTATIONP_START
#define WCDB_CPP_ORM_IMPLEMENTATION_END __WCDB_CPP_ORM_IMPLEMENTATION_END
#define WCDB_CPP_INHERIT_ORM(baseClass) __WCDB_CPP_INHERIT_ORM(baseClass)
#define WCDB_CPP_SYNTHESIZE(fieldName) \
__WCDB_CPP_SYNTHESIZE_IMP(fieldName, WCDB_STRINGIFY(fieldName))
#define WCDB_CPP_SYNTHESIZE_COLUMN(fieldName, columnName) \
__WCDB_CPP_SYNTHESIZE_IMP(fieldName, columnName)
// Column Constraint
#define WCDB_CPP_PRIMARY(fieldName) __WCDB_CPP_PRIMARY_IMP(fieldName, false)
#define WCDB_CPP_PRIMARY_ASC(fieldName) \
__WCDB_CPP_ORDERED_PRIMARY_IMP(fieldName, WCDB::Order::ASC, false)
#define WCDB_CPP_PRIMARY_DESC(fieldName) \
__WCDB_CPP_ORDERED_PRIMARY_IMP(fieldName, WCDB::Order::DESC, false)
#define WCDB_CPP_PRIMARY_AUTO_INCREMENT(fieldName) \
__WCDB_CPP_PRIMARY_IMP(fieldName, true)
#define WCDB_CPP_PRIMARY_ASC_AUTO_INCREMENT(fieldName) \
__WCDB_CPP_ORDERED_PRIMARY_IMP(fieldName, WCDB::Order::ASC, true)
#define WCDB_CPP_PRIMARY_ENABLE_AUTOINCREMENT_FOR_EXISTING_TABLE \
__WCDB_CPP_PRIMARY_ENABLE_AUTOINCREMENT_FOR_EXISTING_TABLE
#define WCDB_CPP_NOT_NULL(fieldName) __WCDB_CPP_NOT_NULL_IMP(fieldName)
#define WCDB_CPP_UNIQUE(fieldName) __WCDB_CPP_UNIQUE_IMP(fieldName)
#define WCDB_CPP_DEFAULT(fieldName, defaultValue) \
__WCDB_CPP_DEFAULT_IMP(fieldName, defaultValue)
#define WCDB_CPP_CHECK(fieldName, condition) \
__WCDB_CPP_CHECK_IMP(fieldName, condition)
//For FTS
#define WCDB_CPP_NOTINDEXED(fieldName) __WCDB_CPP_NOTINDEXED_IMP(fieldName)
// Table Constraint
#define WCDB_CPP_WITHOUT_ROWID __WCDB_CPP_WITHOUT_ROWID
#define WCDB_CPP_MULTI_PRIMARY(constraintName, fieldName) \
__WCDB_CPP_MULTI_PRIMARY_IMP(constraintName, fieldName)
#define WCDB_CPP_MULTI_PRIMARY_ASC(constraintName, fieldName) \
__WCDB_CPP_ORDERED_MULTI_PRIMARY_IMP(constraintName, fieldName, WCDB::Order::ASC)
#define WCDB_CPP_MULTI_PRIMARY_DESC(constraintName, fieldName) \
__WCDB_CPP_ORDERED_MULTI_PRIMARY_IMP(constraintName, fieldName, WCDB::Order::DESC)
#define WCDB_CPP_MULTI_UNIQUE(constraintName, fieldName) \
__WCDB_CPP_MULTI_UNIQUE_IMP(constraintName, fieldName)
#define WCDB_CPP_MULTI_UNIQUE_ASC(constraintName, fieldName) \
__WCDB_CPP_ORDERED_MULTI_UNIQUE_IMP(constraintName, fieldName, WCDB::Order::ASC)
#define WCDB_CPP_MULTI_UNIQUE_DESC(constraintName, fieldName) \
__WCDB_CPP_ORDERED_MULTI_UNIQUE_IMP(constraintName, fieldName, WCDB::Order::DESC)
// Index
#define WCDB_CPP_INDEX(indexSuffixName, fieldName) \
__WCDB_CPP_INDEX_IMP(indexSuffixName, fieldName, false)
#define WCDB_CPP_INDEX_ASC(indexSuffixName, fieldName) \
__WCDB_CPP_ORDERED_INDEX_IMP(indexSuffixName, fieldName, WCDB::Order::ASC, false)
#define WCDB_CPP_INDEX_DESC(indexSuffixName, fieldName) \
__WCDB_CPP_ORDERED_INDEX_IMP(indexSuffixName, fieldName, WCDB::Order::DESC, false)
#define WCDB_CPP_UNIQUE_INDEX(indexSuffixName, fieldName) \
__WCDB_CPP_INDEX_IMP(indexSuffixName, fieldName, true)
#define WCDB_CPP_UNIQUE_INDEX_ASC(indexSuffixName, fieldName) \
__WCDB_CPP_ORDERED_INDEX_IMP(indexSuffixName, fieldName, WCDB::Order::ASC, true)
#define WCDB_CPP_UNIQUE_INDEX_DESC(indexSuffixName, fieldName) \
__WCDB_CPP_ORDERED_INDEX_IMP(indexSuffixName, fieldName, WCDB::Order::DESC, true)
// Index Operation
#define WCDB_CPP_INDEX_FOR_NEWLY_CREATED_TABLE_ONLY(indexSuffixName) \
__WCDB_CPP_INDEX_FOR_NEWLY_CREATED_TABLE_ONLY_IMP(indexSuffixName)
#define WCDB_CPP_INDEX_TO_BE_DROPPED(indexSuffixName) \
__WCDB_CPP_INDEX_TO_BE_DROPPED(indexSuffixName)
// Virtual Table Argument
#define WCDB_CPP_VIRTUAL_TABLE_ARGUMENT(argument) \
__WCDB_CPP_VIRTUAL_TABLE_ARGUMENT_IMP(argument)
#define WCDB_CPP_VIRTUAL_TABLE_TOKENIZE(tokenizeName) \
__WCDB_CPP_VIRTUAL_TABLE_ARGUMENT_IMP( \
WCDB::FTSTokenizerUtil::tokenize(tokenizeName, nullptr))
#define WCDB_CPP_VIRTUAL_TABLE_TOKENIZE_WITH_PARAMETERS(tokenizeName, ...) \
__WCDB_CPP_VIRTUAL_TABLE_ARGUMENT_IMP( \
WCDB::FTSTokenizerUtil::tokenize(tokenizeName, __VA_ARGS__, nullptr))
#define WCDB_CPP_VIRTUAL_TABLE_EXTERNAL_CONTENT(tableName) \
__WCDB_CPP_VIRTUAL_TABLE_ARGUMENT_IMP( \
WCDB::StatementCreateVirtualTable::externalContent(tableName))
#define WCDB_CPP_VIRTUAL_TABLE_MODULE(moduleName) \
__WCDB_CPP_VIRTUAL_TABLE_MODULE_IMP(moduleName)
#define WCDB_CPP_UNINDEXED(propertyName) __WCDB_CPP_UNINDEXED_IMP(propertyName)