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 subscriber 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 Get primary {@link OH_UdsPlainText} data from the {@link OH_UdmfData}. 247 * 248 * @param data Represents a pointer to an instance of {@link OH_UdmfData}. 249 * @param plainText Represents a pointer to an instance of {@link OH_UdsPlainText}. 250 * @return Returns the status code of the execution. See {@link Udmf_ErrCode}. 251 * {@link UDMF_E_OK} success. 252 * {@link UDMF_E_INVALID_PARAM} The error code for common invalid args. 253 * @see OH_UdmfData OH_UdsPlainText Udmf_ErrCode. 254 * @since 13 255 */ 256 int OH_UdmfData_GetPrimaryPlainText(OH_UdmfData* data, OH_UdsPlainText* plainText); 257 258 /** 259 * @brief Get one {@link OH_UdsHtml} data from the {@link OH_UdmfData}. 260 * 261 * @param data Represents a pointer to an instance of {@link OH_UdmfData}. 262 * @param html Represents a pointer to an instance of {@link OH_UdsHtml}. 263 * @return Returns the status code of the execution. See {@link Udmf_ErrCode}. 264 * {@link UDMF_E_OK} success. 265 * {@link UDMF_E_INVALID_PARAM} The error code for common invalid args. 266 * @see OH_UdmfData OH_UdsHtml Udmf_ErrCode. 267 * @since 13 268 */ 269 int OH_UdmfData_GetPrimaryHtml(OH_UdmfData* data, OH_UdsHtml* html); 270 271 /** 272 * @brief Get the count of {@link OH_UdmfRecord} in the {@link OH_UdmfData}. 273 * 274 * @param data Represents a pointer to an instance of {@link OH_UdmfData}. 275 * @return Returns the count of {@link OH_UdmfRecord} 276 * @see OH_UdmfData. 277 * @since 13 278 */ 279 int OH_UdmfData_GetRecordCount(OH_UdmfData* data); 280 281 /** 282 * @brief Get the record of the specified index from the {@link OH_UdmfData}. 283 * 284 * @param data Represents a pointer to an instance of {@link OH_UdmfData}. 285 * @param index Represents the index of {@link OH_UdmfRecord} in the {@link OH_UdmfData}. 286 * @return Returns the count of {@link OH_UdmfRecord} 287 * @see OH_UdmfData. 288 * @since 13 289 */ 290 OH_UdmfRecord* OH_UdmfData_GetRecord(OH_UdmfData* data, unsigned int index); 291 292 /** 293 * @brief Checks whether the UDMF data is from a local device. 294 * 295 * @param data Represents a pointer to an instance of {@link OH_UdmfData}. 296 * @return Returns the count of {@link OH_UdmfRecord} 297 * @see OH_UdmfData. 298 * @since 13 299 */ 300 bool OH_UdmfData_IsLocal(OH_UdmfData* data); 301 302 /** 303 * @brief Creation a pointer to the instance of the {@link OH_UdmfRecord}, it's relate with UDS data. 304 * 305 * @return If the operation is successful, a pointer to the instance of the {@link OH_UdmfRecord} 306 * structure is returned. If the operation is failed, nullptr is returned. 307 * @see OH_UdmfRecord. 308 * @since 12 309 */ 310 OH_UdmfRecord* OH_UdmfRecord_Create(); 311 312 /** 313 * @brief Destroy a pointer that points to an instance of {@link OH_UdmfRecord}. 314 * 315 * @param pThis Represents a pointer to an instance of {@link OH_UdmfRecord}. 316 * @see OH_UdmfRecord. 317 * @since 12 318 */ 319 void OH_UdmfRecord_Destroy(OH_UdmfRecord* pThis); 320 321 /** 322 * @brief Add one custom data to the {@link OH_UdmfRecord} record. 323 * 324 * @param pThis Represents a pointer to an instance of {@link OH_UdmfRecord}. 325 * @param typeId Represents record type, reference udmf_meta.h. 326 * @param entry Represents custom data. 327 * @param count Represents the size of data param. 328 * @return Returns the status code of the execution. See {@link Udmf_ErrCode}. 329 * {@link UDMF_E_OK} success. 330 * {@link UDMF_E_INVALID_PARAM} The error code for common invalid args. 331 * @see OH_UdmfRecord Udmf_ErrCode. 332 * @since 12 333 */ 334 int OH_UdmfRecord_AddGeneralEntry(OH_UdmfRecord* record, const char* typeId, 335 const unsigned char* entry, unsigned int count); 336 337 /** 338 * @brief Add one {@link OH_UdsPlainText} data to the {@link OH_UdmfRecord} record. 339 * 340 * @param pThis Represents a pointer to an instance of {@link OH_UdmfRecord}. 341 * @param plainText Represents a pointer to an instance of {@link OH_UdsPlainText}. 342 * @return Returns the status code of the execution. See {@link Udmf_ErrCode}. 343 * {@link UDMF_E_OK} success. 344 * {@link UDMF_E_INVALID_PARAM} The error code for common invalid args. 345 * @see OH_UdmfRecord OH_UdsPlainText Udmf_ErrCode. 346 * @since 12 347 */ 348 int OH_UdmfRecord_AddPlainText(OH_UdmfRecord* pThis, OH_UdsPlainText* plainText); 349 350 /** 351 * @brief Add one {@link OH_UdsHyperlink} data to the {@link OH_UdmfRecord} record. 352 * 353 * @param pThis Represents a pointer to an instance of {@link OH_UdmfRecord}. 354 * @param hyperlink Represents a pointer to an instance of {@link OH_UdsHyperlink}. 355 * @return Returns the status code of the execution. See {@link Udmf_ErrCode}. 356 * {@link UDMF_E_OK} success. 357 * {@link UDMF_E_INVALID_PARAM} The error code for common invalid args. 358 * @see OH_UdmfRecord OH_UdsHyperlink Udmf_ErrCode. 359 * @since 12 360 */ 361 int OH_UdmfRecord_AddHyperlink(OH_UdmfRecord* pThis, OH_UdsHyperlink* hyperlink); 362 363 /** 364 * @brief Add one {@link OH_UdsHtml} data to the {@link OH_UdmfRecord} record. 365 * 366 * @param pThis Represents a pointer to an instance of {@link OH_UdmfRecord}. 367 * @param html Represents a pointer to an instance of {@link OH_UdsHtml}. 368 * @return Returns the status code of the execution. See {@link Udmf_ErrCode}. 369 * {@link UDMF_E_OK} success. 370 * {@link UDMF_E_INVALID_PARAM} The error code for common invalid args. 371 * @see OH_UdmfRecord OH_UdsHtml Udmf_ErrCode. 372 * @since 12 373 */ 374 int OH_UdmfRecord_AddHtml(OH_UdmfRecord* pThis, OH_UdsHtml* html); 375 376 /** 377 * @brief Add one {@link OH_UdsAppItem} data to the {@link OH_UdmfRecord} record. 378 * 379 * @param pThis Represents a pointer to an instance of {@link OH_UdmfRecord}. 380 * @param appItem Represents a pointer to an instance of {@link OH_UdsAppItem}. 381 * @return Returns the status code of the execution. See {@link Udmf_ErrCode}. 382 * {@link UDMF_E_OK} success. 383 * {@link UDMF_E_INVALID_PARAM} The error code for common invalid args. 384 * @see OH_UdmfRecord OH_UdsAppItem Udmf_ErrCode. 385 * @since 12 386 */ 387 int OH_UdmfRecord_AddAppItem(OH_UdmfRecord* pThis, OH_UdsAppItem* appItem); 388 389 /** 390 * @brief Add one {@link OH_UdsFileUri} data to the {@link OH_UdmfRecord} record. 391 * 392 * @param pThis Represents a pointer to an instance of {@link OH_UdmfRecord}. 393 * @param fileUri Represents a pointer to an instance of {@link OH_UdsFileUri}. 394 * @return Returns the status code of the execution. See {@link Udmf_ErrCode}. 395 * {@link UDMF_E_OK} success. 396 * {@link UDMF_E_INVALID_PARAM} The error code for common invalid args. 397 * @see OH_UdmfRecord OH_UdsFileUri Udmf_ErrCode. 398 * @since 13 399 */ 400 int OH_UdmfRecord_AddFileUri(OH_UdmfRecord* pThis, OH_UdsFileUri* fileUri); 401 402 /** 403 * @brief Add one {@link OH_UdsPixelMap} data to the {@link OH_UdmfRecord} record. 404 * 405 * @param pThis Represents a pointer to an instance of {@link OH_UdmfRecord}. 406 * @param pixelMap Represents a pointer to an instance of {@link OH_UdsPixelMap}. 407 * @return Returns the status code of the execution. See {@link Udmf_ErrCode}. 408 * {@link UDMF_E_OK} success. 409 * {@link UDMF_E_INVALID_PARAM} The error code for common invalid args. 410 * @see OH_UdmfRecord OH_UdsPixelMap Udmf_ErrCode. 411 * @since 13 412 */ 413 int OH_UdmfRecord_AddPixelMap(OH_UdmfRecord* pThis, OH_UdsPixelMap* pixelMap); 414 415 /** 416 * @brief Add one {@link OH_UdsArrayBuffer} data to the {@link OH_UdmfRecord} record. 417 * 418 * @param record Represents a pointer to an instance of {@link OH_UdmfRecord}. 419 * @param type Represents record type, reference udmf_meta.h. 420 * @param buffer Represents a pointer to an instance of {@link OH_UdsArrayBuffer}. 421 * @return Returns the status code of the execution. See {@link Udmf_ErrCode}. 422 * {@link UDMF_E_OK} success. 423 * {@link UDMF_E_INVALID_PARAM} The error code for common invalid args. 424 * @see OH_UdmfRecord OH_UdsArrayBuffer Udmf_ErrCode. 425 * @since 13 426 */ 427 int OH_UdmfRecord_AddArrayBuffer(OH_UdmfRecord* record, const char* type, OH_UdsArrayBuffer* buffer); 428 429 /** 430 * @brief Add one {@link OH_UdsContentForm} data to the {@link OH_UdmfRecord} record. 431 * 432 * @param pThis Represents a pointer to an instance of {@link OH_UdmfRecord}. 433 * @param contentForm Represents a pointer to an instance of {@link OH_UdsContentForm}. 434 * @return Returns the status code of the execution. See {@link Udmf_ErrCode}. 435 * {@link UDMF_E_OK} success. 436 * {@link UDMF_E_INVALID_PARAM} The error code for common invalid args. 437 * @see OH_UdmfRecord OH_UdsContentForm Udmf_ErrCode. 438 * @since 14 439 */ 440 int OH_UdmfRecord_AddContentForm(OH_UdmfRecord* pThis, OH_UdsContentForm* contentForm); 441 442 /** 443 * @brief Get all types in the {@link OH_UdmfRecord} record. 444 * 445 * @param pThis Represents a pointer to an instance of {@link OH_UdmfRecord}. 446 * @param count Represents the types count that is a output param. 447 * @return Returns string array that in {@link OH_UdmfRecord} when input parameters valid, 448 * otherwise return nullptr. 449 * @see OH_UdmfRecord. 450 * @since 12 451 */ 452 char** OH_UdmfRecord_GetTypes(OH_UdmfRecord* pThis, unsigned int* count); 453 454 /** 455 * @brief Get one entry data from the {@link OH_UdmfRecord} record. 456 * 457 * @param pThis Represents a pointer to an instance of {@link OH_UdmfRecord}. 458 * @param typeId Represents record type, reference udmf_meta.h. 459 * @param entry Represents a pointer to entry data that is a output param. 460 * @param count Represents the entry data length that is a output param. 461 * @return Returns the status code of the execution. See {@link Udmf_ErrCode}. 462 * {@link UDMF_E_OK} success. 463 * {@link UDMF_E_INVALID_PARAM} The error code for common invalid args. 464 * @see OH_UdmfRecord Udmf_ErrCode. 465 * @since 12 466 */ 467 int OH_UdmfRecord_GetGeneralEntry(OH_UdmfRecord* pThis, const char* typeId, 468 unsigned char** entry, unsigned int* count); 469 470 /** 471 * @brief Get one {@link OH_UdsPlainText} data from the {@link OH_UdmfRecord} record. 472 * 473 * @param pThis Represents a pointer to an instance of {@link OH_UdmfRecord}. 474 * @param plainText Represents a pointer to an instance of {@link OH_UdsPlainText}. 475 * @return Returns the status code of the execution. See {@link Udmf_ErrCode}. 476 * {@link UDMF_E_OK} success. 477 * {@link UDMF_E_INVALID_PARAM} The error code for common invalid args. 478 * @see OH_UdmfRecord OH_UdsPlainText Udmf_ErrCode. 479 * @since 12 480 */ 481 int OH_UdmfRecord_GetPlainText(OH_UdmfRecord* pThis, OH_UdsPlainText* plainText); 482 483 /** 484 * @brief Get one {@link OH_UdsHyperlink} data from the {@link OH_UdmfRecord} record. 485 * 486 * @param pThis Represents a pointer to an instance of {@link OH_UdmfRecord}. 487 * @param hyperlink Represents a pointer to an instance of {@link OH_UdsHyperlink}. 488 * @return Returns the status code of the execution. See {@link Udmf_ErrCode}. 489 * {@link UDMF_E_OK} success. 490 * {@link UDMF_E_INVALID_PARAM} The error code for common invalid args. 491 * @see OH_UdmfRecord OH_UdsHyperlink Udmf_ErrCode. 492 * @since 12 493 */ 494 int OH_UdmfRecord_GetHyperlink(OH_UdmfRecord* pThis, OH_UdsHyperlink* hyperlink); 495 496 /** 497 * @brief Get one {@link OH_UdsHtml} data from the {@link OH_UdmfRecord} record. 498 * 499 * @param pThis Represents a pointer to an instance of {@link OH_UdmfRecord}. 500 * @param html Represents a pointer to an instance of {@link OH_UdsHtml}. 501 * @return Returns the status code of the execution. See {@link Udmf_ErrCode}. 502 * {@link UDMF_E_OK} success. 503 * {@link UDMF_E_INVALID_PARAM} The error code for common invalid args. 504 * @see OH_UdmfRecord OH_UdsHtml Udmf_ErrCode. 505 * @since 12 506 */ 507 int OH_UdmfRecord_GetHtml(OH_UdmfRecord* pThis, OH_UdsHtml* html); 508 509 /** 510 * @brief Get one {@link OH_UdsAppItem} data from the {@link OH_UdmfRecord} record. 511 * 512 * @param pThis Represents a pointer to an instance of {@link OH_UdmfRecord}. 513 * @param appItem Represents a pointer to an instance of {@link OH_UdsAppItem}. 514 * @return Returns the status code of the execution. See {@link Udmf_ErrCode}. 515 * {@link UDMF_E_OK} success. 516 * {@link UDMF_E_INVALID_PARAM} The error code for common invalid args. 517 * @see OH_UdmfRecord OH_UdsAppItem Udmf_ErrCode. 518 * @since 12 519 */ 520 int OH_UdmfRecord_GetAppItem(OH_UdmfRecord* pThis, OH_UdsAppItem* appItem); 521 522 /** 523 * @brief Get one {@link OH_UdsFileUri} data from the {@link OH_UdmfRecord} record. 524 * 525 * @param pThis Represents a pointer to an instance of {@link OH_UdmfRecord}. 526 * @param fileUri Represents a pointer to an instance of {@link OH_UdsFileUri}. 527 * @return Returns the status code of the execution. See {@link Udmf_ErrCode}. 528 * {@link UDMF_E_OK} success. 529 * {@link UDMF_E_INVALID_PARAM} The error code for common invalid args. 530 * @see OH_UdmfRecord OH_UdsFileUri Udmf_ErrCode. 531 * @since 13 532 */ 533 int OH_UdmfRecord_GetFileUri(OH_UdmfRecord* pThis, OH_UdsFileUri* fileUri); 534 535 /** 536 * @brief Get one {@link OH_UdsPixelMap} data from the {@link OH_UdmfRecord} record. 537 * 538 * @param pThis Represents a pointer to an instance of {@link OH_UdmfRecord}. 539 * @param pixelMap Represents a pointer to an instance of {@link OH_UdsPixelMap}. 540 * @return Returns the status code of the execution. See {@link Udmf_ErrCode}. 541 * {@link UDMF_E_OK} success. 542 * {@link UDMF_E_INVALID_PARAM} The error code for common invalid args. 543 * @see OH_UdmfRecord OH_UdsPixelMap Udmf_ErrCode. 544 * @since 13 545 */ 546 int OH_UdmfRecord_GetPixelMap(OH_UdmfRecord* pThis, OH_UdsPixelMap* pixelMap); 547 548 /** 549 * @brief Get one {@link OH_UdsArrayBuffer} data from the {@link OH_UdmfRecord} record. 550 * 551 * @param record Represents a pointer to an instance of {@link OH_UdmfRecord}. 552 * @param type Represents record type, reference udmf_meta.h. 553 * @param buffer Represents a pointer to an instance of {@link OH_UdsArrayBuffer}. 554 * @return Returns the status code of the execution. See {@link Udmf_ErrCode}. 555 * {@link UDMF_E_OK} success. 556 * {@link UDMF_E_INVALID_PARAM} The error code for common invalid args. 557 * @see OH_UdmfRecord OH_UdsArrayBuffer Udmf_ErrCode. 558 * @since 13 559 */ 560 int OH_UdmfRecord_GetArrayBuffer(OH_UdmfRecord* record, const char* type, OH_UdsArrayBuffer* buffer); 561 562 /** 563 * @brief Get one {@link OH_UdsContentForm} data from the {@link OH_UdmfRecord} record. 564 * 565 * @param pThis Represents a pointer to an instance of {@link OH_UdmfRecord}. 566 * @param contentForm Represents a pointer to an instance of {@link OH_UdsContentForm}. 567 * @return Returns the status code of the execution. See {@link Udmf_ErrCode}. 568 * {@link UDMF_E_OK} success. 569 * {@link UDMF_E_INVALID_PARAM} The error code for common invalid args. 570 * @see OH_UdmfRecord OH_UdsContentForm Udmf_ErrCode. 571 * @since 14 572 */ 573 int OH_UdmfRecord_GetContentForm(OH_UdmfRecord* pThis, OH_UdsContentForm* contentForm); 574 575 /** 576 * @brief Set the data provider of the types. 577 * 578 * @param pThis Represents a pointer to an instance of {@link OH_UdmfRecord}. 579 * @param types Represents a pointer to a group of data types; 580 * @param count Represents the number of data types; 581 * @param provider Represents a pointer an instance of {@link OH_UdmfRecordProvider}. 582 * @return Returns the status code of the execution. See {@link Udmf_ErrCode}. 583 * {@link UDMF_E_OK} success. 584 * {@link UDMF_E_INVALID_PARAM} The error code for common invalid args. 585 * @see OH_UdmfRecord OH_UdmfRecordProvider Udmf_ErrCode. 586 * @since 13 587 */ 588 int OH_UdmfRecord_SetProvider(OH_UdmfRecord* pThis, const char* const* types, unsigned int count, 589 OH_UdmfRecordProvider* provider); 590 591 /** 592 * @brief Creation a pointer to the instance of the {@link OH_UdmfProperty} 593 * from a {@link OH_UdmfData} data. 594 * 595 * @param unifiedData Represents a pointer to an instance of {@link OH_UdmfData}. 596 * @return If the operation is successful, a pointer to the instance of the {@link OH_UdmfProperty} 597 * structure is returned. If the operation is failed, nullptr is returned. 598 * @see OH_UdmfData OH_UdmfProperty. 599 * @since 12 600 */ 601 OH_UdmfProperty* OH_UdmfProperty_Create(OH_UdmfData* unifiedData); 602 603 /** 604 * @brief Destroy a pointer that points to the {@link OH_UdmfProperty} instance. 605 * 606 * @param pThis Represents a pointer to an instance of {@link OH_UdmfProperty}. 607 * @see OH_UdmfProperty. 608 * @since 12 609 */ 610 void OH_UdmfProperty_Destroy(OH_UdmfProperty* pThis); 611 612 /** 613 * @brief Get tag value from the {@link OH_UdmfProperty}. 614 * 615 * @param pThis Represents a pointer to an instance of {@link OH_UdmfProperty}. 616 * @return Returns a pointer of the tag value string when input parameters valid, otherwise return nullptr. 617 * @see OH_UdmfProperty. 618 * @since 12 619 */ 620 const char* OH_UdmfProperty_GetTag(OH_UdmfProperty* pThis); 621 622 /** 623 * @brief Get timestamp value from the {@link OH_UdmfProperty}. 624 * 625 * @param pThis Represents a pointer to an instance of {@link OH_UdmfProperty}. 626 * @return Returns timestamp value. 627 * @see OH_UdmfProperty 628 * @since 12 629 */ 630 int64_t OH_UdmfProperty_GetTimestamp(OH_UdmfProperty* pThis); 631 632 /** 633 * @brief Get share option value from the {@link OH_UdmfProperty}. 634 * 635 * @param pThis Represents a pointer to an instance of {@link OH_UdmfProperty}. 636 * @return Returns {@link Udmf_ShareOption} value. 637 * @see OH_UdmfProperty Udmf_ShareOption 638 * @since 12 639 */ 640 Udmf_ShareOption OH_UdmfProperty_GetShareOption(OH_UdmfProperty* pThis); 641 642 /** 643 * @brief Get integer value by key from the {@link OH_UdmfProperty}. 644 * 645 * @param pThis Represents a pointer to an instance of {@link OH_UdmfProperty}. 646 * @param key Represents key-value pair's key 647 * @param defaultValue Represents when get value failure. 648 * @return Returns value associated with the key in successfully, otherwise return defaultValue. 649 * @see OH_UdmfProperty. 650 * @since 12 651 */ 652 int OH_UdmfProperty_GetExtrasIntParam(OH_UdmfProperty* pThis, 653 const char* key, int defaultValue); 654 655 /** 656 * @brief Get tag value from the {@link OH_UdmfProperty}. 657 * 658 * @param pThis Represents a pointer to an instance of {@link OH_UdmfProperty}. 659 * @param key Represents key-value pair's key. 660 * @return Returns a pointer of the key value string when input parameters valid, otherwise return nullptr. 661 * @see OH_UdmfProperty 662 * @since 12 663 */ 664 const char* OH_UdmfProperty_GetExtrasStringParam(OH_UdmfProperty* pThis, const char* key); 665 666 /** 667 * @brief Set tag value to {@link OH_UdmfProperty} . 668 * 669 * @param pThis Represents a pointer to an instance of {@link OH_UdmfProperty}. 670 * @param tag Represents new tag param. 671 * @return Returns the status code of the execution. See {@link Udmf_ErrCode}. 672 * {@link UDMF_E_OK} success. 673 * {@link UDMF_E_INVALID_PARAM} The error code for common invalid args. 674 * @see OH_UdmfProperty Udmf_ErrCode. 675 * @since 12 676 */ 677 int OH_UdmfProperty_SetTag(OH_UdmfProperty* pThis, const char* tag); 678 679 /** 680 * @brief Set Udmf_ShareOption value to {@link OH_UdmfProperty}. 681 * 682 * @param pThis Represents a pointer to an instance of {@link OH_UdmfProperty}. 683 * @param option Represents new {@link Udmf_ShareOption} param. 684 * @return Returns the status code of the execution. See {@link Udmf_ErrCode}. 685 * {@link UDMF_E_OK} success. 686 * {@link UDMF_E_INVALID_PARAM} The error code for common invalid args. 687 * @see OH_UdmfProperty Udmf_ShareOption Udmf_ErrCode. 688 * @since 12 689 */ 690 int OH_UdmfProperty_SetShareOption(OH_UdmfProperty* pThis, Udmf_ShareOption option); 691 692 /** 693 * @brief Set extras param to {@link OH_UdmfProperty}. 694 * 695 * @param pThis Represents a pointer to an instance of {@link OH_UdmfProperty}. 696 * @param key Represents extras param's key value. 697 * @param param Represents value of k-v pairs. 698 * @return Returns the status code of the execution. See {@link Udmf_ErrCode}. 699 * {@link UDMF_E_OK} success. 700 * {@link UDMF_E_INVALID_PARAM} The error code for common invalid args. 701 * @see OH_UdmfProperty Udmf_ErrCode. 702 * @since 12 703 */ 704 int OH_UdmfProperty_SetExtrasIntParam(OH_UdmfProperty* pThis, const char* key, int param); 705 706 /** 707 * @brief Set extras param to {@link OH_UdmfProperty}. 708 * 709 * @param pThis Represents a pointer to an instance of {@link OH_UdmfProperty}. 710 * @param key Represents extras param's key value. 711 * @param param Represents value of k-v pairs. 712 * @return Returns the status code of the execution. See {@link Udmf_ErrCode}. 713 * {@link UDMF_E_OK} success. 714 * {@link UDMF_E_INVALID_PARAM} The error code for common invalid args. 715 * @see OH_UdmfProperty Udmf_ErrCode. 716 * @since 12 717 */ 718 int OH_UdmfProperty_SetExtrasStringParam(OH_UdmfProperty* pThis, 719 const char* key, const char* param); 720 721 /** 722 * @brief Get {@link OH_UdmfData} data from udmf database. 723 * 724 * @param key Represents database store's key value. 725 * @param intention Represents data type {@link Udmf_Intention} 726 * @param unifiedData Represents output params of {@link OH_UdmfData}; 727 * @return Returns the status code of the execution. See {@link Udmf_ErrCode}. 728 * {@link UDMF_E_OK} success. 729 * {@link UDMF_E_INVALID_PARAM} The error code for common invalid args. 730 * @see OH_UdmfProperty Udmf_Intention Udmf_ErrCode. 731 * @since 12 732 */ 733 int OH_Udmf_GetUnifiedData(const char* key, Udmf_Intention intention, OH_UdmfData* unifiedData); 734 735 /** 736 * @brief Set {@link OH_UdmfData} data to database. 737 * 738 * @param intention Represents data type {@link Udmf_Intention}. 739 * @param unifiedData Represents a pointer to an instance of {@link OH_UdmfData}. 740 * @param key Represents return value after set data to database successfully, 741 * it's memory size not less than {@link UDMF_KEY_BUFFER_LEN}. 742 * @param keyLen Represents size of key param. 743 * @return Returns the status code of the execution. See {@link Udmf_ErrCode}. 744 * {@link UDMF_E_OK} success. 745 * {@link UDMF_E_INVALID_PARAM} The error code for common invalid args. 746 * @see OH_UdmfProperty Udmf_Intention Udmf_ErrCode. 747 * @since 12 748 */ 749 int OH_Udmf_SetUnifiedData(Udmf_Intention intention, OH_UdmfData* unifiedData, 750 char* key, unsigned int keyLen); 751 752 #ifdef __cplusplus 753 }; 754 #endif 755 756 /** @} */ 757 #endif 758