diff --git a/en/native_sdk/database/data/data_asset.h b/en/native_sdk/database/data/data_asset.h new file mode 100644 index 0000000000000000000000000000000000000000..532780decd10cc1ed8818fde88ad1d0526b2aef9 --- /dev/null +++ b/en/native_sdk/database/data/data_asset.h @@ -0,0 +1,288 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef DATA_ASSET_H +#define DATA_ASSET_H + +/** + * @addtogroup Data + * @{ + * + * @brief Data (distributed data manager) supports persistence of various + * structured data on a single device, and data synchronization and sharing + * between a device and the cloud. + * It defines a series of data types for operations, such as data addition, + * deletion, modification, and query. + * + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 11 + */ + +/** + * @file data_asset.h + * + * @brief Provides the struct of the asset type. + * + * An asset is a data struct that can be used in data management. It holds the + * attributes, such as the name, absolute path, relative path, creation time, + * modification time, state, and size, of a file. + * File to include: + * @library libnative_rdb_ndk.z.so + * @since 11 + */ + +#include +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Enumerates the asset statuses. + * + * @since 11 + */ +typedef enum Data_AssetStatus { + /** The asset is null. */ + ASSET_NULL = 0, + /** The asset is in normal status. */ + ASSET_NORMAL, + /** The asset is to be inserted to the cloud. */ + ASSET_INSERT, + /** The asset is to be updated to the cloud. */ + ASSET_UPDATE, + /** The asset is to be deleted from the cloud. */ + ASSET_DELETE, + /** The asset is in abnormal status. */ + ASSET_ABNORMAL, + /** The asset is being downloaded to a local device. */ + ASSET_DOWNLOADING +} Data_AssetStatus; + +/** + * @brief Defines the data of the asset type. + * + * It provides information about an asset. + * + * @since 11 + */ +typedef struct Data_Asset Data_Asset; + +/** + * @brief Sets the name of an asset. + * + * @param asset Pointer to the {@link Data_Asset} instance. + * @param name Pointer to the name to set. + * @return Returns a specific error code. For details, see {@link OH_Rdb_ErrCode}. + * @see Data_Asset + * @since 11 + */ +int OH_Data_Asset_SetName(Data_Asset *asset, const char *name); + +/** + * @brief Sets the absolute path (that is, the URI) of an asset in the system. + * + * @param asset Pointer to the {@link Data_Asset} instance. + * @param name Pointer to the URI to set. + * @return Returns a specific error code. For details, see {@link OH_Rdb_ErrCode}. + * @see Data_Asset + * @since 11 + */ +int OH_Data_Asset_SetUri(Data_Asset *asset, const char *uri); + +/** + * @brief Sets the relative path of an asset in the application sandbox directory. + * + * @param asset Pointer to the {@link Data_Asset} instance. + * @param path Pointer to the relative path to set. + * @return Returns a specific error code. For details, see {@link OH_Rdb_ErrCode}. + * @see Data_Asset + * @since 11 + */ +int OH_Data_Asset_SetPath(Data_Asset *asset, const char *path); + +/** + * @brief Sets the creation time for an asset. + * + * @param asset Pointer to the {@link Data_Asset} instance. + * @param createTime Creation time to set. + * @return Returns a specific error code. For details, see {@link OH_Rdb_ErrCode}. + * @see Data_Asset + * @since 11 + */ +int OH_Data_Asset_SetCreateTime(Data_Asset *asset, int64_t createTime); + +/** + * @brief Sets the last modification time for an asset. + * + * @param asset Pointer to the {@link Data_Asset} instance. + * @param modifyTime Last modification time to set. + * @return Returns a specific error code. For details, see {@link OH_Rdb_ErrCode}. + * @see Data_Asset + * @since 11 + */ +int OH_Data_Asset_SetModifyTime(Data_Asset *asset, int64_t modifyTime); + +/** + * @brief Sets the size of an asset. + * + * @param asset Pointer to the {@link Data_Asset} instance. + * @param size Size of the asset to set. + * @return Returns a specific error code. For details, see {@link OH_Rdb_ErrCode}. + * @see Data_Asset + * @since 11 + */ +int OH_Data_Asset_SetSize(Data_Asset *asset, size_t size); + +/** + * @brief Sets the status of an asset. + * + * @param asset Pointer to the {@link Data_Asset} instance. + * @param status Status to set. For details, see {@link Data_AssetStatus}. + * @return Returns a specific error code. For details, see {@link OH_Rdb_ErrCode}. + * @see Data_Asset, Data_AssetStatus + * @since 11 + */ +int OH_Data_Asset_SetStatus(Data_Asset *asset, Data_AssetStatus status); + +/** + * @brief Obtains the name of an asset. + * + * @param asset Pointer to the {@link Data_Asset} instance. + * @param name Pointer to the asset name obtained, in the form of a string. + * @param length Pointer to the length of the name. + * @return Returns a specific error code. For details, see {@link OH_Rdb_ErrCode}. + * @see Data_Asset + * @since 11 + */ +int OH_Data_Asset_GetName(Data_Asset *asset, char *name, size_t *length); + +/** + * @brief Obtains the absolute path (URI) of an asset. + * + * @param asset Pointer to the {@link Data_Asset} instance. + * @param uri Pointer to the absolute path obtained, in the form of a string. + * @param length Pointer to the length of the URI. + * @return Returns a specific error code. For details, see {@link OH_Rdb_ErrCode}. + * @see Data_Asset + * @since 11 + */ +int OH_Data_Asset_GetUri(Data_Asset *asset, char *uri, size_t *length); + +/** + * @brief Obtains the relative path of an asset. + * + * @param asset Pointer to the {@link Data_Asset} instance. + * @param uri Pointer to the relative path obtained, in the form of a string. + * @param length Pointer to the length of the relative path. + * @return Returns a specific error code. For details, see {@link OH_Rdb_ErrCode}. + * @see Data_Asset + * @since 11 + */ +int OH_Data_Asset_GetPath(Data_Asset *asset, char *path, size_t *length); + +/** + * @brief Obtains the creation time of an asset. + * + * @param asset Pointer to the {@link Data_Asset} instance. + * @param createTime Pointer to the asset creation time obtained, + * in the int64_t format. + * @return Returns a specific error code. For details, see {@link OH_Rdb_ErrCode}. + * @see Data_Asset + * @since 11 + */ +int OH_Data_Asset_GetCreateTime(Data_Asset *asset, int64_t *createTime); + +/** + * @brief Obtains the last modification time of an asset. + * + * @param asset Pointer to the {@link Data_Asset} instance. + * @param modifyTime Pointer to the last modification time of the asset + * obtained, in the int64_t format. + * @return Returns a specific error code. For details, see {@link OH_Rdb_ErrCode}. + * @see Data_Asset + * @since 11 + */ +int OH_Data_Asset_GetModifyTime(Data_Asset *asset, int64_t *modifyTime); + +/** + * @brief Obtains the space occupied by an asset. + * + * @param asset Pointer to the {@link Data_Asset} instance. + * @param size Pointer to the space occupied by the asset, in the size_t format. + * @return Returns a specific error code. For details, see {@link OH_Rdb_ErrCode}. + * @see Data_Asset + * @since 11 + */ +int OH_Data_Asset_GetSize(Data_Asset *asset, size_t *size); + +/** + * @brief Obtains the status of an asset. + * + * @param asset Pointer to the {@link Data_Asset} instance. + * @param status Pointer to the asset status obtained, + * in the {@link Data_AssetStatus} format. + * @return Returns a specific error code. For details, see {@link OH_Rdb_ErrCode}. + * @see Data_Asset + * @since 11 + */ +int OH_Data_Asset_GetStatus(Data_Asset *asset, Data_AssetStatus *status); + +/** + * @brief Creates a {@link Data_Asset} instance. + * + * @return Returns the pointer to the {@link Data_Asset} instance created + * if the operation is successful; returns NULL otherwise. + * @see Data_Asset. + * @since 11 + */ +Data_Asset *OH_Data_Asset_CreateOne(); + +/** + * @brief Destroys a {@link Data_Asset} instance to reclaim the memory occupied. + * + * @param asset Pointer to the {@link Data_Asset} instance. + * @return Returns RDB_OK if the operation is successful; + * returns an error code otherwise. For details, see {@link OH_Rdb_ErrCode}. + * @see Data_Asset, OH_Rdb_ErrCode. + * @since 11 + */ +int OH_Data_Asset_DestroyOne(Data_Asset *asset); + +/** + * @brief Creates multiple {@link Data_Asset} instances. + * + * @param count Number of assets to create. + * @return Returns the pointer to the {@link Data_Asset} instance created + * if the operation is successful; returns NULL otherwise. + * @see Data_Asset. + * @since 11 + */ +Data_Asset **OH_Data_Asset_CreateMultiple(uint32_t count); + +/** + * @brief Destroys multiple {@link Data_Asset} instances to reclaim + * the memory occupied. + * + * @param assets Pointer to the {@link Data_Asset} instance. + * @param count Number of {@link Data_Asset} instances to destroy. + * @return Returns RDB_OK if the operation is successful; + * returns an error code otherwise. For details, see {@link OH_Rdb_ErrCode}. + * @see Data_Asset, OH_Rdb_ErrCode. + * @since 11 + */ +int OH_Data_Asset_DestroyMultiple(Data_Asset **assets, uint32_t count); +#ifdef __cplusplus +}; +#endif // DATA_ASSET_H diff --git a/en/native_sdk/database/rdb/oh_cursor.h b/en/native_sdk/database/rdb/oh_cursor.h index 7eeb8d68e2721230016d8a3045c37dc71e51357e..422c761fc35553efd57d360bc3d0393413400f68 100644 --- a/en/native_sdk/database/rdb/oh_cursor.h +++ b/en/native_sdk/database/rdb/oh_cursor.h @@ -35,13 +35,14 @@ * @brief Provides methods to access the result set obtained by querying an RDB store. * * A result set is a set of results returned by query(). - * @library native_rdb_ndk_header.so + * @library libnative_rdb_ndk.z.so * @since 10 */ #include #include #include +#include "database/rdb/data_asset.h" #ifdef __cplusplus extern "C" { #endif @@ -62,6 +63,18 @@ typedef enum OH_ColumnType { TYPE_TEXT, /** BLOB */ TYPE_BLOB, + /** + * @brief ASSET + * + * @since 11 + */ + TYPE_ASSET, + /** + * @brief ASSETS + * + * @since 11 + */ + TYPE_ASSETS, } OH_ColumnType; /** @@ -78,8 +91,8 @@ typedef struct OH_Cursor { /** * @brief Obtains the number of columns in a result set. * - * @param cursor Indicates the pointer to the {@link OH_Cursor} instance. - * @param count Indicates the pointer to the number of columns in the result set obtained. + * @param cursor Pointer to the {@link OH_Cursor} instance. + * @param count Pointer to the number of columns in the result set obtained. * @return Returns the operation result. If the operation fails, an error code is returned. * @see OH_Cursor. * @since 10 @@ -89,9 +102,9 @@ typedef struct OH_Cursor { /** * @brief Obtains the type of the data in the column specified by the column index. * - * @param cursor Indicates the pointer to the {@link OH_Cursor} instance. - * @param columnIndex Indicates the index of the column in the result set. - * @param columnType Indicates the pointer to the data type obtained. For details, see {@link OH_ColumnType}. + * @param cursor Pointer to the {@link OH_Cursor} instance. + * @param columnIndex Index of the column in the result set. + * @param columnType Pointer to the data type obtained. For details, see {@link OH_ColumnType}. * @return Returns the operation result. If the operation fails, an error code is returned. * @see OH_Cursor, OH_ColumnType. * @since 10 @@ -101,9 +114,9 @@ typedef struct OH_Cursor { /** * @brief Obtains the column index based on the specified column name. * - * @param cursor Indicates the pointer to the {@link OH_Cursor} instance. - * @param name Indicates the pointer to the name of the column in the result set. - * @param columnIndex Indicates the pointer to the index of the column obtained. + * @param cursor Pointer to the {@link OH_Cursor} instance. + * @param name Pointer to the name of the column in the result set. + * @param columnIndex Pointer to the index of the column obtained. * @return Returns the operation result. If the operation fails, an error code is returned. * @see OH_Cursor. * @since 10 @@ -113,10 +126,10 @@ typedef struct OH_Cursor { /** * @brief Obtains the column name based on the specified column index. * - * @param cursor Indicates the pointer to the {@link OH_Cursor} instance. - * @param columnIndex Indicates the index of the column in the result set. - * @param name Indicates the pointer to the column name obtained. - * @param length Indicates the length of the column name obtained. + * @param cursor Pointer to the {@link OH_Cursor} instance. + * @param columnIndex Index of the column in the result set. + * @param name Pointer to the column name obtained. + * @param length Length of the column name obtained. * @return Returns the operation result. If the operation fails, an error code is returned. * @see OH_Cursor. * @since 10 @@ -126,8 +139,8 @@ typedef struct OH_Cursor { /** * @brief Obtains the number of rows in a result set. * - * @param cursor Indicates the pointer to the {@link OH_Cursor} instance. - * @param count Indicates the pointer to the number of rows in the result set obtained. + * @param cursor Pointer to the {@link OH_Cursor} instance. + * @param count Pointer to the number of rows in the result set obtained. * @return Returns the operation result. If the operation fails, an error code is returned. * @see OH_Cursor. * @since 10 @@ -137,7 +150,7 @@ typedef struct OH_Cursor { /** * @brief Goes to the next row of the result set. * - * @param cursor Indicates the pointer to the {@link OH_Cursor} instance. + * @param cursor Pointer to the {@link OH_Cursor} instance. * @return Returns the operation result. If the operation fails, an error code is returned. * @see OH_Cursor. * @since 10 @@ -147,9 +160,9 @@ typedef struct OH_Cursor { /** * @brief Obtains information about the memory required when the column data type in the result set is BLOB or TEXT. * - * @param cursor Indicates the pointer to the {@link OH_Cursor} instance. - * @param columnIndex Indicates the index of the column in the result set. - * @param size Indicates the pointer to the memory size obtained. + * @param cursor Pointer to the {@link OH_Cursor} instance. + * @param columnIndex Index of the column in the result set. + * @param size Pointer to the memory size obtained. * @return Returns the operation result. If the operation fails, an error code is returned. * @see OH_Cursor. * @since 10 @@ -159,10 +172,10 @@ typedef struct OH_Cursor { /** * @brief Obtains the value in the form of a string based on the specified column and the current row. * - * @param cursor Indicates the pointer to the {@link OH_Cursor} instance. - * @param columnIndex Indicates the index of the column in the result set. - * @param value Indicates the pointer to the string obtained. - * @param length Indicates the length of the value, which is obtained by getSize(). + * @param cursor Pointer to the {@link OH_Cursor} instance. + * @param columnIndex Index of the column in the result set. + * @param value Pointer to the string obtained. + * @param length Length of the value, which is obtained by getSize(). * @return Returns the operation result. If the operation fails, an error code is returned. * @see OH_Cursor. * @since 10 @@ -172,9 +185,9 @@ typedef struct OH_Cursor { /** * @brief Obtains the value of the int64_t type based on the specified column and the current row. * - * @param cursor Indicates the pointer to the {@link OH_Cursor} instance. - * @param columnIndex Indicates the index of the column in the result set. - * @param value Indicates the pointer to the value obtained. + * @param cursor Pointer to the {@link OH_Cursor} instance. + * @param columnIndex Index of the column in the result set. + * @param value Pointer to the value obtained. * @return Returns the operation result. If the operation fails, an error code is returned. * @see OH_Cursor. * @since 10 @@ -184,9 +197,9 @@ typedef struct OH_Cursor { /** * @brief Obtains the value of the double type based on the specified column and the current row. * - * @param cursor Indicates the pointer to the {@link OH_Cursor} instance. - * @param columnIndex Indicates the index of the column in the result set. - * @param value Indicates the pointer to the value obtained. + * @param cursor Pointer to the {@link OH_Cursor} instance. + * @param columnIndex Index of the column in the result set. + * @param value Pointer to the value obtained. * @return Returns the operation result. If the operation fails, an error code is returned. * @see OH_Cursor. * @since 10 @@ -196,10 +209,10 @@ typedef struct OH_Cursor { /** * @brief Obtains the value in the form of a byte array based on the specified column and the current row. * - * @param cursor Indicates the pointer to the {@link OH_Cursor} instance. - * @param columnIndex Indicates the index of the column in the result set. - * @param value Indicates the pointer to the string obtained. - * @param length Indicates the length of the value, which is obtained by getSize(). + * @param cursor Pointer to the {@link OH_Cursor} instance. + * @param columnIndex Index of the column in the result set. + * @param value Pointer to the string obtained. + * @param length Length of the value, which is obtained by getSize(). * @return Returns the operation result. If the operation fails, an error code is returned. * @see OH_Cursor. * @since 10 @@ -209,9 +222,9 @@ typedef struct OH_Cursor { /** * @brief Checks whether the value in the specified column is null. * - * @param cursor Indicates the pointer to the {@link OH_Cursor} instance. - * @param columnIndex Indicates the index of the column in the result set. - * @param isNull Indicates the pointer to the check result. The value true means the value is null; + * @param cursor Pointer to the {@link OH_Cursor} instance. + * @param columnIndex Index of the column in the result set. + * @param isNull Pointer to the check result. The value true means the value is null; * the value false means the opposite. * @return Returns the operation result. If the operation fails, an error code is returned. * @see OH_Cursor. @@ -222,12 +235,37 @@ typedef struct OH_Cursor { /** * @brief Destroys a result set. * - * @param cursor Indicates the pointer to the {@link OH_Cursor} instance. + * @param cursor Pointer to the {@link OH_Cursor} instance. * @return Returns the operation result. If the operation fails, an error code is returned. * @see OH_Cursor. * @since 10 */ int (*destroy)(OH_Cursor *cursor); + + /** + * @brief Obtains the value of the asset type based on the specified column and current row. + * + * @param cursor Pointer to the {@link OH_Cursor} instance. + * @param columnIndex Index of the column in the result set. + * @param value Pointer to the value obtained. + * @return Returns the operation result. If the operation fails, an error code is returned. + * @see OH_Cursor. + * @since 11 + */ + int (*getAsset)(OH_Cursor *cursor, int32_t columnIndex, Data_Asset *value); + + /** + * @brief Obtains the values of the assets type based on the specified column and current row. + * + * @param cursor Pointer to the {@link OH_Cursor} instance. + * @param columnIndex Index of the column in the result set. + * @param value Pointer to the values obtained. + * @param length Length of the asset array. + * @return Returns the operation result. If the operation fails, an error code is returned. + * @see OH_Cursor. + * @since 11 + */ + int (*getAssets)(OH_Cursor *cursor, int32_t columnIndex, Data_Asset **value, uint32_t length); } OH_Cursor; #ifdef __cplusplus diff --git a/en/native_sdk/database/rdb/oh_predicates.h b/en/native_sdk/database/rdb/oh_predicates.h index ed900b1bbc382d0b886ab0e8b3be1f9fee70162c..c1774ecc8614cb5a5c5edebd10c730df8033fc8b 100644 --- a/en/native_sdk/database/rdb/oh_predicates.h +++ b/en/native_sdk/database/rdb/oh_predicates.h @@ -33,7 +33,7 @@ * @file oh_predicates.h * * @brief Represents a predicate for a relational database (RDB). - * @library native_rdb_ndk_header.so + * @library libnative_rdb_ndk.z.so * @since 10 */ @@ -71,9 +71,9 @@ typedef struct OH_Predicates { * * This method is equivalent to "=" in SQL statements. * - * @param predicates Indicates the pointer to the {@link OH_Predicates} instance. - * @param field Indicates the pointer to the column name in the database table. - * @param valueObject Indicates the pointer to the {@link OH_VObject} instance, which is the value to match. + * @param predicates Pointer to the {@link OH_Predicates} instance. + * @param field Pointer to the column name in the database table. + * @param valueObject Pointer to the {@link OH_VObject} instance, which is the value to match. * @return Returns the Predicates instance created. * @see OH_Predicates, OH_VObject. * @since 10 @@ -85,9 +85,9 @@ typedef struct OH_Predicates { * * This method is equivalent to "!=" in SQL statements. * - * @param predicates Indicates the pointer to the {@link OH_Predicates} instance. - * @param field Indicates the pointer to the column name in the database table. - * @param valueObject Indicates the pointer to the {@link OH_VObject} instance, which is the value to match. + * @param predicates Pointer to the {@link OH_Predicates} instance. + * @param field Pointer to the column name in the database table. + * @param valueObject Pointer to the {@link OH_VObject} instance, which is the value to match. * @return Returns the Predicates instance created. * @see OH_Predicates, OH_VObject. * @since 10 @@ -99,7 +99,7 @@ typedef struct OH_Predicates { * * This method is equivalent to "(" in SQL statements. * - * @param predicates Indicates the pointer to the {@link OH_Predicates} instance. + * @param predicates Pointer to the {@link OH_Predicates} instance. * @return Returns a Predicates instance with a left parenthesis. * @see OH_Predicates. * @since 10 @@ -111,7 +111,7 @@ typedef struct OH_Predicates { * * This method is equivalent to ")" in SQL statements. * - * @param predicates Indicates the pointer to the {@link OH_Predicates} instance. + * @param predicates Pointer to the {@link OH_Predicates} instance. * @return Returns a Predicates instance with a right parenthesis. * @see OH_Predicates. * @since 10 @@ -123,7 +123,7 @@ typedef struct OH_Predicates { * * This method is equivalent to "OR" in SQL statements. * - * @param predicates Indicates the pointer to the {@link OH_Predicates} instance. + * @param predicates Pointer to the {@link OH_Predicates} instance. * @return Returns a Predicates instance with the OR operator. * @see OH_Predicates. * @since 10 @@ -135,7 +135,7 @@ typedef struct OH_Predicates { * * This method is equivalent to "AND" in SQL statements. * - * @param predicates Indicates the pointer to the {@link OH_Predicates} instance. + * @param predicates Pointer to the {@link OH_Predicates} instance. * @return Returns a Predicates instance with the AND operator. * @see OH_Predicates. * @since 10 @@ -147,8 +147,8 @@ typedef struct OH_Predicates { * * This method is equivalent to "IS NULL" in SQL statements. * - * @param predicates Indicates the pointer to the {@link OH_Predicates} instance. - * @param field Indicates the pointer to the column name in the database table. + * @param predicates Pointer to the {@link OH_Predicates} instance. + * @param field Pointer to the column name in the database table. * @return Returns the Predicates instance created. * @see OH_Predicates. * @since 10 @@ -160,8 +160,8 @@ typedef struct OH_Predicates { * * This method is equivalent to "IS NOT NULL" in SQL statements. * - * @param predicates Indicates the pointer to the {@link OH_Predicates} instance. - * @param field Indicates the pointer to the column name in the database table. + * @param predicates Pointer to the {@link OH_Predicates} instance. + * @param field Pointer to the column name in the database table. * @return Returns the Predicates instance created. * @see OH_Predicates. * @since 10 @@ -173,9 +173,9 @@ typedef struct OH_Predicates { * * This method is equivalent to "LIKE" in SQL statements. * - * @param predicates Indicates the pointer to the {@link OH_Predicates} instance. - * @param field Indicates the pointer to the column name in the database table. - * @param valueObject Indicates the pointer to the {@link OH_VObject} instance, which is the value to match. + * @param predicates Pointer to the {@link OH_Predicates} instance. + * @param field Pointer to the column name in the database table. + * @param valueObject Pointer to the {@link OH_VObject} instance, which is the value to match. * @return Returns the Predicates instance created. * @see OH_Predicates, OH_VObject. * @since 10 @@ -187,9 +187,9 @@ typedef struct OH_Predicates { * * This method is equivalent to "BETWEEN" in SQL statements. * - * @param predicates Indicates the pointer to the {@link OH_Predicates} instance. - * @param field Indicates the pointer to the column name in the database table. - * @param valueObject Indicates the pointer to the {@link OH_VObject} instance, which is the value range to match. + * @param predicates Pointer to the {@link OH_Predicates} instance. + * @param field Pointer to the column name in the database table. + * @param valueObject Pointer to the {@link OH_VObject} instance, which is the value range to match. * @return Returns the Predicates instance created. * @see OH_Predicates, OH_VObject. * @since 10 @@ -201,9 +201,9 @@ typedef struct OH_Predicates { * * This method is equivalent to "NOT BETWEEN" in SQL statements. * - * @param predicates Indicates the pointer to the {@link OH_Predicates} instance. - * @param field Indicates the pointer to the column name in the database table. - * @param valueObject Indicates the pointer to the {@link OH_VObject} instance, which is the range to match. + * @param predicates Pointer to the {@link OH_Predicates} instance. + * @param field Pointer to the column name in the database table. + * @param valueObject Pointer to the {@link OH_VObject} instance, which is the range to match. * @return Returns the Predicates instance created. * @see OH_Predicates, OH_VObject. * @since 10 @@ -215,9 +215,9 @@ typedef struct OH_Predicates { * * This method is equivalent to ">" in SQL statements. * - * @param predicates Indicates the pointer to the {@link OH_Predicates} instance. - * @param field Indicates the pointer to the column name in the database table. - * @param valueObject Indicates the pointer to the {@link OH_VObject} instance, which is the value to match. + * @param predicates Pointer to the {@link OH_Predicates} instance. + * @param field Pointer to the column name in the database table. + * @param valueObject Pointer to the {@link OH_VObject} instance, which is the value to match. * @return Returns the Predicates instance created. * @see OH_Predicates, OH_VObject. * @since 10 @@ -229,9 +229,9 @@ typedef struct OH_Predicates { * * This method is equivalent to "<" in SQL statements. * - * @param predicates Indicates the pointer to the {@link OH_Predicates} instance. - * @param field Indicates the pointer to the column name in the database table. - * @param valueObject Indicates the pointer to the {@link OH_VObject} instance, which is the value to match. + * @param predicates Pointer to the {@link OH_Predicates} instance. + * @param field Pointer to the column name in the database table. + * @param valueObject Pointer to the {@link OH_VObject} instance, which is the value to match. * @return Returns the Predicates instance created. * @see OH_Predicates, OH_VObject. * @since 10 @@ -243,9 +243,9 @@ typedef struct OH_Predicates { * the specified value. * This method is equivalent to ">=" in SQL statements. * - * @param predicates Indicates the pointer to the {@link OH_Predicates} instance. - * @param field Indicates the pointer to the column name in the database table. - * @param valueObject Indicates the pointer to the {@link OH_VObject} instance, which is the value to match. + * @param predicates Pointer to the {@link OH_Predicates} instance. + * @param field Pointer to the column name in the database table. + * @param valueObject Pointer to the {@link OH_VObject} instance, which is the value to match. * @return Returns the Predicates instance created. * @see OH_Predicates, OH_VObject. * @since 10 @@ -257,9 +257,9 @@ typedef struct OH_Predicates { * * This method is equivalent to "<=" in SQL statements. * - * @param predicates Indicates the pointer to the {@link OH_Predicates} instance. - * @param field Indicates the pointer to the column name in the database table. - * @param valueObject Indicates the pointer to the {@link OH_VObject} instance, which is the value to match. + * @param predicates Pointer to the {@link OH_Predicates} instance. + * @param field Pointer to the column name in the database table. + * @param valueObject Pointer to the {@link OH_VObject} instance, which is the value to match. * @return Returns the Predicates instance created. * @see OH_Predicates, OH_VObject. * @since 10 @@ -271,9 +271,9 @@ typedef struct OH_Predicates { * * This method is equivalent to "ORDER BY" in SQL statements. * - * @param predicates Indicates the pointer to the {@link OH_Predicates} instance. - * @param field Indicates the pointer to the column name in the database table. - * @param type Indicates the sorting type {@link OH_OrderType}. + * @param predicates Pointer to the {@link OH_Predicates} instance. + * @param field Pointer to the column name in the database table. + * @param type Sorting type {@link OH_OrderType}. * @return Returns the Predicates instance created. * @see OH_Predicates, OH_OrderType. * @since 10 @@ -285,7 +285,7 @@ typedef struct OH_Predicates { * * This method is equivalent to "DISTINCT" in SQL statements. * - * @param predicates Indicates the pointer to the {@link OH_Predicates} instance. + * @param predicates Pointer to the {@link OH_Predicates} instance. * @return Returns a Predicates instance that can filter duplicate records. * @see OH_Predicates. * @since 10 @@ -297,8 +297,8 @@ typedef struct OH_Predicates { * * This method is equivalent to "LIMIT" in SQL statements. * - * @param predicates Indicates the pointer to the {@link OH_Predicates} instance. - * @param value Indicates the maximum number of data records. + * @param predicates Pointer to the {@link OH_Predicates} instance. + * @param value Maximum number of data records. * @return Returns the Predicates instance created. * @see OH_Predicates. * @since 10 @@ -310,8 +310,8 @@ typedef struct OH_Predicates { * * This method is equivalent to "OFFSET" in SQL statements. * - * @param predicates Indicates the pointer to the {@link OH_Predicates} instance. - * @param rowOffset Indicates the start position of the returned result. The value is a positive integer. + * @param predicates Pointer to the {@link OH_Predicates} instance. + * @param rowOffset Start position of the returned result. The value is a positive integer. * @return Returns the Predicates instance created. * @see OH_Predicates. * @since 10 @@ -324,9 +324,9 @@ typedef struct OH_Predicates { * * This method is equivalent to "GROUP BY" in SQL statements. * - * @param predicates Indicates the pointer to the {@link OH_Predicates} instance. - * @param fields Indicates the pointer to the columns to group. - * @param length Indicates the length of the fields value. + * @param predicates Pointer to the {@link OH_Predicates} instance. + * @param fields Pointer to the columns to group. + * @param length Length of the fields value. * @return Returns the Predicates instance created. * @see OH_Predicates. * @since 10 @@ -338,9 +338,9 @@ typedef struct OH_Predicates { * * This method is equivalent to "IN" in SQL statements. * - * @param predicates Indicates the pointer to the {@link OH_Predicates} instance. - * @param field Indicates the pointer to the name of the column in the database table. - * @param valueObject Indicates the pointer to the {@link OH_VObject} instance, which is the value to match. + * @param predicates Pointer to the {@link OH_Predicates} instance. + * @param field Pointer to the name of the column in the database table. + * @param valueObject Pointer to the {@link OH_VObject} instance, which is the value to match. * @return Returns the Predicates instance created. * @see OH_Predicates, OH_VObject. * @since 10 @@ -352,9 +352,9 @@ typedef struct OH_Predicates { * * This method is equivalent to "NOT IN" in SQL statements. * - * @param predicates Indicates the pointer to the {@link OH_Predicates} instance. - * @param field Indicates the pointer to the name of the column in the database table. - * @param valueObject Indicates the pointer to the {@link OH_VObject} instance, which is the value to match. + * @param predicates Pointer to the {@link OH_Predicates} instance. + * @param field Pointer to the name of the column in the database table. + * @param valueObject Pointer to the {@link OH_VObject} instance, which is the value to match. * @return Returns the Predicates instance created. * @see OH_Predicates, OH_VObject. * @since 10 @@ -365,7 +365,7 @@ typedef struct OH_Predicates { /** * @brief Clears a Predicates instance. * - * @param predicates Indicates the pointer to the {@link OH_Predicates} instance. + * @param predicates Pointer to the {@link OH_Predicates} instance. * @return Returns the Predicates instance cleared. * @see OH_Predicates. * @since 10 @@ -376,7 +376,7 @@ typedef struct OH_Predicates { /** * @brief Destroys a {@link OH_Predicates} instance and reclaims the memory occupied. * - * @param predicates Indicates the pointer to the {@link OH_Predicates} instance. + * @param predicates Pointer to the {@link OH_Predicates} instance. * @return Returns the operation result. If the operation fails, an error code is returned. * @see OH_Predicates. * @since 10 diff --git a/en/native_sdk/database/rdb/oh_value_object.h b/en/native_sdk/database/rdb/oh_value_object.h index 621ef04bfa2ead9418f88cf7978e10df26b0185e..361affca0410ba429c40b32efa0798a1e048085c 100644 --- a/en/native_sdk/database/rdb/oh_value_object.h +++ b/en/native_sdk/database/rdb/oh_value_object.h @@ -33,7 +33,7 @@ * @file oh_value_object.h * * @brief Provides data conversion methods. - * + * @library libnative_rdb_ndk.z.so * @since 10 */ @@ -54,9 +54,9 @@ typedef struct OH_VObject { /** * @brief Converts an int64 value or array into a value of the {@link OH_VObject} type. * - * @param valueObject Indicates the pointer to the {@link OH_VObject} instance. - * @param value Indicates the pointer to the value or array to convert. - * @param count Indicates the number or length of the parameters to convert. + * @param valueObject Pointer to the {@link OH_VObject} instance. + * @param value Pointer to the value or array to convert. + * @param count Number or length of the parameters to convert. * If value points to a single parameter, count is 1. * If value points to an array, count specifies the length of the array. * @return Returns the operation result. If the operation fails, an error code is returned. @@ -68,9 +68,9 @@ typedef struct OH_VObject { /** * @brief Converts a double value or array into a value of the {@link OH_VObject} type. * - * @param valueObject Indicates the pointer to the {@link OH_VObject} instance. - * @param value Indicates the pointer to the double value or array to convert. - * @param count Indicates the number or length of the parameters to convert. + * @param valueObject Pointer to the {@link OH_VObject} instance. + * @param value Pointer to the double value or array to convert. + * @param count Number or length of the parameters to convert. * If value points to a single parameter, count is 1. * If value points to an array, count specifies the length of the array. * @return Returns the operation result. If the operation fails, an error code is returned. @@ -82,8 +82,8 @@ typedef struct OH_VObject { /** * @brief Converts a character array of the char type into a value of the {@link OH_VObject} type. * - * @param valueObject Indicates the pointer to the {@link OH_VObject} instance. - * @param value Indicates the pointer to the character array to convert. + * @param valueObject Pointer to the {@link OH_VObject} instance. + * @param value Pointer to the character array to convert. * @return Returns the operation result. If the operation fails, an error code is returned. * @see OH_VObject. * @since 10 @@ -93,9 +93,9 @@ typedef struct OH_VObject { /** * @brief Converts a string array of the char type into a value of the {@link OH_VObject} type. * - * @param valueObject Indicates the pointer to the {@link OH_VObject} instance. - * @param value Indicates the pointer to the string array to convert. - * @param count Indicates the length of the string array to convert. + * @param valueObject Pointer to the {@link OH_VObject} instance. + * @param value Pointer to the string array to convert. + * @param count Length of the string array to convert. * @return Returns the operation result. If the operation fails, an error code is returned. * @see OH_VObject. * @since 10 @@ -105,12 +105,12 @@ typedef struct OH_VObject { /** * @brief Destroys a {@link OH_VObject} instance and reclaims the memory occupied. * - * @param valueObject Indicates the pointer to the {@link OH_VObject} instance. + * @param valueObject Pointer to the {@link OH_VObject} instance. * @return Returns the operation result. If the operation fails, an error code is returned. * @see OH_VObject. * @since 10 */ - int (*destroyValueObject)(OH_VObject *valueObject); + int (*destroy)(OH_VObject *valueObject); } OH_VObject; #ifdef __cplusplus diff --git a/en/native_sdk/database/rdb/oh_values_bucket.h b/en/native_sdk/database/rdb/oh_values_bucket.h index 67486b2691ec3aa172cdd7e4632b55425c5d86ea..1754770d2df2f27a767c8db7198a8086ab05895d 100644 --- a/en/native_sdk/database/rdb/oh_values_bucket.h +++ b/en/native_sdk/database/rdb/oh_values_bucket.h @@ -33,11 +33,12 @@ * @file oh_values_bucket.h * * @brief Defines the types of the key and value in a key-value (KV) pair. - * @library native_rdb_ndk_header.so + * @library libnative_rdb_ndk.z.so * @since 10 */ #include +#include "database/data/data_asset" #ifdef __cplusplus extern "C" { #endif @@ -57,9 +58,9 @@ typedef struct OH_VBucket { /** * @brief Puts a char value into the {@link OH_VBucket} instance in the given column. * - * @param bucket Indicates the pointer to the {@link OH_VBucket} instance. - * @param field Indicates the pointer to the column name. - * @param value Indicates the pointer to the value to put. + * @param bucket Pointer to the {@link OH_VBucket} instance. + * @param field Pointer to the column name. + * @param value Pointer to the value to put. * @return Returns the operation result. If the operation fails, an error code is returned. * @see OH_VBucket. * @since 10 @@ -69,9 +70,9 @@ typedef struct OH_VBucket { /** * @brief Puts an int64_t value into the {@link OH_VBucket} instance in the given column. * - * @param bucket Indicates the pointer to the {@link OH_VBucket} instance. - * @param field Indicates the pointer to the column name. - * @param value Indicates the value to put. + * @param bucket Pointer to the {@link OH_VBucket} instance. + * @param field Pointer to the column name. + * @param value Pointer to the value to put. * @return Returns the operation result. If the operation fails, an error code is returned. * @see OH_VBucket. * @since 10 @@ -81,9 +82,9 @@ typedef struct OH_VBucket { /** * @brief Puts a double value into the {@link OH_VBucket} instance in the given column. * - * @param bucket Indicates the pointer to the {@link OH_VBucket} instance. - * @param field Indicates the pointer to the column name. - * @param value Indicates the value to put. + * @param bucket Pointer to the {@link OH_VBucket} instance. + * @param field Pointer to the column name. + * @param value Pointer to the value to put. * @return Returns the operation result. If the operation fails, an error code is returned. * @see OH_VBucket. * @since 10 @@ -93,10 +94,10 @@ typedef struct OH_VBucket { /** * @brief Puts a const uint8_t value into the {@link OH_VBucket} object in the given column. * - * @param bucket Indicates the pointer to the {@link OH_VBucket} instance. - * @param field Indicates the pointer to the column name. - * @param value Indicates the pointer to the value to put. - * @param size Indicates the length of the value. + * @param bucket Pointer to the {@link OH_VBucket} instance. + * @param field Pointer to the column name. + * @param value Pointer to the value to put. + * @param size Length of the value. * @return Returns the operation result. If the operation fails, an error code is returned. * @see OH_VBucket. * @since 10 @@ -106,8 +107,8 @@ typedef struct OH_VBucket { /** * @brief Puts null into the {@link OH_VBucket} instance in the given column. * - * @param bucket Indicates the pointer to the {@link OH_VBucket} instance. - * @param field Indicates the pointer to the column name. + * @param bucket Pointer to the {@link OH_VBucket} instance. + * @param field Pointer to the column name. * @return Returns the operation result. If the operation fails, an error code is returned. * @see OH_VBucket. * @since 10 @@ -117,7 +118,7 @@ typedef struct OH_VBucket { /** * @brief Clears an {@link OH_VBucket} instance. * - * @param bucket Indicates the pointer to the {@link OH_VBucket} instance. + * @param bucket Pointer to the {@link OH_VBucket} instance. * @return Returns the operation result. If the operation fails, an error code is returned. * @see OH_VBucket. * @since 10 @@ -127,7 +128,7 @@ typedef struct OH_VBucket { /** * @brief Destroys a {@link OH_VBucket} instance and reclaims the memory occupied. * - * @param bucket Indicates the pointer to the {@link OH_VBucket} instance. + * @param bucket Pointer to the {@link OH_VBucket} instance. * @return Returns the operation result. If the operation fails, an error code is returned. * @see OH_VBucket. * @since 10 @@ -135,6 +136,31 @@ typedef struct OH_VBucket { int (*destroy)(OH_VBucket *bucket); } OH_VBucket; +/** + * @brief Puts an object of the {@link OH_Asset} type into the {@link OH_VBucket} instance in the given column. + * + * @param bucket Pointer to the {@link OH_VBucket} instance. + * @param field Pointer to the column name. + * @param value Pointer to the value to put. + * @return Returns the operation result. If the operation fails, an error code is returned. + * @see OH_VBucket. + * @since 11 + */ +int OH_VBucket_PutAsset(OH_VBucket *bucket, const char *field, OH_Asset *value); + +/** + * @brief Puts an object of the {@link OH_Asset} array into the {@link OH_VBucket} instance in the given column. + * + * @param bucket Pointer to the {@link OH_VBucket} instance. + * @param field Pointer to the column name. + * @param value Pointer to the values to put. + * @param count Number of elements in the {@link OH_Asset} array. + * @return Returns the operation result. If the operation fails, an error code is returned. + * @see OH_VBucket. + * @since 11 + */ +int OH_VBucket_PutAssets(OH_VBucket *bucket, const char *field, OH_Asset **value, int count); + #ifdef __cplusplus }; #endif diff --git a/en/native_sdk/database/rdb/relational_store.h b/en/native_sdk/database/rdb/relational_store.h index bd3873ce20f96049ba7b3e3bda65809645a90974..498fe35f8e6d55f54098055672592b1e045baee8 100644 --- a/en/native_sdk/database/rdb/relational_store.h +++ b/en/native_sdk/database/rdb/relational_store.h @@ -34,7 +34,7 @@ * @file relational_store.h * * @brief Provides methods for managing relational database (RDB) stores. - * @library native_rdb_ndk_header.so + * @library libnative_rdb_ndk.z.so * @since 10 */ @@ -79,6 +79,30 @@ typedef enum OH_Rdb_SecurityLevel { S4 } OH_Rdb_SecurityLevel; +/** + * @brief Enumerates the security levels of the database directories. + * + * @since 11 + */ +typedef enum Rdb_SecurityArea { + /** + * @brief The security level of the database directory is 1. + */ + RDB_SECURITY_AREA_EL1 = 1, + /** + * @brief The security level of the database directory is 2. + */ + RDB_SECURITY_AREA_EL2, + /** + * @brief The security level of the database directory is 3. + */ + RDB_SECURITY_AREA_EL3, + /** + * @brief The security level of the database directory is 4. + */ + RDB_SECURITY_AREA_EL4, +} Rdb_SecurityArea; + /** * @brief Defines the RDB store configuration. * @@ -88,18 +112,24 @@ typedef enum OH_Rdb_SecurityLevel { typedef struct { /** Size of the struct. */ int selfSize; - /** Database file path. */ + /** Path of the database file. */ const char *dataBaseDir; /** RDB store name. */ const char *storeName; /** Application bundle name. */ const char *bundleName; - /** Application module name. */ + /** Module name. */ const char *moduleName; /** Whether to encrypt the RDB store. */ bool isEncrypt; - /** RDB store security level. For details, see {@link OH_Rdb_SecurityLevel}. */ + /** Security level of the RDB store. For details, see {@link OH_Rdb_SecurityLevel}. */ int securityLevel; + /** + * Security level of the database directory. For details, see {@link Rdb_SecurityArea}. + * + * @since 11 + */ + int area; } OH_Rdb_Config; #pragma pack() @@ -136,7 +166,7 @@ OH_VBucket *OH_Rdb_CreateValuesBucket(void); /** * @brief Creates an {@link OH_Predicates} instance. * - * @param table Indicates the pointer to the name of the database table. + * @param table Pointer to the name of the database table. * @return Returns the pointer to the {@link OH_Predicates} instance created if the operation is successful; * returns NULL otherwise. * @see OH_Predicates. @@ -147,8 +177,8 @@ OH_Predicates *OH_Rdb_CreatePredicates(const char *table); /** * @brief Obtains an {@link OH_Rdb_Store} instance for RDB store operations. * - * @param config Indicates the pointer to the {@link OH_Rdb_Config} instance, which is the RDB store configuration. - * @param errCode Indicates the pointer to the function execution status. + * @param config Pointer to the {@link OH_Rdb_Config} instance, which is the configuration of the RDB store. + * @param errCode Pointer to the function execution status. * @return Returns the pointer to the {@link OH_Rdb_Store} instance created if the operation is successful; * returns NULL otherwise. * @see OH_Rdb_Config, OH_Rdb_Store. @@ -159,7 +189,7 @@ OH_Rdb_Store *OH_Rdb_GetOrOpen(const OH_Rdb_Config *config, int *errCode); /** * @brief Destroys a {@link OH_Rdb_Store} instance and reclaims the memory occupied. * - * @param store Indicates the pointer to the {@link OH_Rdb_Store} instance. + * @param store Pointer to the {@link OH_Rdb_Store} instance. * @return Returns the operation result. If the operation fails, an error code is returned. * @see OH_Rdb_Store. * @since 10 @@ -169,7 +199,7 @@ int OH_Rdb_CloseStore(OH_Rdb_Store *store); /** * @brief Deletes an RDB store based on the specified database file configuration. * - * @param path Indicates the pointer to the database file path. + * @param path Pointer to the database file path. * @return Returns the operation result. If the operation fails, an error code is returned. * @since 10 */ @@ -178,9 +208,9 @@ int OH_Rdb_DeleteStore(const OH_Rdb_Config *config); /** * @brief Insert a row of data into a table. * - * @param store Indicates the pointer to the {@link OH_Rdb_Store} instance. - * @param table Indicates the pointer to the name of the target table. - * @param valuesBucket Indicates the pointer to the data row {@link OH_VBucket} to insert. + * @param store Pointer to the {@link OH_Rdb_Store} instance. + * @param table Pointer to the name of the target table. + * @param valuesBucket Pointer to the data row {@link OH_VBucket} to insert. * @return Returns the row ID if the operation is successful; returns an error code otherwise. * @see OH_Rdb_Store, OH_VBucket. * @since 10 @@ -190,9 +220,9 @@ int OH_Rdb_Insert(OH_Rdb_Store *store, const char *table, OH_VBucket *valuesBuck /** * @brief Updates data in an RDB store based on specified conditions. * - * @param store Indicates the pointer to the {@link OH_Rdb_Store} instance. - * @param valuesBucket Indicates the pointer to the data {@link OH_VBucket} to be written to the table. - * @param predicates Indicates the pointer to the {@link OH_Predicates} instance, which specifies the update conditions. + * @param store Pointer to the {@link OH_Rdb_Store} instance. + * @param valuesBucket Pointer to the data {@link OH_VBucket} to be written to the table. + * @param predicates Pointer to the {@link OH_Predicates} instance, which specifies the update conditions. * @return Returns the number of updated rows if the operation is successful; returns an error code otherwise. * @see OH_Rdb_Store, OH_Bucket, OH_Predicates. * @since 10 @@ -202,9 +232,8 @@ int OH_Rdb_Update(OH_Rdb_Store *store, OH_VBucket *valuesBucket, OH_Predicates * /** * @brief Deletes data from an RDB store based on specified conditions. * - * @param store Indicates the pointer to the {@link OH_Rdb_Store} instance. - * @param predicates Indicates the pointer to the {@link OH_Predicates} instance, which specifies the deletion - * conditions. + * @param store Pointer to the {@link OH_Rdb_Store} instance. + * @param predicates Pointer to the {@link OH_Predicates} instance, which specifies the deletion conditions. * @return Returns the number of rows deleted if the operation is successful; returns an error code otherwise. * @see OH_Rdb_Store, OH_Predicates. * @since 10 @@ -214,11 +243,12 @@ int OH_Rdb_Delete(OH_Rdb_Store *store, OH_Predicates *predicates); /** * @brief Queries data in an RDB store based on specified conditions. * - * @param store Indicates the pointer to the {@link OH_Rdb_Store} instance. - * @param predicates Indicates the pointer to the {@link OH_Predicates} instance, which specifies the query conditions. - * @param columnNames Indicates the pointer to the columns to be queried. If this parameter is not specified, - * the query applies to all columns. - * @param length Indicates the length of the columnNames array. + * @param store Pointer to the {@link OH_Rdb_Store} instance. + * @param predicates Pointer to the {@link OH_Predicates} instance, which specifies the query conditions. + * @param columnNames Pointer to the columns to be queried. If this parameter is not specified, the query applies + * to all columns. + * @param length Length of the columnNames array. If length is greater than the length + * of columnNames array, out-of-bounds access occurs. * @return Returns the pointer to the {@link OH_Cursor} instance if the operation is successful; returns NULL otherwise. * @see OH_Rdb_Store, OH_Predicates, OH_Cursor. * @since 10 @@ -228,8 +258,8 @@ OH_Cursor *OH_Rdb_Query(OH_Rdb_Store *store, OH_Predicates *predicates, const ch /** * @brief Executes an SQL statement that contains specified arguments but returns no value. * - * @param store Indicates the pointer to the {@link OH_Rdb_Store} instance. - * @param sql Indicates the pointer to the SQL statement to execute. + * @param store Pointer to the {@link OH_Rdb_Store} instance. + * @param sql Pointer to the SQL statement to execute. * @return Returns the operation result. If the operation fails, an error code is returned. * @see OH_Rdb_Store. * @since 10 @@ -239,8 +269,8 @@ int OH_Rdb_Execute(OH_Rdb_Store *store, const char *sql); /** * @brief Executes the SQL statement to query data in an RDB store. * - * @param store Indicates the pointer to the {@link OH_Rdb_Store} instance. - * @param sql Indicates the pointer to the SQL statement to execute. + * @param store Pointer to the {@link OH_Rdb_Store} instance. + * @param sql Pointer to the SQL statement to execute. * @return Returns the pointer to the {@link OH_Cursor} instance if the operation is successful; returns NULL otherwise. * @see OH_Rdb_Store. * @since 10 @@ -250,7 +280,7 @@ OH_Cursor *OH_Rdb_ExecuteQuery(OH_Rdb_Store *store, const char *sql); /** * @brief Starts the transaction before executing an SQL statement. * - * @param store Indicates the pointer to the {@link OH_Rdb_Store} instance. + * @param store Pointer to the {@link OH_Rdb_Store} instance. * @return Returns the operation result. If the operation fails, an error code is returned. * @see OH_Rdb_Store. * @since 10 @@ -260,7 +290,7 @@ int OH_Rdb_BeginTransaction(OH_Rdb_Store *store); /** * @brief Rolls back the SQL statements executed. * - * @param store Indicates the pointer to the {@link OH_Rdb_Store} instance. + * @param store Pointer to the {@link OH_Rdb_Store} instance. * @return Returns the operation result. If the operation fails, an error code is returned. * @see OH_Rdb_Store. * @since 10 @@ -270,7 +300,7 @@ int OH_Rdb_RollBack(OH_Rdb_Store *store); /** * @brief Submits the SQL statements executed. * - * @param store Indicates the pointer to the {@link OH_Rdb_Store} instance. + * @param store Pointer to the {@link OH_Rdb_Store} instance. * @return Returns the operation result. If the operation fails, an error code is returned. * @see OH_Rdb_Store. * @since 10 @@ -280,8 +310,8 @@ int OH_Rdb_Commit(OH_Rdb_Store *store); /** * @brief Backs up an RDB store in the specified directory. * - * @param store Indicates the pointer to the {@link OH_Rdb_Store} instance. - * @param databasePath Indicates the pointer to the backup file path of the database. + * @param store Pointer to the {@link OH_Rdb_Store} instance. + * @param databasePath Pointer to the backup file path of the database. * @return Returns the operation result. If the operation fails, an error code is returned. * @see OH_Rdb_Store. * @since 10 @@ -291,8 +321,8 @@ int OH_Rdb_Backup(OH_Rdb_Store *store, const char *databasePath); /** * @brief Restores an RDB store from the specified database backup file. * - * @param store Indicates the pointer to the {@link OH_Rdb_Store} instance. - * @param databasePath Indicates the pointer to the backup file path of the database. + * @param store Pointer to the {@link OH_Rdb_Store} instance. + * @param databasePath Pointer to the backup file path of the database. * @return Returns the operation result. If the operation fails, an error code is returned. * @see OH_Rdb_Store. * @since 10 @@ -302,8 +332,8 @@ int OH_Rdb_Restore(OH_Rdb_Store *store, const char *databasePath); /** * @brief Obtains the RDB store version. * - * @param store Indicates the pointer to the {@link OH_Rdb_Store} instance. - * @param version Indicates the pointer to the version number. + * @param store Pointer to the {@link OH_Rdb_Store} instance. + * @param version Pointer to the version number. * @return Returns the operation result. If the operation fails, an error code is returned. * @see OH_Rdb_Store. * @since 10 @@ -313,14 +343,301 @@ int OH_Rdb_GetVersion(OH_Rdb_Store *store, int *version); /** * @brief Sets the RDB store version. * - * @param store Indicates the pointer to the {@link OH_Rdb_Store} instance. - * @param version Indicates the version to set. + * @param store Pointer to the {@link OH_Rdb_Store} instance. + * @param version Version to set. * @return Returns the operation result. If the operation fails, an error code is returned. * @see OH_Rdb_Store. * @since 10 */ int OH_Rdb_SetVersion(OH_Rdb_Store *store, int version); +/** + * @brief Enumerates the distributed table types. + * + * @since 11 + */ +typedef enum Rdb_DistributedType { + /** Distributed database table synchronized between the device and the cloud. */ + RDB_DISTRIBUTED_CLOUD +} Rdb_DistributedType; + +/** + * @brief Describes the version of {@link Rdb_DistributedConfig}. + * + * @since 11 + */ +#define DISTRIBUTED_CONFIG_VERSION 1 + +/** + * @brief Represents the distributed configuration of a table. + * + * @since 11 + */ +typedef struct Rdb_DistributedConfig { + /** Version of the Rdb_DistributedConfig struct. */ + int version; + /** Whether the table supports automatic synchronization. */ + bool isAutoSync; +} Rdb_DistributedConfig; + +/** + * @brief Sets distributed database tables. + * + * @param store Pointer to the {@link OH_Rdb_Store} instance. + * @param tables Pointer to the names of the distributed database tables to set. + * @param count Number of distributed database tables to be set. + * @param type Distributed type of the table. For details, see {@link Rdb_DistributedType}. + * @param config Distributed configuration of the tables. For details, see {@link Rdb_DistributedConfig}. + * @return Returns the operation result. If the operation fails, an error code is returned. + * @see OH_Rdb_Store. + * @since 11 + */ +int OH_Rdb_SetDistributedTables(OH_Rdb_Store *store, const char *tables[], uint32_t count, Rdb_DistributedType type, + const Rdb_DistributedConfig *config); + +/** + * @brief Obtains the last modification time of a table in an RDB store. + * + * @param store Pointer to the {@link OH_Rdb_Store} instance. + * @param tableName Pointer to the name of the distributed database table. + * @param columnName Pointer to the column name of the database table. + * @param values Pointer to the primary keys. If the database table has no primary key, rowid must be passed in + * through columnName. In this case, values specifies the row number of the database table to query. + * @return Returns the operation result. If the operation fails, an error code is returned. + * @see OH_Rdb_Store. + * @since 11 + */ +OH_Cursor *OH_Rdb_FindModifyTime(OH_Rdb_Store *store, const char *tableName, const char *columnName, + OH_VObject *values); + +/** + * @brief Enumerates the data change types. + * + * @since 11 + */ +typedef enum Rdb_ChangeType { + /** Data change. */ + RDB_DATA_CHANGE, + /** Asset change. */ + RDB_ASSET_CHANGE +} Rdb_ChangeType; + +/** + * @brief Represents information about the primary key or row number of the row that changes. + * + * @since 11 + */ +typedef struct Rdb_KeyInfo { + /** Number of primary keys or rows changed. */ + int count; + /** Primary key type {@link OH_ColumnType}. */ + int type; + /** + * @brief Specific data changed. + * + * @since 11 + */ + union Rdb_KeyData { + /** Data of the uint64_t type. */ + uint64_t integer; + /** Data of the double type. */ + double real; + /** Data of the char \* type. */ + const char *text; + } *data; +} Rdb_KeyInfo; + +/** + * @brief Represents the version of {@link Rdb_ChangeInfo}. + * + * @since 11 + */ +#define DISTRIBUTED_CHANGE_INFO_VERSION 1 + +/** + * @brief Represents details about the device-cloud synchronization process. + * + * @since 11 + */ +typedef struct Rdb_ChangeInfo { + /** Version of the Rdb_DistributedConfig struct. */ + int version; + /** Name of the table with data changes. */ + const char *tableName; + /** Type of the data changed, which can be data or asset. */ + int ChangeType; + /** + * Location where the data is inserted. If the primary key of the table is of the string type, the value is the + * value of the primary key. Otherwise, the value is the row number of the inserted data. + */ + Rdb_KeyInfo inserted; + /** + * Location where data is updated. If the primary key of the table is of the string type, the value is the value + * of the primary key. Otherwise, the value is the row number of the updated data. + */ + Rdb_KeyInfo updated; + /** + * Location where data is deleted. If the primary key of the table is of the string type, the value is the value + * of the primary key. Otherwise, the value is the row number of the deleted data. + */ + Rdb_KeyInfo deleted; +} Rdb_ChangeInfo; + +/** + * @brief Enumerates the subscription types. + * + * @since 11 + */ +typedef enum Rdb_SubscribeType { + /** Subscribe to cloud data changes. */ + RDB_SUBSCRIBE_TYPE_CLOUD, + /** Subscribe to cloud data change details. */ + RDB_SUBSCRIBE_TYPE_CLOUD_DETAILS, +} Rdb_SubscribeType; + +/** + * @brief Enumerates the data synchronization modes. + * + * @since 11 + */ +typedef enum Rdb_SyncMode { + /** Synchronize with the data with the latest modification time. */ + RDB_SYNC_MODE_TIME_FIRST, + /** Synchronize data from a local device to the cloud. */ + RDB_SYNC_MODE_NATIVE_FIRST, + /** Synchronize data from the cloud to a local device. */ + RDB_SYNC_MODE_CLOUD_FIRST +} Rdb_SyncMode; + +/** + * @brief Defines a struct for the device-cloud synchronization statistics of a database table. + * + * @since 11 + */ +typedef struct Rdb_Statistic { + /** Total number of rows to be synchronized between the device and cloud in the database table. */ + int total; + /** Number of rows that are successfully synchronized between the device and cloud in the database table. */ + int successful; + /** Number of rows that failed to be synchronized between the device and cloud in the database table. */ + int failed; + /** Number of rows that are not executed for device-cloud synchronization in the database table. */ + int remained; +} Rdb_Statistic; + +/** + * @brief Defines a struct for statistics of device-cloud upload and download tasks of a database table. + * + * @since 11 + */ +typedef struct Rdb_TableDetails { + /** Name of the database table. */ + const char *table; + /** Statistics of the device-cloud upload tasks. */ + Rdb_Statistic upload; + /** Statistics of the device-cloud download tasks. */ + Rdb_Statistic download; +} Rdb_TableDetails; + +/** + * Enumerates the device-cloud synchronization progresses. + * + * @since 11 + */ +typedef enum Rdb_Progress { + /** The device-cloud synchronization starts. */ + RDB_SYNC_BEGIN, + /** The device-cloud synchronization is in progress. */ + RDB_SYNC_IN_PROGRESS, + /** The device-cloud synchronization is finished. */ + RDB_SYNC_FINISH +} Rdb_Progress; + + +/** + * Enumerates the device-cloud synchronization states. + * + * @since 11 + */ +typedef enum Rdb_ProgressCode { + /** The device-cloud synchronization is successful. */ + RDB_SUCCESS, + /** An unknown error occurs during the device-cloud synchronization. */ + RDB_UNKNOWN_ERROR, + /** A network error occurs during the device-cloud synchronization. */ + RDB_NETWORK_ERROR, + /** The cloud is unavailable. */ + RDB_CLOUD_DISABLED, + /** The device-cloud synchronization of another device is being performed. */ + RDB_LOCKED_BY_OTHERS, + /** + * The number of records or size of the data to be synchronized exceeds the maximum. + * The maximum value is configured on the cloud. + */ + RDB_RECORD_LIMIT_EXCEEDED, + /** The remaining cloud space is less than the size of the data to be synchronized. */ + RDB_NO_SPACE_FOR_ASSET +} Rdb_ProgressCode; + +/** + * @brief Represents the version of {@link OH_ProgressDetails}. + * + * @since 11 + */ +#define DISTRIBUTED_PROGRESS_DETAIL_VERSION 1 + +/** + * @brief Defines a struct for statistics of device-cloud upload and download tasks of an RDB store. + * + * @since 11 + */ +typedef struct Rdb_ProgressDetails { + /** Version of the OH_TableDetails struct. */ + int version; + /** Device-cloud synchronization progress. */ + int schedule; + /** Device-cloud synchronization state. */ + int code; + /** Number of the tables synchronized between the device and cloud. */ + int32_t tableLength; +} Rdb_ProgressDetails; + +/** + * @brief Obtains the device-cloud synchronization statistics of a table. + * + * @param progress Pointer to the {@link OH_ProgressDetails} instance. + * @param version Version of {@link Rdb_ProgressDetails}. + * @return Returns the pointer to {@link Rdb_TableDetails} if the operation is successful; returns NULL otherwise. + * @see Rdb_ProgressDetails + * @see Rdb_TableDetails + * @since 11 + */ +Rdb_TableDetails *OH_Rdb_GetTableDetails(Rdb_ProgressDetails *progress, int32_t version); + +/** + * @brief Called to return the device-cloud synchronization details. + * + * @param progressDetails Pointer to the device-cloud synchronization statistics. + * @see OH_Rdb_Store. + * @since 11 + */ +typedef void (*Rdb_SyncCallback)(Rdb_ProgressDetails *progressDetails); + +/** + * @brief Performs device-cloud synchronization. + * + * @param store Pointer to the {@link OH_Rdb_Store} instance. + * @param mode Synchronization mode. For details, see {@link Rdb_SyncMode}. + * @param tables Pointer to the names of the tables to synchronize. + * @param count Number of tables to synchronize. If the value is 0, + * all tables in the RDB store are to be synchronized. + * @param progress Pointer to the callback to invoke. + * @see OH_Rdb_Store. + * @since 11 + */ +int OH_Rdb_CloudSync(OH_Rdb_Store *store, Rdb_SyncMode mode, const char *tables, int count, + Rdb_SyncCallback *progress); + #ifdef __cplusplus }; #endif diff --git a/en/native_sdk/database/rdb/relational_store_error_code.h b/en/native_sdk/database/rdb/relational_store_error_code.h index 8f26a7b2f53b5ee26dcdc66dab6e4d695464f611..5091a12c2386d56e543b8ab36b114574c6ff60b6 100644 --- a/en/native_sdk/database/rdb/relational_store_error_code.h +++ b/en/native_sdk/database/rdb/relational_store_error_code.h @@ -34,7 +34,7 @@ * @file relational_store_error_code.h * * @brief Declares the error code information about a relational database (RDB) store. - * @library native_rdb_ndk_header.so + * @library libnative_rdb_ndk.z.so * @since 10 */ @@ -229,7 +229,7 @@ typedef enum OH_Rdb_ErrCode { RDB_E_EMPTY_NEW_ENCRYPT_KEY = (E_BASE + 32), /** - * @brief The RDB store is non-encrypted, which is cannot be changed. + * @brief The RDB store is non-encrypted, which cannot be changed. */ RDB_E_CHANGE_UNENCRYPTED_TO_ENCRYPTED = (E_BASE + 33),