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 RELATIONAL_STORE_UTILS_H
17 #define RELATIONAL_STORE_UTILS_H
18 
19 #include "value_object.h"
20 #include "securec.h"
21 
22 namespace OHOS {
23 namespace Relational {
24     char* MallocCString(const std::string& origin);
25 
26     struct StoreConfig {
27         char* name;
28         int32_t securityLevel;
29         bool encrypt;
30         char* dataGroupId;
31         char* customDir;
32         bool isSearchable;
33         bool autoCleanDirtyData;
34     };
35 
36     struct Asset {
37         const char* name;
38         const char* uri;
39         const char* path;
40         const char* createTime;
41         const char* modifyTime;
42         const char* size;
43         int32_t status;
44     };
45 
46     struct Assets {
47         Asset* head;
48         int64_t size;
49     };
50 
51     struct CArrUI8 {
52         uint8_t* head;
53         int64_t size;
54     };
55 
56     struct CArrStr {
57         char** head;
58         int64_t size;
59     };
60 
61     struct ValueType {
62         int64_t integer;
63         double dou;
64         char* string;
65         bool boolean;
66         CArrUI8 Uint8Array;
67         Asset asset;
68         Assets assets;
69         uint8_t tag;
70     };
71 
72     enum TagType {
73         TYPE_NULL, TYPE_INT, TYPE_DOU, TYPE_STR, TYPE_BOOL, TYPE_BLOB, TYPE_ASSET, TYPE_ASSETS
74     };
75 
76     struct ValuesBucket {
77         char** key;
78         ValueType* value;
79         int64_t size;
80     };
81 
82     NativeRdb::ValueObject ValueTypeToValueObject(const ValueType& value);
83 
84     struct CArrInt32 {
85         int32_t* head;
86         int64_t size;
87     };
88 
89     struct CArrSyncResult {
90         char** str;
91         int32_t* num;
92         int64_t size;
93     };
94 
95     ValueType ValueObjectToValueType(const NativeRdb::ValueObject& object);
96 }
97 }
98 #endif