• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2 * Copyright (c) 2024 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15 
16 #ifndef RDB_GRD_API_MANAGER_H
17 #define RDB_GRD_API_MANAGER_H
18 
19 #include "grd_type_export.h"
20 
21 namespace OHOS {
22 namespace NativeRdb {
23 
24 typedef int32_t (*DBOpen)(const char *dbPath, const char *configStr, uint32_t flags, GRD_DB **db);
25 typedef int32_t (*DBClose)(GRD_DB *db, uint32_t flags);
26 typedef int32_t (*DBRepair)(const char *dbPath, const char *configStr);
27 
28 typedef int (*DBSqlPrepare)(GRD_DB *db, const char *str, uint32_t strLen, GRD_SqlStmt **stmt, const char **unusedStr);
29 typedef int (*DBSqlReset)(GRD_SqlStmt *stmt);
30 typedef int (*DBSqlFinalize)(GRD_SqlStmt *stmt);
31 typedef int (*DBSqlBindBlob)(GRD_SqlStmt *stmt, uint32_t idx, const void *val, int32_t len, void (*freeFunc)(void *));
32 typedef int (*DBSqlBindText)(GRD_SqlStmt *stmt, uint32_t idx, const void *val, int32_t len, void (*freeFunc)(void *));
33 typedef int (*DBSqlBindInt)(GRD_SqlStmt *stmt, uint32_t idx, int32_t val);
34 typedef int (*DBSqlBindInt64)(GRD_SqlStmt *stmt, uint32_t idx, int64_t val);
35 typedef int (*DBSqlBindDouble)(GRD_SqlStmt *stmt, uint32_t idx, double val);
36 typedef int (*DBSqlBindNull)(GRD_SqlStmt *stmt, uint32_t idx);
37 typedef int (*DBSqlBindFloatVector)(
38     GRD_SqlStmt *stmt, uint32_t idx, const float *val, uint32_t dim, void (*freeFunc)(void *));
39 
40 typedef int (*DBSqlStep)(GRD_SqlStmt *stmt);
41 typedef uint32_t (*DBSqlColCnt)(GRD_SqlStmt *stmt);
42 typedef GRD_DbDataTypeE (*DBSqlColType)(GRD_SqlStmt *stmt, uint32_t idx);
43 typedef int (*DBSqlColBytes)(GRD_SqlStmt *stmt, uint32_t idx);
44 typedef char *(*DBSqlColName)(GRD_SqlStmt *stmt, uint32_t idx);
45 typedef GRD_DbValueT (*DBSqlColValue)(GRD_SqlStmt *stmt, uint32_t idx);
46 typedef uint8_t *(*DBSqlColBlob)(GRD_SqlStmt *stmt, uint32_t idx);
47 typedef char *(*DBSqlColText)(GRD_SqlStmt *stmt, uint32_t idx);
48 typedef int (*DBSqlColInt)(GRD_SqlStmt *stmt, uint32_t idx);
49 typedef uint64_t (*DBSqlColInt64)(GRD_SqlStmt *stmt, uint32_t idx);
50 typedef double (*DBSqlColDouble)(GRD_SqlStmt *stmt, uint32_t idx);
51 typedef const float *(*DBSqlColumnFloatVector)(GRD_SqlStmt *stmt, uint32_t idx, uint32_t *dim);
52 typedef int (*DBBackup) (GRD_DB *db, const char *backupDbFile, uint8_t *encryptedKey, uint32_t encryptedKeyLen);
53 typedef int (*DBRestore) (GRD_DB *db, const char *backupDbFile, uint8_t *encryptedKey, uint32_t encryptedKeyLen);
54 typedef GRD_DbValueT (*DBGetConfig) (GRD_DB *db, GRD_ConfigTypeE type);
55 typedef int (*DBSetConfig) (GRD_DB *db, GRD_ConfigTypeE type, GRD_DbValueT value);
56 
57 struct GRD_APIInfo {
58     DBOpen DBOpenApi = nullptr;
59     DBClose DBCloseApi = nullptr;
60     DBRepair DBRepairApi = nullptr;
61     DBSqlPrepare DBSqlPrepare = nullptr;
62     DBSqlReset DBSqlReset = nullptr;
63     DBSqlFinalize DBSqlFinalize = nullptr;
64     DBSqlBindBlob DBSqlBindBlob = nullptr;
65     DBSqlBindText DBSqlBindText = nullptr;
66     DBSqlBindInt DBSqlBindInt = nullptr;
67     DBSqlBindInt64 DBSqlBindInt64 = nullptr;
68     DBSqlBindDouble DBSqlBindDouble = nullptr;
69     DBSqlBindNull DBSqlBindNull = nullptr;
70     DBSqlBindFloatVector DBSqlBindFloatVector = nullptr;
71     DBSqlStep DBSqlStep = nullptr;
72     DBSqlColCnt DBSqlColCnt = nullptr;
73     DBSqlColType DBSqlColType = nullptr;
74     DBSqlColBytes DBSqlColBytes = nullptr;
75     DBSqlColName DBSqlColName = nullptr;
76     DBSqlColValue DBSqlColValue = nullptr;
77     DBSqlColBlob DBSqlColBlob = nullptr;
78     DBSqlColText DBSqlColText = nullptr;
79     DBSqlColInt DBSqlColInt = nullptr;
80     DBSqlColInt64 DBSqlColInt64 = nullptr;
81     DBSqlColDouble DBSqlColDouble = nullptr;
82     DBSqlColumnFloatVector DBSqlColumnFloatVector = nullptr;
83     DBBackup DBBackupApi = nullptr;
84     DBRestore DBRestoreApi = nullptr;
85     DBGetConfig DBGetConfigApi = nullptr;
86     DBSetConfig DBSetConfigApi = nullptr;
87 };
88 
89 GRD_APIInfo GetApiInfoInstance();
90 
91 } // namespace NativeRdb
92 } // namespace OHOS
93 
94 #endif // RDB_GRD_API_MANAGER_H
95