• 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 /**
17  * @addtogroup RDB
18  * @{
19  *
20  * @brief The relational database (RDB) store manages data based on relational models.
21  * With the underlying SQLite database, the RDB store provides a complete mechanism for managing local databases.
22  * To satisfy different needs in complicated scenarios, the RDB store offers a series of APIs for performing operations
23  * such as adding, deleting, modifying, and querying data, and supports direct execution of SQL statements.
24  *
25  * @since 11
26  */
27 
28 /**
29  * @file data_asset.h
30  *
31  * @brief Provides the data type of asset.
32  * @kit ArkData
33  * @library libnative_rdb_ndk.so
34  * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
35  * @since 11
36  */
37 
38 #ifndef DATA_ASSET_H
39 #define DATA_ASSET_H
40 
41 #ifdef __cplusplus
42 #include <cstddef>
43 #else
44 #include <stddef.h>
45 #endif
46 
47 #include <stdint.h>
48 #ifdef __cplusplus
49 extern "C" {
50 #endif
51 /**
52  * @brief Describes the status of asset.
53  *
54  * @since 11
55  */
56 typedef enum Data_AssetStatus {
57     /**
58      * @brief Means the status of asset is null.
59      */
60     ASSET_NULL = 0,
61 
62     /**
63      * @brief Means the status of asset is normal.
64      */
65     ASSET_NORMAL,
66 
67     /**
68      * @brief Means the asset needs to be inserted.
69      */
70     ASSET_INSERT,
71 
72     /**
73      * @brief Means the asset needs to be updated.
74      */
75     ASSET_UPDATE,
76 
77     /**
78      * @brief Means the asset needs to be deleted.
79      */
80     ASSET_DELETE,
81 
82     /**
83      * @brief Means the status of asset is abnormal.
84      */
85     ASSET_ABNORMAL,
86 
87     /**
88      * @brief Means the status of asset is downloading.
89      */
90     ASSET_DOWNLOADING
91 } Data_AssetStatus;
92 
93 /**
94  * @brief Define the Data_Asset structure type.
95  *
96  * Provides information of an asset.
97  *
98  * @since 11
99  */
100 typedef struct Data_Asset Data_Asset;
101 
102 /**
103  * @brief Set the name of the Data_Asset.
104  *
105  * @param asset Represents a pointer to an {@link Data_Asset} instance.
106  * @param name Indicates the name to set.
107  * @return Returns a specific error code.
108  *     {@link RDB_OK} - success.
109  *     {@link RDB_E_INVALID_ARGS} - The error code for common invalid args.
110  * Specific error codes can be referenced {@link OH_Rdb_ErrCode}.
111  * @see Data_Asset
112  * @since 11
113  */
114 int OH_Data_Asset_SetName(Data_Asset *asset, const char *name);
115 
116 /**
117  * @brief Set the uri of the Data_Asset.
118  *
119  * @param asset Represents a pointer to an {@link Data_Asset} instance.
120  * @param uri Indicates the uri to set.
121  * @return Returns a specific error code.
122  *     {@link RDB_OK} - success.
123  *     {@link RDB_E_INVALID_ARGS} - The error code for common invalid args.
124  * Specific error codes can be referenced {@link OH_Rdb_ErrCode}.
125  * @see Data_Asset
126  * @since 11
127  */
128 int OH_Data_Asset_SetUri(Data_Asset *asset, const char *uri);
129 
130 /**
131  * @brief Set the path of the Data_Asset.
132  *
133  * @param asset Represents a pointer to an {@link Data_Asset} instance.
134  * @param path Indicates the path to set.
135  * @return Returns a specific error code.
136  *     {@link RDB_OK} - success.
137  *     {@link RDB_E_INVALID_ARGS} - The error code for common invalid args.
138  * Specific error codes can be referenced {@link OH_Rdb_ErrCode}.
139  * @see Data_Asset
140  * @since 11
141  */
142 int OH_Data_Asset_SetPath(Data_Asset *asset, const char *path);
143 
144 /**
145  * @brief Set the create time of the Data_Asset.
146  *
147  * @param asset Represents a pointer to an {@link Data_Asset} instance.
148  * @param createTime Indicates the create time to set.
149  * @return Returns a specific error code.
150  *     {@link RDB_OK} - success.
151  *     {@link RDB_E_INVALID_ARGS} - The error code for common invalid args.
152  * Specific error codes can be referenced {@link OH_Rdb_ErrCode}.
153  * @see Data_Asset
154  * @since 11
155  */
156 int OH_Data_Asset_SetCreateTime(Data_Asset *asset, int64_t createTime);
157 
158 /**
159  * @brief Set the modify time of the Data_Asset.
160  *
161  * @param asset Represents a pointer to an {@link Data_Asset} instance.
162  * @param modifyTime Indicates the create time to set.
163  * @return Returns a specific error code.
164  *     {@link RDB_OK} - success.
165  *     {@link RDB_E_INVALID_ARGS} - The error code for common invalid args.
166  * Specific error codes can be referenced {@link OH_Rdb_ErrCode}.
167  * @see Data_Asset
168  * @since 11
169  */
170 int OH_Data_Asset_SetModifyTime(Data_Asset *asset, int64_t modifyTime);
171 
172 /**
173  * @brief Set the size of the Data_Asset.
174  *
175  * @param asset Represents a pointer to an {@link Data_Asset} instance.
176  * @param size Indicates the size to set.
177  * @return Returns a specific error code.
178  *     {@link RDB_OK} - success.
179  *     {@link RDB_E_INVALID_ARGS} - The error code for common invalid args.
180  * Specific error codes can be referenced {@link OH_Rdb_ErrCode}.
181  * @see Data_Asset
182  * @since 11
183  */
184 int OH_Data_Asset_SetSize(Data_Asset *asset, size_t size);
185 
186 /**
187  * @brief Set the status of the Data_Asset.
188  *
189  * @param asset Represents a pointer to an {@link Data_Asset} instance.
190  * @param status Indicates the status to set. Specific status can be referenced {@link Data_AssetStatus}.
191  * @return Returns a specific error code.
192  *     {@link RDB_OK} - success.
193  *     {@link RDB_E_INVALID_ARGS} - The error code for common invalid args.
194  * Specific error codes can be referenced {@link OH_Rdb_ErrCode}.
195  * @see Data_Asset, Data_AssetStatus
196  * @since 11
197  */
198 int OH_Data_Asset_SetStatus(Data_Asset *asset, Data_AssetStatus status);
199 
200 /**
201  * @brief Obtains the name of the asset.
202  *
203  * @param asset Represents a pointer to an {@link Data_Asset} instance.
204  * @param name This parameter is the output parameter,
205  * and the name of the asset as a char * is written to this variable.
206  * @param length Indicates the length of the name.
207  * @return Returns a specific error code.
208  *     {@link RDB_ERR} - Indicates that the function execution exception.
209  *     {@link RDB_OK} - success.
210  *     {@link RDB_E_INVALID_ARGS} - The error code for common invalid args.
211  * Specific error codes can be referenced {@link OH_Rdb_ErrCode}.
212  * @see Data_Asset
213  * @since 11
214  */
215 int OH_Data_Asset_GetName(Data_Asset *asset, char *name, size_t *length);
216 
217 /**
218  * @brief Obtains the uri of the asset.
219  *
220  * @param asset Represents a pointer to an {@link Data_Asset} instance.
221  * @param uri This parameter is the output parameter,
222  * and the uri of the asset as a char * is written to this variable.
223  * @param length Indicates the length of the uri.
224  * @return Returns a specific error code.
225  *     {@link RDB_ERR} - Indicates that the function execution exception.
226  *     {@link RDB_OK} - success.
227  *     {@link RDB_E_INVALID_ARGS} - The error code for common invalid args.
228  * Specific error codes can be referenced {@link OH_Rdb_ErrCode}.
229  * @see Data_Asset
230  * @since 11
231  */
232 int OH_Data_Asset_GetUri(Data_Asset *asset, char *uri, size_t *length);
233 
234 /**
235  * @brief Obtains the path of the asset.
236  *
237  * @param asset Represents a pointer to an {@link Data_Asset} instance.
238  * @param path This parameter is the output parameter,
239  * and the path of the asset as a char * is written to this variable.
240  * @param length Indicates the length of the path.
241  * @return Returns a specific error code.
242  *     {@link RDB_ERR} - Indicates that the function execution exception.
243  *     {@link RDB_OK} - success.
244  *     {@link RDB_E_INVALID_ARGS} - The error code for common invalid args.
245  * Specific error codes can be referenced {@link OH_Rdb_ErrCode}.
246  * @see Data_Asset
247  * @since 11
248  */
249 int OH_Data_Asset_GetPath(Data_Asset *asset, char *path, size_t *length);
250 
251 /**
252  * @brief Obtains the create time of the asset.
253  *
254  * @param asset Represents a pointer to an {@link Data_Asset} instance.
255  * @param createTime This parameter is the output parameter,
256  * and the create time of the asset as a int64_t is written to this variable.
257  * @return Returns a specific error code.
258  *     {@link RDB_ERR} - Indicates that the function execution exception.
259  *     {@link RDB_OK} - success.
260  *     {@link RDB_E_INVALID_ARGS} - The error code for common invalid args.
261  * Specific error codes can be referenced {@link OH_Rdb_ErrCode}.
262  * @see Data_Asset
263  * @since 11
264  */
265 int OH_Data_Asset_GetCreateTime(Data_Asset *asset, int64_t *createTime);
266 
267 /**
268  * @brief Obtains the modify time of the asset.
269  *
270  * @param asset Represents a pointer to an {@link Data_Asset} instance.
271  * @param modifyTime This parameter is the output parameter,
272  * and the create time of the asset as a int64_t is written to this variable.
273  * @return Returns a specific error code.
274  *     {@link RDB_ERR} - Indicates that the function execution exception.
275  *     {@link RDB_OK} - success.
276  *     {@link RDB_E_INVALID_ARGS} - The error code for common invalid args.
277  * Specific error codes can be referenced {@link OH_Rdb_ErrCode}.
278  * @see Data_Asset
279  * @since 11
280  */
281 int OH_Data_Asset_GetModifyTime(Data_Asset *asset, int64_t *modifyTime);
282 
283 /**
284  * @brief Obtains the size of the asset.
285  *
286  * @param asset Represents a pointer to an {@link Data_Asset} instance.
287  * @param size This parameter is the output parameter,
288  * and the size of the asset as a size_t is written to this variable.
289  * @return Returns a specific error code.
290  *     {@link RDB_ERR} - Indicates that the function execution exception.
291  *     {@link RDB_OK} - success.
292  *     {@link RDB_E_INVALID_ARGS} - The error code for common invalid args.
293  * Specific error codes can be referenced {@link OH_Rdb_ErrCode}.
294  * @see Data_Asset
295  * @since 11
296  */
297 int OH_Data_Asset_GetSize(Data_Asset *asset, size_t *size);
298 
299 /**
300  * @brief Obtains the status of the asset.
301  *
302  * @param asset Represents a pointer to an {@link Data_Asset} instance.
303  * @param status This parameter is the output parameter,
304  * and the size of the status as a {@link Data_AssetStatus} is written to this variable.
305  * @return Returns a specific error code.
306  *     {@link RDB_OK} - success.
307  *     {@link RDB_E_INVALID_ARGS} - The error code for common invalid args.
308  * Specific error codes can be referenced {@link OH_Rdb_ErrCode}.
309  * @see Data_Asset Data_AssetStatus.
310  * @since 11
311  */
312 int OH_Data_Asset_GetStatus(Data_Asset *asset, Data_AssetStatus *status);
313 
314 /**
315  * @brief Creates an {@link Data_Asset} instance.
316  *
317  * @return If the creation is successful, a pointer to the instance of the @link Data_Asset} structure is returned,
318  * otherwise NULL is returned.
319  * @see Data_Asset.
320  * @since 11
321  */
322 Data_Asset *OH_Data_Asset_CreateOne(void);
323 
324 /**
325  * @brief Destroy the {@link Data_Asset} object and reclaim the memory occupied by the object.
326  *
327  * @param asset Represents a pointer to an {@link Data_Asset} instance.
328  * @return Returns the status code of the execution. Successful execution returns RDB_OK,
329  * while failure returns a specific error code.
330  *     {@link RDB_OK} - success.
331  * Specific error codes can be referenced {@link OH_Rdb_ErrCode}.
332  * @see Data_Asset, OH_Rdb_ErrCode.
333  * @since 11
334  */
335 int OH_Data_Asset_DestroyOne(Data_Asset *asset);
336 
337 /**
338  * @brief Creates {@link Data_Asset} instances of given number.
339  *
340  * @param count Represents the count of {@link Data_Asset} to create.
341  * @return If the creation is successful, a pointer to the instance of the {@link Data_Asset} structure is returned.
342  *         If the creation is unsuccessful, NULL is returned.
343  * @see Data_Asset.
344  * @since 11
345  */
346 Data_Asset **OH_Data_Asset_CreateMultiple(uint32_t count);
347 
348 /**
349  * @brief Destroy the {@link Data_Asset} objects and reclaim the memory occupied by the objects.
350  *
351  * @param assets Represents a pointer to an {@link Data_Asset} instance.
352  * @param count Represents the count of {@link Data_Asset} to destroy.
353  * @return Returns the status code of the execution. Successful execution returns RDB_OK,
354  * while failure returns a specific error code.
355  *     {@link RDB_OK} - success.
356  * Specific error codes can be referenced {@link OH_Rdb_ErrCode}.
357  * @see Data_Asset, OH_Rdb_ErrCode.
358  * @since 11
359  */
360 int OH_Data_Asset_DestroyMultiple(Data_Asset **assets, uint32_t count);
361 #ifdef __cplusplus
362 };
363 #endif
364 
365 /** @} */
366 
367 #endif // DATA_ASSET_H
368