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