1 /* 2 * Copyright (c) 2023 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 GRD_TYPE_EXPORT_H 17 #define GRD_TYPE_EXPORT_H 18 #include <cstdint> 19 #ifdef __cplusplus 20 extern "C" { 21 #endif // __cplusplus 22 23 #ifndef _WIN32 24 #define GRD_API __attribute__((visibility("default"))) 25 #else 26 #define GRD_API 27 #endif 28 29 typedef struct GRD_DB GRD_DB; 30 31 /** 32 * @brief Open database config 33 */ 34 #define GRD_DB_OPEN_ONLY 0x00 35 #define GRD_DB_OPEN_CREATE 0x01 36 // check data in database if close abnormally last time, if data is corrupted, rebuild the database 37 #define GRD_DB_OPEN_CHECK_FOR_ABNORMAL 0x02 38 // check data in database when open database, if data is corrupted, rebuild the database. 39 #define GRD_DB_OPEN_CHECK 0x04 40 #define GRD_DB_OPEN_SHARED_READ_ONLY 0x08 41 42 /** 43 * @brief Close database config 44 */ 45 #define GRD_DB_CLOSE 0x00 46 #define GRD_DB_CLOSE_IGNORE_ERROR 0x01 47 48 /** 49 * @brief flush database config 50 */ 51 #define GRD_DB_FLUSH_ASYNC 0x00 52 #define GRD_DB_FLUSH_SYNC 0x01 53 54 #define GRD_DOC_ID_DISPLAY 0x01 55 typedef struct Query { 56 const char *filter; 57 const char *projection; 58 } Query; 59 60 typedef struct GRD_KVItem { 61 void *data; 62 uint32_t dataLen; 63 } GRD_KVItemT; 64 65 typedef enum KvScanMode { 66 KV_SCAN_PREFIX = 0, 67 KV_SCAN_EQUAL_OR_LESS_KEY = 1, 68 KV_SCAN_EQUAL_OR_GREATER_KEY = 2, 69 KV_SCAN_RANGE = 3, 70 KV_SCAN_BUTT 71 } GRD_KvScanModeE; 72 73 typedef struct GRD_FilterOption { 74 GRD_KvScanModeE mode; 75 GRD_KVItem begin; 76 GRD_KVItem end; 77 } GRD_FilterOptionT; 78 79 typedef struct GRD_ResultSet GRD_ResultSet; 80 typedef struct GRD_DB GRD_DB; 81 typedef struct GRD_KVBatch GRD_KVBatchT; 82 83 /** 84 * @brief Flags for create and drop collection 85 */ 86 #define CHK_EXIST_COLLECTION 1 87 #define CHK_NON_EXIST_COLLECTION 1 88 89 #define GRD_DOC_APPEND 0 90 #define GRD_DOC_REPLACE 1 91 92 #ifdef __cplusplus 93 } 94 #endif // __cplusplus 95 #endif // GRD_TYPE_EXPORT_H