1 /* 2 * Copyright (c) 2024 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 UDMF 18 * @{ 19 * 20 * @brief The Unified Data Management Framework(UDMF) aims to define various standards 21 * for data across applications, devices, and platforms, providing a unified OpenHarmony 22 * data language and standardized data access and reading paths. 23 * 24 * @since 12 25 */ 26 27 /** 28 * @file udmf.h 29 * 30 * @brief Provides unified data management framework related functions and enumerations. 31 * 32 * @kit ArkData 33 * @library libudmf.so 34 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 35 * 36 * @since 12 37 */ 38 39 #ifndef UDMF_H 40 #define UDMF_H 41 42 #include <inttypes.h> 43 #include <stdbool.h> 44 #include "uds.h" 45 46 #ifdef __cplusplus 47 extern "C" { 48 #endif 49 50 /** 51 * @brief The key minimum memory space size of Unified Data. 52 * 53 * @since 12 54 */ 55 #define UDMF_KEY_BUFFER_LEN (512) 56 57 /** 58 * @brief Describe the intention type of the udmf. 59 * 60 * @since 12 61 */ 62 typedef enum Udmf_Intention { 63 /** 64 * @brief The intention is drag. 65 */ 66 UDMF_INTENTION_DRAG, 67 /** 68 * @brief The intention is pasteboard. 69 */ 70 UDMF_INTENTION_PASTEBOARD, 71 } Udmf_Intention; 72 73 /** 74 * @brief Describe intra-device usage range type enumeration. 75 * 76 * @since 12 77 */ 78 typedef enum Udmf_ShareOption { 79 /** 80 * @brief Invalid share option. 81 */ 82 SHARE_OPTIONS_INVALID, 83 /** 84 * @brief Allowed to be used in the same application on this device. 85 */ 86 SHARE_OPTIONS_IN_APP, 87 /** 88 * @brief Allowed to be used in the cross application on this device. 89 */ 90 SHARE_OPTIONS_CROSS_APP 91 } Udmf_ShareOption; 92 93 /** 94 * @brief Describes the unified data type. 95 * 96 * @since 12 97 */ 98 typedef struct OH_UdmfData OH_UdmfData; 99 100 /** 101 * @brief Describes the record type in the unified data. 102 * 103 * @since 12 104 */ 105 typedef struct OH_UdmfRecord OH_UdmfRecord; 106 107 /** 108 * @brief Defines the data provider. 109 * 110 * @since 13 111 */ 112 typedef struct OH_UdmfRecordProvider OH_UdmfRecordProvider; 113 114 /** 115 * @brief Describes some property parameters of unified data. 116 * 117 * @since 12 118 */ 119 typedef struct OH_UdmfProperty OH_UdmfProperty; 120 121 /** 122 * @brief Creation a pointer to the instance of the {@link OH_UdmfData}. 123 * 124 * @return If the operation is successful, a pointer to the instance of the {@link OH_UdmfData} 125 * structure is returned. If the operation is failed, nullptr is returned. 126 * @see OH_UdmfData. 127 * @since 12 128 */ 129 OH_UdmfData* OH_UdmfData_Create(); 130 131 /** 132 * @brief Destroy a pointer that points to the {@link OH_UdmfData} instance. 133 * 134 * @param pThis Represents a pointer to an instance of {@link OH_UdmfData}. 135 * @see OH_UdmfData. 136 * @since 12 137 */ 138 void OH_UdmfData_Destroy(OH_UdmfData* pThis); 139 140 /** 141 * @brief Add one {OH_UdmfRecord} record to the {@link OH_UdmfData} data. 142 * 143 * @param pThis Represents a pointer to an instance of {@link OH_UdmfData}. 144 * @param record Represents a pointer to an instance of {@link OH_UdmfRecord}. 145 * @return Returns the status code of the execution. See {@link Udmf_ErrCode}. 146 * {@link UDMF_E_OK} success. 147 * {@link UDMF_E_INVALID_PARAM} The error code for common invalid args. 148 * @see OH_UdmfData Udmf_ErrCode. 149 * @since 12 150 */ 151 int OH_UdmfData_AddRecord(OH_UdmfData* pThis, OH_UdmfRecord* record); 152 153 /** 154 * @brief Check whether the type exists in the {@link OH_UdmfData} data. 155 * 156 * @param pThis Represents a pointer to an instance of {@link OH_UdmfData}. 157 * @param type Represents a string pointer of the type. 158 * @return Returns the status of finding type. 159 * {@code false} is not existed. 160 * {@code true} is existed. 161 * @see OH_UdmfData. 162 * @since 12 163 */ 164 bool OH_UdmfData_HasType(OH_UdmfData* pThis, const char* type); 165 166 /** 167 * @brief Get all types in the {@link OH_UdmfData} data. 168 * 169 * @param pThis Represents a pointer to an instance of {@link OH_UdmfData}. 170 * @param count Represents the types count that is a output param. 171 * @return Returns string array that in {@link OH_UdmfData} when input parameters valid, 172 * otherwise return nullptr. 173 * @see OH_UdmfData. 174 * @since 12 175 */ 176 char** OH_UdmfData_GetTypes(OH_UdmfData* pThis, unsigned int* count); 177 178 /** 179 * @brief Get all records in the {@link OH_UdmfData} data. 180 * 181 * @param pThis Represents a pointer to an instance of {@link OH_UdmfData}. 182 * @param count Represents the records count that is a output param. 183 * @return Returns {@link OH_UdmfRecord} pointer array when input parameters valid, otherwise return nullptr. 184 * @see OH_UdmfData OH_UdmfRecord. 185 * @since 12 186 */ 187 OH_UdmfRecord** OH_UdmfData_GetRecords(OH_UdmfData* pThis, unsigned int* count); 188 189 /** 190 * @brief Defines the callback function used free the context. 191 * @param context Pointer to the context which is to be free. 192 * @since 13 193 */ 194 typedef void (*UdmfData_Finalize)(void* context); 195 196 /** 197 * @brief Creates an {@link OH_UdmfRecordProvider} instance. 198 * 199 * @return Returns the pointer to the {@link OH_UdmfRecordProvider} instance created if the operation is successful. 200 * Returns nullptr if the memory is not enough. 201 * @see OH_UdmfRecordProvider. 202 * @since 13 203 */ 204 OH_UdmfRecordProvider* OH_UdmfRecordProvider_Create(); 205 206 /** 207 * @brief Destroy an {@link OH_UdmfRecordProvider} instance. 208 * 209 * @param provider Pointer to the {@link OH_UdmfRecordProvider} instance to destroy. 210 * @return Returns the status code of the execution. For details, see {@link Udmf_ErrCode}. 211 * Returns {@link UDMF_E_OK} if the operation is successful. 212 * Returns {@link UDMF_E_INVALID_PARAM} if invalid args are detected. 213 * @see OH_UdmfRecordProvider Udmf_ErrCode. 214 * @since 13 215 */ 216 int OH_UdmfRecordProvider_Destroy(OH_UdmfRecordProvider* provider); 217 218 /** 219 * @brief Defines a callback function used to obtain data by type. 220 * 221 * @param context Pointer to the context set by {@link OH_UdmfRecordProvider_SetData}. 222 * @param type Pointer to the type of data to obtain. For details, see {@link udmf_meta.h}. 223 * @return Returns the data content. 224 * @since 13 225 */ 226 typedef void* (*OH_UdmfRecordProvider_GetData)(void* context, const char* type); 227 228 /** 229 * @brief Sets a callback function to obtain data. 230 * 231 * @param provider Pointer to the {@link OH_UdmfRecordProvider} instance. 232 * @param context Pointer to the context set, which is the first parameter in OH_UdmfRecordProvider_GetData. 233 * @param callback Callback to set. For details, see {@link OH_UdmfRecordProvider_GetData}. 234 * @param finalize Optional callback that can free context when destroy provider. 235 * For details, see {@link UdmfData_Finalize}. 236 * @return Returns the status code of the execution. For details, see {@link Udmf_ErrCode}. 237 * Returns {@link UDMF_E_OK} if the operation is successful. 238 * Returns {@link UDMF_E_INVALID_PARAM} if invalid args are detected. 239 * @see OH_UdmfRecordProvider OH_UdmfRecordProvider_GetData UdmfData_Finalize Udmf_ErrCode. 240 * @since 13 241 */ 242 int OH_UdmfRecordProvider_SetData(OH_UdmfRecordProvider* provider, void* context, 243 const OH_UdmfRecordProvider_GetData callback, const UdmfData_Finalize finalize); 244 245 /** 246 * @brief Creation a pointer to the instance of the {@link OH_UdmfRecord}, it's relate with UDS data. 247 * 248 * @return If the operation is successful, a pointer to the instance of the {@link OH_UdmfRecord} 249 * structure is returned. If the operation is failed, nullptr is returned. 250 * @see OH_UdmfRecord. 251 * @since 12 252 */ 253 OH_UdmfRecord* OH_UdmfRecord_Create(); 254 255 /** 256 * @brief Destroy a pointer that points to an instance of {@link OH_UdmfRecord}. 257 * 258 * @param pThis Represents a pointer to an instance of {@link OH_UdmfRecord}. 259 * @see OH_UdmfRecord. 260 * @since 12 261 */ 262 void OH_UdmfRecord_Destroy(OH_UdmfRecord* pThis); 263 264 /** 265 * @brief Add one custom data to the {@link OH_UdmfRecord} record. 266 * 267 * @param pThis Represents a pointer to an instance of {@link OH_UdmfRecord}. 268 * @param typeId Represents record type, reference udmf_meta.h. 269 * @param entry Represents custom data. 270 * @param count Represents the size of data param. 271 * @return Returns the status code of the execution. See {@link Udmf_ErrCode}. 272 * {@link UDMF_E_OK} success. 273 * {@link UDMF_E_INVALID_PARAM} The error code for common invalid args. 274 * @see OH_UdmfRecord Udmf_ErrCode. 275 * @since 12 276 */ 277 int OH_UdmfRecord_AddGeneralEntry(OH_UdmfRecord* pThis, const char* typeId, unsigned char* entry, unsigned int count); 278 279 /** 280 * @brief Add one {OH_UdsPlainText} data to the {@link OH_UdmfRecord} record. 281 * 282 * @param pThis Represents a pointer to an instance of {@link OH_UdmfRecord}. 283 * @param plainText Represents a pointer to an instance of {@link OH_UdsPlainText}. 284 * @return Returns the status code of the execution. See {@link Udmf_ErrCode}. 285 * {@link UDMF_E_OK} success. 286 * {@link UDMF_E_INVALID_PARAM} The error code for common invalid args. 287 * @see OH_UdmfRecord OH_UdsPlainText Udmf_ErrCode. 288 * @since 12 289 */ 290 int OH_UdmfRecord_AddPlainText(OH_UdmfRecord* pThis, OH_UdsPlainText* plainText); 291 292 /** 293 * @brief Add one {OH_UdsHyperlink} data to the {@link OH_UdmfRecord} record. 294 * 295 * @param pThis Represents a pointer to an instance of {@link OH_UdmfRecord}. 296 * @param hyperlink Represents a pointer to an instance of {@link OH_UdsHyperlink}. 297 * @return Returns the status code of the execution. See {@link Udmf_ErrCode}. 298 * {@link UDMF_E_OK} success. 299 * {@link UDMF_E_INVALID_PARAM} The error code for common invalid args. 300 * @see OH_UdmfRecord OH_UdsHyperlink Udmf_ErrCode. 301 * @since 12 302 */ 303 int OH_UdmfRecord_AddHyperlink(OH_UdmfRecord* pThis, OH_UdsHyperlink* hyperlink); 304 305 /** 306 * @brief Add one {OH_UdsHtml} data to the {@link OH_UdmfRecord} record. 307 * 308 * @param pThis Represents a pointer to an instance of {@link OH_UdmfRecord}. 309 * @param html Represents a pointer to an instance of {@link OH_UdsHtml}. 310 * @return Returns the status code of the execution. See {@link Udmf_ErrCode}. 311 * {@link UDMF_E_OK} success. 312 * {@link UDMF_E_INVALID_PARAM} The error code for common invalid args. 313 * @see OH_UdmfRecord OH_UdsHtml Udmf_ErrCode. 314 * @since 12 315 */ 316 int OH_UdmfRecord_AddHtml(OH_UdmfRecord* pThis, OH_UdsHtml* html); 317 318 /** 319 * @brief Add one {OH_UdsAppItem} data to the {@link OH_UdmfRecord} record. 320 * 321 * @param pThis Represents a pointer to an instance of {@link OH_UdmfRecord}. 322 * @param appItem Represents a pointer to an instance of {@link OH_UdsAppItem}. 323 * @return Returns the status code of the execution. See {@link Udmf_ErrCode}. 324 * {@link UDMF_E_OK} success. 325 * {@link UDMF_E_INVALID_PARAM} The error code for common invalid args. 326 * @see OH_UdmfRecord OH_UdsAppItem Udmf_ErrCode. 327 * @since 12 328 */ 329 int OH_UdmfRecord_AddAppItem(OH_UdmfRecord* pThis, OH_UdsAppItem* appItem); 330 331 /** 332 * @brief Add one {OH_UdsFileUri} data to the {@link OH_UdmfRecord} record. 333 * 334 * @param pThis Represents a pointer to an instance of {@link OH_UdmfRecord}. 335 * @param fileUri Represents a pointer to an instance of {@link OH_UdsFileUri}. 336 * @return Returns the status code of the execution. See {@link Udmf_ErrCode}. 337 * {@link UDMF_E_OK} success. 338 * {@link UDMF_E_INVALID_PARAM} The error code for common invalid args. 339 * @see OH_UdmfRecord OH_UdsFileUri Udmf_ErrCode. 340 * @since 13 341 */ 342 int OH_UdmfRecord_AddFileUri(OH_UdmfRecord* pThis, OH_UdsFileUri* fileUri); 343 344 /** 345 * @brief Add one {OH_UdsPixelMap} data to the {@link OH_UdmfRecord} record. 346 * 347 * @param pThis Represents a pointer to an instance of {@link OH_UdmfRecord}. 348 * @param pixelMap Represents a pointer to an instance of {@link OH_UdsPixelMap}. 349 * @return Returns the status code of the execution. See {@link Udmf_ErrCode}. 350 * {@link UDMF_E_OK} success. 351 * {@link UDMF_E_INVALID_PARAM} The error code for common invalid args. 352 * @see OH_UdmfRecord OH_UdsPixelMap Udmf_ErrCode. 353 * @since 13 354 */ 355 int OH_UdmfRecord_AddPixelMap(OH_UdmfRecord* pThis, OH_UdsPixelMap* pixelMap); 356 357 /** 358 * @brief Add one {@link OH_UdsArrayBuffer} data to the {@link OH_UdmfRecord} record. 359 * 360 * @param record Represents a pointer to an instance of {@link OH_UdmfRecord}. 361 * @param type Represents record type, reference udmf_meta.h. 362 * @param buffer Represents a pointer to an instance of {@link OH_UdsArrayBuffer}. 363 * @return Returns the status code of the execution. See {@link Udmf_ErrCode}. 364 * {@link UDMF_E_OK} success. 365 * {@link UDMF_E_INVALID_PARAM} The error code for common invalid args. 366 * @see OH_UdmfRecord OH_UdsArrayBuffer Udmf_ErrCode. 367 * @since 13 368 */ 369 int OH_UdmfRecord_AddArrayBuffer(OH_UdmfRecord* record, const char* type, OH_UdsArrayBuffer* buffer); 370 371 /** 372 * @brief Add one {@link OH_UdsContentForm} data to the {@link OH_UdmfRecord} record. 373 * 374 * @param pThis Represents a pointer to an instance of {@link OH_UdmfRecord}. 375 * @param contentForm Represents a pointer to an instance of {@link OH_UdsContentForm}. 376 * @return Returns the status code of the execution. See {@link Udmf_ErrCode}. 377 * {@link UDMF_E_OK} success. 378 * {@link UDMF_E_INVALID_PARAM} The error code for common invalid args. 379 * @see OH_UdmfRecord OH_UdsContentForm Udmf_ErrCode. 380 * @since 14 381 */ 382 int OH_UdmfRecord_AddContentForm(OH_UdmfRecord* pThis, OH_UdsContentForm* contentForm); 383 384 /** 385 * @brief Get all types in the {@link OH_UdmfRecord} record. 386 * 387 * @param pThis Represents a pointer to an instance of {@link OH_UdmfRecord}. 388 * @param count Represents the types count that is a output param. 389 * @return Returns string array that in {@link OH_UdmfRecord} when input parameters valid, 390 * otherwise return nullptr. 391 * @see OH_UdmfRecord. 392 * @since 12 393 */ 394 char** OH_UdmfRecord_GetTypes(OH_UdmfRecord* pThis, unsigned int* count); 395 396 /** 397 * @brief Get one entry data from the {@link OH_UdmfRecord} record. 398 * 399 * @param pThis Represents a pointer to an instance of {@link OH_UdmfRecord}. 400 * @param typeId Represents record type, reference udmf_meta.h. 401 * @param entry Represents a pointer to entry data that is a output param. 402 * @param count Represents the entry data length that is a output param. 403 * @return Returns the status code of the execution. See {@link Udmf_ErrCode}. 404 * {@link UDMF_E_OK} success. 405 * {@link UDMF_E_INVALID_PARAM} The error code for common invalid args. 406 * {@link UDMF_ERR} Internal data error. 407 * @see OH_UdmfRecord Udmf_ErrCode. 408 * @since 12 409 */ 410 int OH_UdmfRecord_GetGeneralEntry(OH_UdmfRecord* pThis, const char* typeId, 411 unsigned char** entry, unsigned int* count); 412 413 /** 414 * @brief Get one {OH_UdsPlainText} data from the {@link OH_UdmfRecord} record. 415 * 416 * @param pThis Represents a pointer to an instance of {@link OH_UdmfRecord}. 417 * @param plainText Represents a pointer to an instance of {@link OH_UdsPlainText}. 418 * @return Returns the status code of the execution. See {@link Udmf_ErrCode}. 419 * {@link UDMF_E_OK} success. 420 * {@link UDMF_E_INVALID_PARAM} The error code for common invalid args. 421 * {@link UDMF_ERR} Internal data error. 422 * @see OH_UdmfRecord OH_UdsPlainText Udmf_ErrCode. 423 * @since 12 424 */ 425 int OH_UdmfRecord_GetPlainText(OH_UdmfRecord* pThis, OH_UdsPlainText* plainText); 426 427 /** 428 * @brief Get one {OH_UdsHyperlink} data from the {@link OH_UdmfRecord} record. 429 * 430 * @param pThis Represents a pointer to an instance of {@link OH_UdmfRecord}. 431 * @param hyperlink Represents a pointer to an instance of {@link OH_UdsHyperlink}. 432 * @return Returns the status code of the execution. See {@link Udmf_ErrCode}. 433 * {@link UDMF_E_OK} success. 434 * {@link UDMF_E_INVALID_PARAM} The error code for common invalid args. 435 * {@link UDMF_ERR} Internal data error. 436 * @see OH_UdmfRecord OH_UdsHyperlink Udmf_ErrCode. 437 * @since 12 438 */ 439 int OH_UdmfRecord_GetHyperlink(OH_UdmfRecord* pThis, OH_UdsHyperlink* hyperlink); 440 441 /** 442 * @brief Get one {OH_UdsHtml} data from the {@link OH_UdmfRecord} record. 443 * 444 * @param pThis Represents a pointer to an instance of {@link OH_UdmfRecord}. 445 * @param html Represents a pointer to an instance of {@link OH_UdsHtml}. 446 * @return Returns the status code of the execution. See {@link Udmf_ErrCode}. 447 * {@link UDMF_E_OK} success. 448 * {@link UDMF_E_INVALID_PARAM} The error code for common invalid args. 449 * {@link UDMF_ERR} Internal data error. 450 * @see OH_UdmfRecord OH_UdsHtml Udmf_ErrCode. 451 * @since 12 452 */ 453 int OH_UdmfRecord_GetHtml(OH_UdmfRecord* pThis, OH_UdsHtml* html); 454 455 /** 456 * @brief Get one {OH_UdsAppItem} data from the {@link OH_UdmfRecord} record. 457 * 458 * @param pThis Represents a pointer to an instance of {@link OH_UdmfRecord}. 459 * @param appItem Represents a pointer to an instance of {@link OH_UdsAppItem}. 460 * @return Returns the status code of the execution. See {@link Udmf_ErrCode}. 461 * {@link UDMF_E_OK} success. 462 * {@link UDMF_E_INVALID_PARAM} The error code for common invalid args. 463 * {@link UDMF_ERR} Internal data error. 464 * @see OH_UdmfRecord OH_UdsAppItem Udmf_ErrCode. 465 * @since 12 466 */ 467 int OH_UdmfRecord_GetAppItem(OH_UdmfRecord* pThis, OH_UdsAppItem* appItem); 468 469 /** 470 * @brief Get one {OH_UdsFileUri} data from the {@link OH_UdmfRecord} record. 471 * 472 * @param pThis Represents a pointer to an instance of {@link OH_UdmfRecord}. 473 * @param fileUri Represents a pointer to an instance of {@link OH_UdsFileUri}. 474 * @return Returns the status code of the execution. See {@link Udmf_ErrCode}. 475 * {@link UDMF_E_OK} success. 476 * {@link UDMF_E_INVALID_PARAM} The error code for common invalid args. 477 * @see OH_UdmfRecord OH_UdsFileUri Udmf_ErrCode. 478 * @since 13 479 */ 480 int OH_UdmfRecord_GetFileUri(OH_UdmfRecord* pThis, OH_UdsFileUri* fileUri); 481 482 /** 483 * @brief Get one {OH_UdsPixelMap} data from the {@link OH_UdmfRecord} record. 484 * 485 * @param pThis Represents a pointer to an instance of {@link OH_UdmfRecord}. 486 * @param pixelMap Represents a pointer to an instance of {@link OH_UdsPixelMap}. 487 * @return Returns the status code of the execution. See {@link Udmf_ErrCode}. 488 * {@link UDMF_E_OK} success. 489 * {@link UDMF_E_INVALID_PARAM} The error code for common invalid args. 490 * @see OH_UdmfRecord OH_UdsPixelMap Udmf_ErrCode. 491 * @since 13 492 */ 493 int OH_UdmfRecord_GetPixelMap(OH_UdmfRecord* pThis, OH_UdsPixelMap* pixelMap); 494 495 /** 496 * @brief Set the data provider of the types. 497 * 498 * @param pThis Represents a pointer to an instance of {@link OH_UdmfRecord}. 499 * @param types Represents a pointer to a group of data types; 500 * @param count Represents the number of data types; 501 * @param provider Represents a pointer an instance of {@link OH_UdmfRecordProvider}. 502 * @return Returns the status code of the execution. See {@link Udmf_ErrCode}. 503 * {@link UDMF_E_OK} success. 504 * {@link UDMF_E_INVALID_PARAM} The error code for common invalid args. 505 * @see OH_UdmfRecord OH_UdmfRecordProvider Udmf_ErrCode. 506 * @since 13 507 */ 508 int OH_UdmfRecord_SetProvider(OH_UdmfRecord* pThis, const char* const* types, unsigned int count, 509 OH_UdmfRecordProvider* provider); 510 511 /** 512 * @brief Get one {@link OH_UdsArrayBuffer} data from the {@link OH_UdmfRecord} record. 513 * 514 * @param record Represents a pointer to an instance of {@link OH_UdmfRecord}. 515 * @param type Represents record type, reference udmf_meta.h. 516 * @param buffer Represents a pointer to an instance of {@link OH_UdsArrayBuffer}. 517 * @return Returns the status code of the execution. See {@link Udmf_ErrCode}. 518 * {@link UDMF_E_OK} success. 519 * {@link UDMF_E_INVALID_PARAM} The error code for common invalid args. 520 * @see OH_UdmfRecord OH_UdsArrayBuffer Udmf_ErrCode. 521 * @since 13 522 */ 523 int OH_UdmfRecord_GetArrayBuffer(OH_UdmfRecord* record, const char* type, OH_UdsArrayBuffer* buffer); 524 525 /** 526 * @brief Get one {@link OH_UdsContentForm} data from the {@link OH_UdmfRecord} record. 527 * 528 * @param pThis Represents a pointer to an instance of {@link OH_UdmfRecord}. 529 * @param contentForm Represents a pointer to an instance of {@link OH_UdsContentForm}. 530 * @return Returns the status code of the execution. See {@link Udmf_ErrCode}. 531 * {@link UDMF_E_OK} success. 532 * {@link UDMF_E_INVALID_PARAM} The error code for common invalid args. 533 * @see OH_UdmfRecord OH_UdsContentForm Udmf_ErrCode. 534 * @since 14 535 */ 536 int OH_UdmfRecord_GetContentForm(OH_UdmfRecord* pThis, OH_UdsContentForm* contentForm); 537 538 /** 539 * @brief Get primary {@link OH_UdsPlainText} data from the {@link OH_UdmfData}. 540 * 541 * @param data Represents a pointer to an instance of {@link OH_UdmfData}. 542 * @param plainText Represents a pointer to an instance of {@link OH_UdsPlainText}. 543 * @return Returns the status code of the execution. See {@link Udmf_ErrCode}. 544 * {@link UDMF_E_OK} success. 545 * {@link UDMF_E_INVALID_PARAM} The error code for common invalid args. 546 * @see OH_UdmfData OH_UdsPlainText Udmf_ErrCode. 547 * @since 13 548 */ 549 int OH_UdmfData_GetPrimaryPlainText(OH_UdmfData* data, OH_UdsPlainText* plainText); 550 551 /** 552 * @brief Get one {@link OH_UdsHtml} data from the {@link OH_UdmfData}. 553 * 554 * @param data Represents a pointer to an instance of {@link OH_UdmfData}. 555 * @param html Represents a pointer to an instance of {@link OH_UdsHtml}. 556 * @return Returns the status code of the execution. See {@link Udmf_ErrCode}. 557 * {@link UDMF_E_OK} success. 558 * {@link UDMF_E_INVALID_PARAM} The error code for common invalid args. 559 * @see OH_UdmfData OH_UdsHtml Udmf_ErrCode. 560 * @since 13 561 */ 562 int OH_UdmfData_GetPrimaryHtml(OH_UdmfData* data, OH_UdsHtml* html); 563 564 /** 565 * @brief Get the count of {@link OH_UdmfRecord} in the {@link OH_UdmfData}. 566 * 567 * @param data Represents a pointer to an instance of {@link OH_UdmfData}. 568 * @return Returns the count of {@link OH_UdmfRecord} 569 * @see OH_UdmfData. 570 * @since 13 571 */ 572 int OH_UdmfData_GetRecordCount(OH_UdmfData* data); 573 574 /** 575 * @brief Get the record of the specified index from the {@link OH_UdmfData}. 576 * 577 * @param data Represents a pointer to an instance of {@link OH_UdmfData}. 578 * @param index Represents the index of {@link OH_UdmfRecord} in the {@link OH_UdmfData}. 579 * @return Returns {@link OH_UdmfRecord} pointer when input parameters valid, otherwise return nullptr. 580 * @see OH_UdmfData. 581 * @since 13 582 */ 583 OH_UdmfRecord* OH_UdmfData_GetRecord(OH_UdmfData* data, unsigned int index); 584 585 /** 586 * @brief Checks whether the UDMF data is from a local device. 587 * 588 * @param data Represents a pointer to an instance of {@link OH_UdmfData}. 589 * @return Returns a boolean value, which indicates whether the UDMF data is from a local device. 590 * The value {@code true} means the data is from a local device. 591 * The value {@code false} means the opposite. 592 * @see OH_UdmfData. 593 * @since 13 594 */ 595 bool OH_UdmfData_IsLocal(OH_UdmfData* data); 596 597 /** 598 * @brief Creation a pointer to the instance of the {@link OH_UdmfProperty} 599 * from a {@link OH_UdmfData} data. 600 * 601 * @param unifiedData Represents a pointer to an instance of {@link OH_UdmfData}. 602 * @return If the operation is successful, a pointer to the instance of the {@link OH_UdmfProperty} 603 * structure is returned. If the operation is failed, nullptr is returned. 604 * @see OH_UdmfData OH_UdmfProperty. 605 * @since 12 606 */ 607 OH_UdmfProperty* OH_UdmfProperty_Create(OH_UdmfData* unifiedData); 608 609 /** 610 * @brief Destroy a pointer that points to the {@link OH_UdmfProperty} instance. 611 * 612 * @param pThis Represents a pointer to an instance of {@link OH_UdmfProperty}. 613 * @see OH_UdmfProperty. 614 * @since 12 615 */ 616 void OH_UdmfProperty_Destroy(OH_UdmfProperty* pThis); 617 618 /** 619 * @brief Get tag value from the {@link OH_UdmfProperty}. 620 * 621 * @param pThis Represents a pointer to an instance of {@link OH_UdmfProperty}. 622 * @return Returns a pointer of the tag value string when input parameters valid, otherwise return nullptr. 623 * @see OH_UdmfProperty. 624 * @since 12 625 */ 626 const char* OH_UdmfProperty_GetTag(OH_UdmfProperty* pThis); 627 628 /** 629 * @brief Get timestamp value from the {@link OH_UdmfProperty}. 630 * 631 * @param pThis Represents a pointer to an instance of {@link OH_UdmfProperty}. 632 * @return Returns timestamp value. 633 * @see OH_UdmfProperty 634 * @since 12 635 */ 636 int64_t OH_UdmfProperty_GetTimestamp(OH_UdmfProperty* pThis); 637 638 /** 639 * @brief Get share option value from the {@link OH_UdmfProperty}. 640 * 641 * @param pThis Represents a pointer to an instance of {@link OH_UdmfProperty}. 642 * @return Returns {@link Udmf_ShareOption} value. 643 * @see OH_UdmfProperty Udmf_ShareOption 644 * @since 12 645 */ 646 Udmf_ShareOption OH_UdmfProperty_GetShareOption(OH_UdmfProperty* pThis); 647 648 /** 649 * @brief Get integer value by key from the {@link OH_UdmfProperty}. 650 * 651 * @param pThis Represents a pointer to an instance of {@link OH_UdmfProperty}. 652 * @param key Represents key-value pair's key 653 * @param defaultValue Represents when get value failure. 654 * @return Returns value associated with the key in successfully, otherwise return defaultValue. 655 * @see OH_UdmfProperty. 656 * @since 12 657 */ 658 int OH_UdmfProperty_GetExtrasIntParam(OH_UdmfProperty* pThis, 659 const char* key, int defaultValue); 660 661 /** 662 * @brief Get tag value from the {@link OH_UdmfProperty}. 663 * 664 * @param pThis Represents a pointer to an instance of {@link OH_UdmfProperty}. 665 * @param key Represents key-value pair's key. 666 * @return Returns a pointer of the key value string when input parameters valid, otherwise return nullptr. 667 * @see OH_UdmfProperty 668 * @since 12 669 */ 670 const char* OH_UdmfProperty_GetExtrasStringParam(OH_UdmfProperty* pThis, const char* key); 671 672 /** 673 * @brief Set tag value to {@link OH_UdmfProperty} . 674 * 675 * @param pThis Represents a pointer to an instance of {@link OH_UdmfProperty}. 676 * @param tag Represents new tag param. 677 * @return Returns the status code of the execution. See {@link Udmf_ErrCode}. 678 * {@link UDMF_E_OK} success. 679 * {@link UDMF_E_INVALID_PARAM} The error code for common invalid args. 680 * @see OH_UdmfProperty Udmf_ErrCode. 681 * @since 12 682 */ 683 int OH_UdmfProperty_SetTag(OH_UdmfProperty* pThis, const char* tag); 684 685 /** 686 * @brief Set Udmf_ShareOption value to {@link OH_UdmfProperty}. 687 * 688 * @param pThis Represents a pointer to an instance of {@link OH_UdmfProperty}. 689 * @param option Represents new {@link Udmf_ShareOption} param. 690 * @return Returns the status code of the execution. See {@link Udmf_ErrCode}. 691 * {@link UDMF_E_OK} success. 692 * {@link UDMF_E_INVALID_PARAM} The error code for common invalid args. 693 * @see OH_UdmfProperty Udmf_ShareOption Udmf_ErrCode. 694 * @since 12 695 */ 696 int OH_UdmfProperty_SetShareOption(OH_UdmfProperty* pThis, Udmf_ShareOption option); 697 698 /** 699 * @brief Set extras param to {@link OH_UdmfProperty}. 700 * 701 * @param pThis Represents a pointer to an instance of {@link OH_UdmfProperty}. 702 * @param key Represents extras param's key value. 703 * @param param Represents value of k-v pairs. 704 * @return Returns the status code of the execution. See {@link Udmf_ErrCode}. 705 * {@link UDMF_E_OK} success. 706 * {@link UDMF_E_INVALID_PARAM} The error code for common invalid args. 707 * @see OH_UdmfProperty Udmf_ErrCode. 708 * @since 12 709 */ 710 int OH_UdmfProperty_SetExtrasIntParam(OH_UdmfProperty* pThis, const char* key, int param); 711 712 /** 713 * @brief Set extras param to {@link OH_UdmfProperty}. 714 * 715 * @param pThis Represents a pointer to an instance of {@link OH_UdmfProperty}. 716 * @param key Represents extras param's key value. 717 * @param param Represents value of k-v pairs. 718 * @return Returns the status code of the execution. See {@link Udmf_ErrCode}. 719 * {@link UDMF_E_OK} success. 720 * {@link UDMF_E_INVALID_PARAM} The error code for common invalid args. 721 * @see OH_UdmfProperty Udmf_ErrCode. 722 * @since 12 723 */ 724 int OH_UdmfProperty_SetExtrasStringParam(OH_UdmfProperty* pThis, 725 const char* key, const char* param); 726 727 /** 728 * @brief Get {@link OH_UdmfData} data from udmf database. 729 * 730 * @param key Represents database store's key value. 731 * @param intention Represents data type {@link Udmf_Intention} 732 * @param unifiedData Represents output params of {@link OH_UdmfData}; 733 * @return Returns the status code of the execution. See {@link Udmf_ErrCode}. 734 * {@link UDMF_E_OK} success. 735 * {@link UDMF_E_INVALID_PARAM} The error code for common invalid args. 736 * {@link UDMF_ERR} Internal data error. 737 * @see OH_UdmfProperty Udmf_Intention Udmf_ErrCode. 738 * @since 12 739 */ 740 int OH_Udmf_GetUnifiedData(const char* key, Udmf_Intention intention, OH_UdmfData* unifiedData); 741 742 /** 743 * @brief Set {@link OH_UdmfData} data to database. 744 * 745 * @param intention Represents data type {@link Udmf_Intention}. 746 * @param unifiedData Represents a pointer to an instance of {@link OH_UdmfData}. 747 * @param key Represents return value after set data to database successfully, 748 * it's memory size not less than {@link UDMF_KEY_BUFFER_LEN}. 749 * @param keyLen Represents size of key param. 750 * @return Returns the status code of the execution. See {@link Udmf_ErrCode}. 751 * {@link UDMF_E_OK} success. 752 * {@link UDMF_E_INVALID_PARAM} The error code for common invalid args. 753 * {@link UDMF_ERR} Internal data error. 754 * @see OH_UdmfProperty Udmf_Intention Udmf_ErrCode. 755 * @since 12 756 */ 757 int OH_Udmf_SetUnifiedData(Udmf_Intention intention, OH_UdmfData* unifiedData, 758 char* key, unsigned int keyLen); 759 760 #ifdef __cplusplus 761 }; 762 #endif 763 764 /** @} */ 765 #endif