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 #include "rdb_visibility.h" 21 22 namespace OHOS { 23 namespace NativeRdb { 24 25 typedef int32_t (*DBOpen)(const char *dbPath, const char *configStr, uint32_t flags, GRD_DB **db); 26 typedef int32_t (*DBClose)(GRD_DB *db, uint32_t flags); 27 typedef int32_t (*DBRepair)(const char *dbPath, const char *configStr); 28 29 typedef int (*DBSqlPrepare)(GRD_DB *db, const char *str, uint32_t strLen, GRD_SqlStmt **stmt, const char **unusedStr); 30 typedef int (*DBSqlReset)(GRD_SqlStmt *stmt); 31 typedef int (*DBSqlFinalize)(GRD_SqlStmt *stmt); 32 typedef int (*DBSqlBindBlob)(GRD_SqlStmt *stmt, uint32_t idx, const void *val, int32_t len, void (*freeFunc)(void *)); 33 typedef int (*DBSqlBindText)(GRD_SqlStmt *stmt, uint32_t idx, const void *val, int32_t len, void (*freeFunc)(void *)); 34 typedef int (*DBSqlBindInt)(GRD_SqlStmt *stmt, uint32_t idx, int32_t val); 35 typedef int (*DBSqlBindInt64)(GRD_SqlStmt *stmt, uint32_t idx, int64_t val); 36 typedef int (*DBSqlBindDouble)(GRD_SqlStmt *stmt, uint32_t idx, double val); 37 typedef int (*DBSqlBindNull)(GRD_SqlStmt *stmt, uint32_t idx); 38 typedef int (*DBSqlBindFloatVector)( 39 GRD_SqlStmt *stmt, uint32_t idx, const float *val, uint32_t dim, void (*freeFunc)(void *)); 40 41 typedef int (*DBSqlStep)(GRD_SqlStmt *stmt); 42 typedef uint32_t (*DBSqlColCnt)(GRD_SqlStmt *stmt); 43 typedef GRD_DbDataTypeE (*DBSqlColType)(GRD_SqlStmt *stmt, uint32_t idx); 44 typedef int (*DBSqlColBytes)(GRD_SqlStmt *stmt, uint32_t idx); 45 typedef char *(*DBSqlColName)(GRD_SqlStmt *stmt, uint32_t idx); 46 typedef GRD_DbValueT (*DBSqlColValue)(GRD_SqlStmt *stmt, uint32_t idx); 47 typedef uint8_t *(*DBSqlColBlob)(GRD_SqlStmt *stmt, uint32_t idx); 48 typedef char *(*DBSqlColText)(GRD_SqlStmt *stmt, uint32_t idx); 49 typedef int (*DBSqlColInt)(GRD_SqlStmt *stmt, uint32_t idx); 50 typedef uint64_t (*DBSqlColInt64)(GRD_SqlStmt *stmt, uint32_t idx); 51 typedef double (*DBSqlColDouble)(GRD_SqlStmt *stmt, uint32_t idx); 52 typedef const float *(*DBSqlColumnFloatVector)(GRD_SqlStmt *stmt, uint32_t idx, uint32_t *dim); 53 typedef int (*DBBackup) (GRD_DB *db, const char *backupDbFile, uint8_t *encryptedKey, uint32_t encryptedKeyLen); 54 typedef int (*DBRestore) (GRD_DB *db, const char *backupDbFile, uint8_t *encryptedKey, uint32_t encryptedKeyLen); 55 typedef GRD_DbValueT (*DBGetConfig) (GRD_DB *db, GRD_ConfigTypeE type); 56 typedef int (*DBSetConfig) (GRD_DB *db, GRD_ConfigTypeE type, GRD_DbValueT value); 57 58 struct GRD_APIInfo { 59 DBOpen DBOpenApi = nullptr; 60 DBClose DBCloseApi = nullptr; 61 DBRepair DBRepairApi = nullptr; 62 DBSqlPrepare DBSqlPrepare = nullptr; 63 DBSqlReset DBSqlReset = nullptr; 64 DBSqlFinalize DBSqlFinalize = nullptr; 65 DBSqlBindBlob DBSqlBindBlob = nullptr; 66 DBSqlBindText DBSqlBindText = nullptr; 67 DBSqlBindInt DBSqlBindInt = nullptr; 68 DBSqlBindInt64 DBSqlBindInt64 = nullptr; 69 DBSqlBindDouble DBSqlBindDouble = nullptr; 70 DBSqlBindNull DBSqlBindNull = nullptr; 71 DBSqlBindFloatVector DBSqlBindFloatVector = nullptr; 72 DBSqlStep DBSqlStep = nullptr; 73 DBSqlColCnt DBSqlColCnt = nullptr; 74 DBSqlColType DBSqlColType = nullptr; 75 DBSqlColBytes DBSqlColBytes = nullptr; 76 DBSqlColName DBSqlColName = nullptr; 77 DBSqlColValue DBSqlColValue = nullptr; 78 DBSqlColBlob DBSqlColBlob = nullptr; 79 DBSqlColText DBSqlColText = nullptr; 80 DBSqlColInt DBSqlColInt = nullptr; 81 DBSqlColInt64 DBSqlColInt64 = nullptr; 82 DBSqlColDouble DBSqlColDouble = nullptr; 83 DBSqlColumnFloatVector DBSqlColumnFloatVector = nullptr; 84 DBBackup DBBackupApi = nullptr; 85 DBRestore DBRestoreApi = nullptr; 86 DBGetConfig DBGetConfigApi = nullptr; 87 DBSetConfig DBSetConfigApi = nullptr; 88 }; 89 90 API_EXPORT bool IsUsingArkData(); 91 92 GRD_APIInfo GetApiInfoInstance(); 93 94 } // namespace NativeRdb 95 } // namespace OHOS 96 97 #endif // RDB_GRD_API_MANAGER_H 98