diff --git a/distributeddatamgr/udmf/include/udmf.h b/distributeddatamgr/udmf/include/udmf.h index 286723b2360fb28f4b3ab5634ab62e2a8a64b225..32d57814f68ac801d455a18ad00efdf6c926caf1 100644 --- a/distributeddatamgr/udmf/include/udmf.h +++ b/distributeddatamgr/udmf/include/udmf.h @@ -197,6 +197,13 @@ typedef struct OH_UdmfGetDataParams OH_UdmfGetDataParams; */ typedef void (*OH_Udmf_DataProgressListener)(OH_Udmf_ProgressInfo* progressInfo, OH_UdmfData* data); +/** + * @brief Describes the optional arguments of data operation + * + * @since 20 + */ +typedef struct OH_UdmfOptions OH_UdmfOptions; + /** * @brief Creation a pointer to the instance of the {@link OH_UdmfData}. * @@ -803,6 +810,83 @@ int OH_UdmfProperty_SetExtrasIntParam(OH_UdmfProperty* pThis, const char* key, i int OH_UdmfProperty_SetExtrasStringParam(OH_UdmfProperty* pThis, const char* key, const char* param); +/** + * @brief Creation a pointer to the instance of the {@link OH_UdmfOptions}. + * + * @return If the operation is successful, a pointer to the instance of the {@link OH_UdmfOptions} + * structure is returned. If the operation is failed, nullptr is returned. + * @see OH_UdmfOptions. + * @since 20 + */ +OH_UdmfOptions* OH_UdmfOptions_Create(); + +/** + * @brief Destroy a pointer that points to an instance of {@link OH_UdmfOptions}. + * + * @param pThis Represents a pointer to an instance of {@link OH_UdmfOptions}. + * @see OH_UdmfOptions. + * @since 20 + */ +void OH_UdmfOptions_Destroy(OH_UdmfOptions* pThis); + +/** + * @brief Get key from the {@link OH_UdmfOptions}. + * + * @param pThis Represents a pointer to an instance of {@link OH_UdmfOptions}. + * @return Returns a pointer of the value string when input args normally, otherwise return nullptr. + * @see OH_UdmfOptions + * @since 20 + */ +const char* OH_UdmfOptions_GetKey(OH_UdmfOptions* pThis); + +/** + * @brief Set the key to the {@link OH_UdmfOptions}. + * + * @param pThis Represents a pointer to an instance of {@link OH_UdmfOptions}. + * @param key Represents a new string value of the key. + * @return Returns the status code of the execution. See {@link Udmf_ErrCode}. + * {@link UDMF_E_OK} success. + * {@link UDMF_E_INVALID_PARAM} The error code for common invalid args. + * @see OH_UdmfOptions Udmf_ErrCode + * @since 20 + */ +int OH_UdmfOptions_SetKey(OH_UdmfOptions* pThis, const char* key); + +/** + * @brief Get intention from the {@link OH_UdmfOptions}. + * + * @param pThis Represents a pointer to an instance of {@link OH_UdmfOptions}. + * @return Returns {@link Udmf_Intention} value. + * @see OH_UdmfOptions Udmf_Intention + * @since 20 + */ +Udmf_Intention OH_UdmfOptions_GetIntention(OH_UdmfOptions* pThis); + +/** + * @brief Set intention value to {@link OH_UdmfOptions}. + * + * @param pThis Represents a pointer to an instance of {@link OH_UdmfOptions}. + * @param intention Represents new {@link Udmf_Intention} param. + * @return Returns the status code of the execution. See {@link Udmf_ErrCode}. + * {@link UDMF_E_OK} success. + * {@link UDMF_E_INVALID_PARAM} The error code for common invalid args. + * @see OH_UdmfOptions Udmf_Intention Udmf_ErrCode. + * @since 20 + */ +int OH_UdmfOptions_SetIntention(OH_UdmfOptions* pThis, Udmf_Intention intention); + +/** + * @brief Reset {@link OH_UdmfOptions} to default. + * + * @param pThis Represents a pointer to an instance of {@link OH_UdmfOptions}. + * @return Returns the status code of the execution. See {@link Udmf_ErrCode}. + * {@link UDMF_E_OK} success. + * {@link UDMF_E_INVALID_PARAM} The error code for common invalid args. + * @see OH_UdmfOptions Udmf_ErrCode. + * @since 20 + */ +int OH_UdmfOptions_Reset(OH_UdmfOptions* pThis); + /** * @brief Get {@link OH_UdmfData} data from udmf database. * @@ -818,6 +902,22 @@ int OH_UdmfProperty_SetExtrasStringParam(OH_UdmfProperty* pThis, */ int OH_Udmf_GetUnifiedData(const char* key, Udmf_Intention intention, OH_UdmfData* unifiedData); +/** + * @brief Get {@link OH_UdmfData} data array from udmf database by intention. + * + * @param options Represents a pointer to an instance of {@link OH_UdmfOptions}. + * @param dataArray Represents output params of {@link OH_UdmfData}. + * This pointer needs to be released using the {@link OH_Udmf_DestroyDataArray} function. + * @param dataSize Represents the data count of output params. + * @return Returns the status code of the execution. See {@link Udmf_ErrCode}. + * {@link UDMF_E_OK} success. + * {@link UDMF_E_INVALID_PARAM} The error code for common invalid args. + * {@link UDMF_ERR} Internal data error. + * @see OH_UdmfData Udmf_Intention Udmf_ErrCode. + * @since 20 + */ +int OH_Udmf_GetUnifiedDataByOptions(OH_UdmfOptions* options, OH_UdmfData** dataArray, unsigned int* dataSize); + /** * @brief Set {@link OH_UdmfData} data to database. * @@ -836,6 +936,63 @@ int OH_Udmf_GetUnifiedData(const char* key, Udmf_Intention intention, OH_UdmfDat int OH_Udmf_SetUnifiedData(Udmf_Intention intention, OH_UdmfData* unifiedData, char* key, unsigned int keyLen); +/** + * @brief Set {@link OH_UdmfData} data to database with options. + * + * @param options Represents a pointer to an instance of {@link OH_UdmfOptions}. + * @param unifiedData Represents a pointer to an instance of {@link OH_UdmfData}. + * @param key Represents return value after set data to database successfully, + * it's memory size not less than {@link UDMF_KEY_BUFFER_LEN}. + * @param keyLen Represents size of key param. + * @return Returns the status code of the execution. See {@link Udmf_ErrCode}. + * {@link UDMF_E_OK} success. + * {@link UDMF_E_INVALID_PARAM} The error code for common invalid args. + * {@link UDMF_ERR} Internal data error. + * @see OH_UdmfOptions OH_UdmfData Udmf_ErrCode. + * @since 20 + */ +int OH_Udmf_SetUnifiedDataByOptions(OH_UdmfOptions* options, OH_UdmfData *unifiedData, char *key, unsigned int keyLen); + +/** + * @brief Update {@link OH_UdmfData} data to database with options. + * + * @param options Represents a pointer to an instance of {@link OH_UdmfOptions}. + * @param unifiedData Represents a pointer to an instance of {@link OH_UdmfData}. + * @return Returns the status code of the execution. See {@link Udmf_ErrCode}. + * {@link UDMF_E_OK} success. + * {@link UDMF_E_INVALID_PARAM} The error code for common invalid args. + * {@link UDMF_ERR} Internal data error. + * @see OH_UdmfOptions OH_UdmfData Udmf_ErrCode. + * @since 20 + */ +int OH_Udmf_UpdateUnifiedData(OH_UdmfOptions* options, OH_UdmfData* unifiedData); + +/** + * @brief Delete {@link OH_UdmfData} data of database with options. + * + * @param options Represents a pointer to an instance of {@link OH_UdmfOptions}. + * @param dataArray Represents output params of {@link OH_UdmfData}. + * This pointer needs to be released using the {@link OH_Udmf_DestroyDataArray} function. + * @param dataSize Represents the data count of output params. + * @return Returns the status code of the execution. See {@link Udmf_ErrCode}. + * {@link UDMF_E_OK} success. + * {@link UDMF_E_INVALID_PARAM} The error code for common invalid args. + * {@link UDMF_ERR} Internal data error. + * @see OH_UdmfData Udmf_Intention Udmf_ErrCode. + * @since 20 + */ +int OH_Udmf_DeleteUnifiedData(OH_UdmfOptions* options, OH_UdmfData** dataArray, unsigned int* dataSize); + +/** + * @brief Destory data array memory. + * + * @param dataArray Represents a pointer to {@link OH_UdmfData}. + * @param dataSize Represents data size in list. + * @see OH_UdmfData + * @since 20 + */ +void OH_Udmf_DestroyDataArray(OH_UdmfData** dataArray, unsigned int dataSize); + /** * @brief Gets the progress from the {@OH_Udmf_ProgressInfo}. * diff --git a/distributeddatamgr/udmf/libudmf.ndk.json b/distributeddatamgr/udmf/libudmf.ndk.json index 561cd69ebabd1c6e3bfd87ab08ad2fd450a0b8b2..93efe5e1f4371f88db40d347320eec026ad7c05a 100644 --- a/distributeddatamgr/udmf/libudmf.ndk.json +++ b/distributeddatamgr/udmf/libudmf.ndk.json @@ -558,5 +558,53 @@ { "first_introduced": "15", "name": "OH_UdmfGetDataParams_SetDataProgressListener" + }, + { + "first_introduced": "20", + "name": "OH_UdmfOptions_Create" + }, + { + "first_introduced": "20", + "name": "OH_UdmfOptions_Destroy" + }, + { + "first_introduced": "20", + "name": "OH_UdmfOptions_GetKey" + }, + { + "first_introduced": "20", + "name": "OH_UdmfOptions_SetKey" + }, + { + "first_introduced": "20", + "name": "OH_UdmfOptions_GetIntention" + }, + { + "first_introduced": "20", + "name": "OH_UdmfOptions_SetIntention" + }, + { + "first_introduced": "20", + "name": "OH_UdmfOptions_Reset" + }, + { + "first_introduced": "20", + "name": "OH_Udmf_GetUnifiedDataByOptions" + }, + { + "first_introduced": "20", + "name": "OH_Udmf_SetUnifiedDataByOptions" + }, + { + "first_introduced": "20", + "name": "OH_Udmf_UpdateUnifiedData" + }, + { + "first_introduced": "20", + "name": "OH_Udmf_DeleteUnifiedData" + }, + { + "first_introduced": "20", + "name": "OH_Udmf_DestroyDataArray" } ] \ No newline at end of file