114cf0368Sopenharmony_ci/*
214cf0368Sopenharmony_ci * Copyright (c) 2024 Huawei Device Co., Ltd.
314cf0368Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
414cf0368Sopenharmony_ci * you may not use this file except in compliance with the License.
514cf0368Sopenharmony_ci * You may obtain a copy of the License at
614cf0368Sopenharmony_ci *
714cf0368Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
814cf0368Sopenharmony_ci *
914cf0368Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
1014cf0368Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
1114cf0368Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1214cf0368Sopenharmony_ci * See the License for the specific language governing permissions and
1314cf0368Sopenharmony_ci * limitations under the License.
1414cf0368Sopenharmony_ci */
1514cf0368Sopenharmony_ci
1614cf0368Sopenharmony_ci/**
1714cf0368Sopenharmony_ci * @addtogroup UDMF
1814cf0368Sopenharmony_ci * @{
1914cf0368Sopenharmony_ci *
2014cf0368Sopenharmony_ci * @brief The Unified Data Management Framework(UDMF) aims to define various standards
2114cf0368Sopenharmony_ci * for data across applications, devices, and platforms, providing a unified OpenHarmony
2214cf0368Sopenharmony_ci * data language and standardized data access and reading paths.
2314cf0368Sopenharmony_ci *
2414cf0368Sopenharmony_ci * @syscap SystemCapability.DistributedDataManager.UDMF.Core
2514cf0368Sopenharmony_ci * @since 12
2614cf0368Sopenharmony_ci */
2714cf0368Sopenharmony_ci
2814cf0368Sopenharmony_ci/**
2914cf0368Sopenharmony_ci * @file utd.h
3014cf0368Sopenharmony_ci *
3114cf0368Sopenharmony_ci * @brief Provides uniform type descriptor(UTD) related functions and struct.
3214cf0368Sopenharmony_ci *
3314cf0368Sopenharmony_ci * @kit ArkData
3414cf0368Sopenharmony_ci * @library libudmf.so
3514cf0368Sopenharmony_ci * @syscap SystemCapability.DistributedDataManager.UDMF.Core
3614cf0368Sopenharmony_ci * @since 12
3714cf0368Sopenharmony_ci */
3814cf0368Sopenharmony_ci
3914cf0368Sopenharmony_ci#ifndef UTD_H
4014cf0368Sopenharmony_ci#define UTD_H
4114cf0368Sopenharmony_ci
4214cf0368Sopenharmony_ci#include <stdbool.h>
4314cf0368Sopenharmony_ci
4414cf0368Sopenharmony_ci#ifdef __cplusplus
4514cf0368Sopenharmony_ciextern "C" {
4614cf0368Sopenharmony_ci#endif
4714cf0368Sopenharmony_ci
4814cf0368Sopenharmony_ci/**
4914cf0368Sopenharmony_ci * @brief Describes the unified data type descriptor.
5014cf0368Sopenharmony_ci *
5114cf0368Sopenharmony_ci * @since 12
5214cf0368Sopenharmony_ci */
5314cf0368Sopenharmony_citypedef struct OH_Utd OH_Utd;
5414cf0368Sopenharmony_ci
5514cf0368Sopenharmony_ci/**
5614cf0368Sopenharmony_ci * @brief Prouct a pointer to the instance of the {@link OH_Utd}.
5714cf0368Sopenharmony_ci *
5814cf0368Sopenharmony_ci * @param typeId Represents type of UTD, reference udmf_meta.h.
5914cf0368Sopenharmony_ci * @return If the operation is successful, a pointer to the instance of the {@link OH_Utd}
6014cf0368Sopenharmony_ci * structure is returned.If the operation is failed, nullptr is returned.
6114cf0368Sopenharmony_ci * Must be destroyed with {@link OH_Utd_DestroyTypeDescriptor} when not needed.
6214cf0368Sopenharmony_ci * @see OH_Utd.
6314cf0368Sopenharmony_ci * @since 12
6414cf0368Sopenharmony_ci */
6514cf0368Sopenharmony_ciOH_Utd* OH_Utd_Create(const char* typeId);
6614cf0368Sopenharmony_ci
6714cf0368Sopenharmony_ci/**
6814cf0368Sopenharmony_ci * @brief Destroy a pointer that points to the {@link OH_Utd} instance.
6914cf0368Sopenharmony_ci *
7014cf0368Sopenharmony_ci * @param pThis Represents a pointer to an instance of {@link OH_Utd}.
7114cf0368Sopenharmony_ci * @see OH_Utd.
7214cf0368Sopenharmony_ci * @since 12
7314cf0368Sopenharmony_ci */
7414cf0368Sopenharmony_civoid OH_Utd_Destroy(OH_Utd* pThis);
7514cf0368Sopenharmony_ci
7614cf0368Sopenharmony_ci/**
7714cf0368Sopenharmony_ci * @brief Get type id from the {@link OH_Utd}.
7814cf0368Sopenharmony_ci *
7914cf0368Sopenharmony_ci * @param pThis Represents a pointer to an instance of {@link OH_Utd}.
8014cf0368Sopenharmony_ci * @return Returns a string pointer when input args normally, otherwise return nullptr.
8114cf0368Sopenharmony_ci * @see OH_Utd.
8214cf0368Sopenharmony_ci * @since 12
8314cf0368Sopenharmony_ci */
8414cf0368Sopenharmony_ciconst char* OH_Utd_GetTypeId(OH_Utd* pThis);
8514cf0368Sopenharmony_ci
8614cf0368Sopenharmony_ci/**
8714cf0368Sopenharmony_ci * @brief Get description from the {@link OH_Utd}.
8814cf0368Sopenharmony_ci *
8914cf0368Sopenharmony_ci * @param pThis Represents a pointer to an instance of {@link OH_Utd}.
9014cf0368Sopenharmony_ci * @return Returns a string pointer when input args normally, otherwise return nullptr.
9114cf0368Sopenharmony_ci * @see OH_Utd.
9214cf0368Sopenharmony_ci * @since 12
9314cf0368Sopenharmony_ci */
9414cf0368Sopenharmony_ciconst char* OH_Utd_GetDescription(OH_Utd* pThis);
9514cf0368Sopenharmony_ci
9614cf0368Sopenharmony_ci/**
9714cf0368Sopenharmony_ci * @brief Get url from the {@link OH_Utd}.
9814cf0368Sopenharmony_ci *
9914cf0368Sopenharmony_ci * @param pThis Represents a pointer to an instance of {@link OH_Utd}.
10014cf0368Sopenharmony_ci * @return Returns a string pointer when input args normally, otherwise return nullptr.
10114cf0368Sopenharmony_ci * @see OH_Utd.
10214cf0368Sopenharmony_ci * @since 12
10314cf0368Sopenharmony_ci */
10414cf0368Sopenharmony_ciconst char* OH_Utd_GetReferenceUrl(OH_Utd* pThis);
10514cf0368Sopenharmony_ci
10614cf0368Sopenharmony_ci/**
10714cf0368Sopenharmony_ci * @brief Get icon file from the {@link OH_Utd}.
10814cf0368Sopenharmony_ci *
10914cf0368Sopenharmony_ci * @param pThis Represents a pointer to an instance of {@link OH_Utd}.
11014cf0368Sopenharmony_ci * @return Returns a string pointer when input args normally, otherwise return nullptr.
11114cf0368Sopenharmony_ci * @see OH_Utd.
11214cf0368Sopenharmony_ci * @since 12
11314cf0368Sopenharmony_ci */
11414cf0368Sopenharmony_ciconst char* OH_Utd_GetIconFile(OH_Utd* pThis);
11514cf0368Sopenharmony_ci
11614cf0368Sopenharmony_ci/**
11714cf0368Sopenharmony_ci * @brief Get belong to type id of the current {@link OH_Utd}.
11814cf0368Sopenharmony_ci *
11914cf0368Sopenharmony_ci * @param pThis Represents a pointer to an instance of {@link OH_Utd}.
12014cf0368Sopenharmony_ci * @param count Represents the return types count.
12114cf0368Sopenharmony_ci * @return Returns string array when input args normally, otherwise return nullptr.
12214cf0368Sopenharmony_ci * @see OH_Utd.
12314cf0368Sopenharmony_ci * @since 12
12414cf0368Sopenharmony_ci */
12514cf0368Sopenharmony_ciconst char** OH_Utd_GetBelongingToTypes(OH_Utd* pThis, unsigned int* count);
12614cf0368Sopenharmony_ci
12714cf0368Sopenharmony_ci/**
12814cf0368Sopenharmony_ci * @brief Get filename extensions of the current {@link OH_Utd}.
12914cf0368Sopenharmony_ci *
13014cf0368Sopenharmony_ci * @param pThis Represents a pointer to an instance of {@link OH_Utd}.
13114cf0368Sopenharmony_ci * @param count Represents the return file extensions count.
13214cf0368Sopenharmony_ci * @return Returns string array when input args normally, otherwise return nullptr.
13314cf0368Sopenharmony_ci * @see OH_Utd.
13414cf0368Sopenharmony_ci * @since 12
13514cf0368Sopenharmony_ci */
13614cf0368Sopenharmony_ciconst char** OH_Utd_GetFilenameExtensions(OH_Utd* pThis, unsigned int* count);
13714cf0368Sopenharmony_ci
13814cf0368Sopenharmony_ci/**
13914cf0368Sopenharmony_ci * @brief Get mime types of the current {@link OH_Utd}.
14014cf0368Sopenharmony_ci *
14114cf0368Sopenharmony_ci * @param pThis Represents a pointer to an instance of {@link OH_Utd}.
14214cf0368Sopenharmony_ci * @param count Represents the mime types count.
14314cf0368Sopenharmony_ci * @return Returns string array when input args normally, otherwise return nullptr.
14414cf0368Sopenharmony_ci * @see OH_Utd.
14514cf0368Sopenharmony_ci * @since 12
14614cf0368Sopenharmony_ci */
14714cf0368Sopenharmony_ciconst char** OH_Utd_GetMimeTypes(OH_Utd* pThis, unsigned int* count);
14814cf0368Sopenharmony_ci
14914cf0368Sopenharmony_ci/**
15014cf0368Sopenharmony_ci * @brief Get type id by file name extension.
15114cf0368Sopenharmony_ci *
15214cf0368Sopenharmony_ci * @param extension Represents file name extension.
15314cf0368Sopenharmony_ci * @param count Represents the types count.
15414cf0368Sopenharmony_ci * @return Returns string list of types. Must be destroyed with {@link OH_Utd_DestroyStringList} when not needed.
15514cf0368Sopenharmony_ci * @since 12
15614cf0368Sopenharmony_ci */
15714cf0368Sopenharmony_ciconst char** OH_Utd_GetTypesByFilenameExtension(const char* extension, unsigned int* count);
15814cf0368Sopenharmony_ci
15914cf0368Sopenharmony_ci/**
16014cf0368Sopenharmony_ci * @brief Get type id by mime type.
16114cf0368Sopenharmony_ci *
16214cf0368Sopenharmony_ci * @param mimeType Represents mime type
16314cf0368Sopenharmony_ci * @param count Represents the types count.
16414cf0368Sopenharmony_ci * @return Returns string list of types. Must be destroyed with {@link OH_Utd_DestroyStringList} when not needed.
16514cf0368Sopenharmony_ci * @since 12
16614cf0368Sopenharmony_ci */
16714cf0368Sopenharmony_ciconst char** OH_Utd_GetTypesByMimeType(const char* mimeType, unsigned int* count);
16814cf0368Sopenharmony_ci
16914cf0368Sopenharmony_ci/**
17014cf0368Sopenharmony_ci * @brief Calculate relationships of two types.
17114cf0368Sopenharmony_ci *
17214cf0368Sopenharmony_ci * @param srcTypeId Represents source type id.
17314cf0368Sopenharmony_ci * @param destTypeId Represents target type id.
17414cf0368Sopenharmony_ci * @return Returns the status code of the execution.
17514cf0368Sopenharmony_ci *         {@code false} Represents srcTypeId not belongs to destTypeId.
17614cf0368Sopenharmony_ci *         {@code true} Represents srcTypeId belongs to destTypeId.
17714cf0368Sopenharmony_ci * @since 12
17814cf0368Sopenharmony_ci */
17914cf0368Sopenharmony_cibool OH_Utd_BelongsTo(const char* srcTypeId, const char* destTypeId);
18014cf0368Sopenharmony_ci
18114cf0368Sopenharmony_ci/**
18214cf0368Sopenharmony_ci * @brief Calculate relationships of two types.
18314cf0368Sopenharmony_ci *
18414cf0368Sopenharmony_ci * @param srcTypeId Represents source type id.
18514cf0368Sopenharmony_ci * @param destTypeId Represents target type id.
18614cf0368Sopenharmony_ci * @return Returns the status code of the execution.
18714cf0368Sopenharmony_ci *         {@code false} Represents srcTypeId not lower level to destTypeId.
18814cf0368Sopenharmony_ci *         {@code true} Represents srcTypeId lower level to destTypeId.
18914cf0368Sopenharmony_ci * @since 12
19014cf0368Sopenharmony_ci */
19114cf0368Sopenharmony_cibool OH_Utd_IsLower(const char* srcTypeId, const char* destTypeId);
19214cf0368Sopenharmony_ci
19314cf0368Sopenharmony_ci/**
19414cf0368Sopenharmony_ci * @brief Calculate relationships of two types.
19514cf0368Sopenharmony_ci *
19614cf0368Sopenharmony_ci * @param srcTypeId Represents source type id.
19714cf0368Sopenharmony_ci * @param destTypeId Represents target type id.
19814cf0368Sopenharmony_ci * @return Returns the status code of the execution.
19914cf0368Sopenharmony_ci *         {@code false} Represents srcTypeId not higher level to destTypeId.
20014cf0368Sopenharmony_ci *         {@code true} Represents srcTypeId higher level to destTypeId.
20114cf0368Sopenharmony_ci * @since 12
20214cf0368Sopenharmony_ci */
20314cf0368Sopenharmony_cibool OH_Utd_IsHigher(const char* srcTypeId, const char* destTypeId);
20414cf0368Sopenharmony_ci
20514cf0368Sopenharmony_ci/**
20614cf0368Sopenharmony_ci * @brief Calculate two {@link OH_Utd}s are equal.
20714cf0368Sopenharmony_ci *
20814cf0368Sopenharmony_ci * @param utd1 Represents a pointer to {@link OH_Utd} instance.
20914cf0368Sopenharmony_ci * @param utd2 Represents a pointer to {@link OH_Utd} instance.
21014cf0368Sopenharmony_ci * @return Returns the status code of the execution.
21114cf0368Sopenharmony_ci *         {@code false} Represents utd1 and utd2 are not equal.
21214cf0368Sopenharmony_ci *         {@code true} Represents utd1 and utd2 are equal.
21314cf0368Sopenharmony_ci * @since 12
21414cf0368Sopenharmony_ci */
21514cf0368Sopenharmony_cibool OH_Utd_Equals(OH_Utd* utd1, OH_Utd* utd2);
21614cf0368Sopenharmony_ci
21714cf0368Sopenharmony_ci/**
21814cf0368Sopenharmony_ci * @brief Destroy string list memory.
21914cf0368Sopenharmony_ci *
22014cf0368Sopenharmony_ci * @param list Represents a point to string list.
22114cf0368Sopenharmony_ci * @param count Represents string count in list.
22214cf0368Sopenharmony_ci * @since 12
22314cf0368Sopenharmony_ci */
22414cf0368Sopenharmony_civoid OH_Utd_DestroyStringList(const char** list, unsigned int count);
22514cf0368Sopenharmony_ci
22614cf0368Sopenharmony_ci#ifdef __cplusplus
22714cf0368Sopenharmony_ci};
22814cf0368Sopenharmony_ci#endif
22914cf0368Sopenharmony_ci
23014cf0368Sopenharmony_ci/** @} */
23114cf0368Sopenharmony_ci#endif
232