• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 OH_VALUES_BUCKET_H
17 #define OH_VALUES_BUCKET_H
18 
19 /**
20  * @addtogroup RDB
21  * @{
22  *
23  * @brief The relational database (RDB) store manages data based on relational models.
24  * With the underlying SQLite database, the RDB store provides a complete mechanism for managing local databases.
25  * To satisfy different needs in complicated scenarios, the RDB store offers a series of APIs for performing operations
26  * such as adding, deleting, modifying, and querying data, and supports direct execution of SQL statements.
27  *
28  * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
29  * @since 10
30  */
31 
32 /**
33  * @file oh_values_bucket.h
34  *
35  * @brief Define the type of stored key value pairs.
36  *
37  * @kit ArkData
38  * @since 10
39  */
40 
41 #ifdef __cplusplus
42 #include <cstdint>
43 #else
44 #include <stdint.h>
45 #endif
46 
47 #include "database/data/data_asset.h"
48 #ifdef __cplusplus
49 extern "C" {
50 #endif
51 
52 /**
53  * @brief Define the OH_VBucket structure type.
54  *
55  * @since 10
56  */
57 typedef struct OH_VBucket OH_VBucket;
58 
59 /**
60  * @brief Define the OH_VBucket structure type.
61  *
62  * @since 10
63  */
64 struct OH_VBucket {
65     /**
66      * The id used to uniquely identify the OH_VBucket struct.
67      */
68     int64_t id;
69 
70     /**
71      * Indicates the capability of OH_VBucket.
72      */
73     uint16_t capability;
74 
75     /**
76      * @brief Put the const char * value to this {@link OH_VBucket} object for the given column name.
77      *
78      * @param bucket Represents a pointer to an {@link OH_VBucket} instance.
79      * @param field Indicates the name of the column.
80      * @param value Indicates the const char * value.
81      * @return Returns the status code of the execution.
82      * @see OH_VBucket.
83      * @since 10
84      */
85     int (*putText)(OH_VBucket *bucket, const char *field, const char *value);
86 
87     /**
88      * @brief Put the int64 value to this {@link OH_VBucket} object for the given column name.
89      *
90      * @param bucket Represents a pointer to an {@link OH_VBucket} instance.
91      * @param field Indicates the name of the column.
92      * @param value Indicates the int64 value.
93      * @return Returns the status code of the execution.
94      * @see OH_VBucket.
95      * @since 10
96      */
97     int (*putInt64)(OH_VBucket *bucket, const char *field, int64_t value);
98 
99     /**
100      * @brief Put the double value to this {@link OH_VBucket} object for the given column name.
101      *
102      * @param bucket Represents a pointer to an {@link OH_VBucket} instance.
103      * @param field Indicates the name of the column.
104      * @param value Indicates the double value.
105      * @return Returns the status code of the execution.
106      * @see OH_VBucket.
107      * @since 10
108      */
109     int (*putReal)(OH_VBucket *bucket, const char *field, double value);
110 
111     /**
112      * @brief Put the const uint8_t * value to this {@link OH_VBucket} object for the given column name.
113      *
114      * @param bucket Represents a pointer to an {@link OH_VBucket} instance.
115      * @param field Indicates the name of the column.
116      * @param value Indicates the const uint8_t * value.
117      * @param size Indicates the size of value.
118      * @return Returns the status code of the execution.
119      * @see OH_VBucket.
120      * @since 10
121      */
122     int (*putBlob)(OH_VBucket *bucket, const char *field, const uint8_t *value, uint32_t size);
123 
124     /**
125      * @brief Put NULL to this {@link OH_VBucket} object for the given column name.
126      *
127      * @param bucket Represents a pointer to an {@link OH_VBucket} instance.
128      * @param field Indicates the name of the column.
129      * @return Returns the status code of the execution.
130      * @see OH_VBucket.
131      * @since 10
132      */
133     int (*putNull)(OH_VBucket *bucket, const char *field);
134 
135     /**
136      * @brief Clear the {@link OH_VBucket} object's values.
137      *
138      * @param bucket Represents a pointer to an {@link OH_VBucket} instance.
139      * @return Returns the status code of the execution.
140      * @see OH_VBucket.
141      * @since 10
142      */
143     int (*clear)(OH_VBucket *bucket);
144 
145     /**
146      * @brief Destroy the {@link OH_VBucket} object and reclaim the memory occupied by the object.
147      *
148      * @param bucket Represents a pointer to an {@link OH_VBucket} instance.
149      * @return Returns the status code of the execution.
150      * @see OH_VBucket.
151      * @since 10
152      */
153     int (*destroy)(OH_VBucket *bucket);
154 };
155 
156 /**
157  * @brief Put the {@link Data_Asset} * value to this {@link OH_VBucket} object for the given column name.
158  *
159  * @param bucket Represents a pointer to an {@link OH_VBucket} instance.
160  * @param field Indicates the name of the column.
161  * @param value Indicates the const {@link Data_Asset} * value.
162  * @return Returns the status code of the execution.
163  *     {@link RDB_OK} - success.
164  *     {@link RDB_E_INVALID_ARGS} - The error code for common invalid args.
165  * @see OH_VBucket.
166  * @since 11
167  */
168 int OH_VBucket_PutAsset(OH_VBucket *bucket, const char *field, Data_Asset *value);
169 
170 /**
171  * @brief Put the {@link Data_Asset} * value of given count to this {@link OH_VBucket} object for the given column name.
172  *
173  * @param bucket Represents a pointer to an {@link OH_VBucket} instance.
174  * @param field Indicates the name of the column.
175  * @param value Indicates the {@link Data_Asset} value of given count.
176  * @param count Indicates the count of value.
177  * @return Returns the status code of the execution.
178  *     {@link RDB_OK} - success.
179  *     {@link RDB_E_INVALID_ARGS} - The error code for common invalid args.
180  * @see OH_VBucket.
181  * @since 11
182  */
183 int OH_VBucket_PutAssets(OH_VBucket *bucket, const char *field, Data_Asset **value, uint32_t count);
184 #ifdef __cplusplus
185 };
186 #endif
187 
188 #endif // OH_VALUES_BUCKET_H
189