• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# utd.h
2
3## Overview
4
5Defines APIs and structs related to the Uniform Type Descriptors (UTDs).
6
7**File to include**: <database/udmf/utd.h>
8
9**Library**: libudmf.so
10
11**System capability**: SystemCapability.DistributedDataManager.UDMF.Core
12
13**Since**: 12
14
15**Related module**: [UDMF](capi-udmf.md)
16
17## Summary
18
19### Structs
20
21| Name                    | typedef Keyword| Description                |
22| ------------------------ | ------------- | -------------------- |
23| [OH_Utd](capi-udmf-oh-utd.md) | OH_Utd        | Defines a struct for a UTD.|
24
25### Functions
26
27| Name                                                        | Description                                                        |
28| ------------------------------------------------------------ | ------------------------------------------------------------ |
29| [OH_Utd* OH_Utd_Create(const char* typeId)](#oh_utd_create)  | Creates an [OH_Utd](capi-udmf-oh-utd.md) instance and a pointer to it.    |
30| [void OH_Utd_Destroy(OH_Utd* pThis)](#oh_utd_destroy)        | Destroys an [OH_Utd](capi-udmf-oh-utd.md) instance.|
31| [const char* OH_Utd_GetTypeId(OH_Utd* pThis)](#oh_utd_gettypeid) | Obtains the type ID from an [OH_Utd](capi-udmf-oh-utd.md) instance.        |
32| [const char* OH_Utd_GetDescription(OH_Utd* pThis)](#oh_utd_getdescription) | Obtains the description from an [OH_Utd](capi-udmf-oh-utd.md) instance.      |
33| [const char* OH_Utd_GetReferenceUrl(OH_Utd* pThis)](#oh_utd_getreferenceurl) | Obtains the URL from an [OH_Utd](capi-udmf-oh-utd.md) instance.       |
34| [const char* OH_Utd_GetIconFile(OH_Utd* pThis)](#oh_utd_geticonfile) | Obtains the path of the default icon file from an [OH_Utd](capi-udmf-oh-utd.md) instance.|
35| [const char** OH_Utd_GetBelongingToTypes(OH_Utd* pThis, unsigned int* count)](#oh_utd_getbelongingtotypes) | Obtains the relationships between the data from an [OH_Utd](capi-udmf-oh-utd.md) instance.|
36| [const char** OH_Utd_GetFilenameExtensions(OH_Utd* pThis, unsigned int* count)](#oh_utd_getfilenameextensions) | Obtains the file name extensions associated with an [OH_Utd](capi-udmf-oh-utd.md) instance.|
37| [const char** OH_Utd_GetMimeTypes(OH_Utd* pThis, unsigned int* count)](#oh_utd_getmimetypes) | Obtains the MIME types associated with an [OH_Utd](capi-udmf-oh-utd.md) instance.        |
38| [const char** OH_Utd_GetTypesByFilenameExtension(const char* extension, unsigned int* count)](#oh_utd_gettypesbyfilenameextension) | Obtains the uniform data types based on the file name extensions.        |
39| [const char** OH_Utd_GetTypesByMimeType(const char* mimeType, unsigned int* count)](#oh_utd_gettypesbymimetype) | Obtains the uniform data types based on the MIME types.                |
40| [bool OH_Utd_BelongsTo(const char* srcTypeId, const char* destTypeId)](#oh_utd_belongsto) | Checks whether a UTD belongs to the target UTD.                |
41| [bool OH_Utd_IsLower(const char* srcTypeId, const char* destTypeId)](#oh_utd_islower) | Checks whether a UTD is a lower-level type of the target UTD. For example, **TYPE_SCRIPT** is a lower-level type of **SOURCE_CODE**, and **TYPE_SCRIPT** and **SOURCE_CODE** are lower-level types of **PLAIN_TEXT**.|
42| [bool OH_Utd_IsHigher(const char* srcTypeId, const char* destTypeId)](#oh_utd_ishigher) | Checks whether a UTD is a higher-level type of the target UTD. For example, **SOURCE_CODE** is a higher-level type of **TYPE_SCRIPT**, and **PLAIN_TEXT** is a higher-level type of **SOURCE_CODE** and **TYPE_SCRIPT**.|
43| [bool OH_Utd_Equals(OH_Utd* utd1, OH_Utd* utd2)](#oh_utd_equals) | Checks whether two UTDs are the same.                        |
44| [void OH_Utd_DestroyStringList(const char** list, unsigned int count)](#oh_utd_destroystringlist) | Destroys a UTD list.                      |
45
46## Function Description
47
48### OH_Utd_Create()
49
50```
51OH_Utd* OH_Utd_Create(const char* typeId)
52```
53
54**Description**
55
56Creates an [OH_Utd](capi-udmf-oh-utd.md) instance and a pointer to it.
57
58**Since**: 12
59
60
61**Parameters**
62
63| Name            | Description                |
64| ------------------ | -------------------- |
65| const char* typeId | Pointer to the type ID of the instance to create.|
66
67**Returns**
68
69| Type                     | Description                                                        |
70| ------------------------- | ------------------------------------------------------------ |
71| [OH_Utd](capi-udmf-oh-utd.md)* | Returns a pointer to the [OH_Utd](capi-udmf-oh-utd.md) instance created if the operation is successful; returns **nullptr** otherwise.<br>If this pointer is no longer required, use [OH_Utd_Destroy](capi-utd-h.md#oh_utd_destroy) to destroy it. Otherwise, memory leaks may occur.|
72
73### OH_Utd_Destroy()
74
75```
76void OH_Utd_Destroy(OH_Utd* pThis)
77```
78
79**Description**
80
81Destroys an [OH_Utd](capi-udmf-oh-utd.md) instance.
82
83**Since**: 12
84
85
86**Parameters**
87
88| Name                         | Description                                                    |
89| ------------------------------- | -------------------------------------------------------- |
90| [OH_Utd](capi-udmf-oh-utd.md)* pThis | Pointer to the [OH_Utd](capi-udmf-oh-utd.md) instance.|
91
92### OH_Utd_GetTypeId()
93
94```
95const char* OH_Utd_GetTypeId(OH_Utd* pThis)
96```
97
98**Description**
99
100Obtains the type ID from an [OH_Utd](capi-udmf-oh-utd.md) instance.
101
102**Since**: 12
103
104
105**Parameters**
106
107| Name                         | Description                                                        |
108| ------------------------------- | ------------------------------------------------------------ |
109| [OH_Utd](capi-udmf-oh-utd.md)* pThis | Pointer to the [OH_Utd](capi-udmf-oh-utd.md) instance.|
110
111**Returns**
112
113| Type       | Description                                                     |
114| ----------- | --------------------------------------------------------- |
115| const char* | Returns a pointer to the type ID obtained if the operation is successful; returns **nullptr** otherwise.|
116
117### OH_Utd_GetDescription()
118
119```
120const char* OH_Utd_GetDescription(OH_Utd* pThis)
121```
122
123**Description**
124
125Obtains the description from an [OH_Utd](capi-udmf-oh-utd.md) instance.
126
127**Since**: 12
128
129
130**Parameters**
131
132| Name                         | Description                                                        |
133| ------------------------------- | ------------------------------------------------------------ |
134| [OH_Utd](capi-udmf-oh-utd.md)* pThis | Pointer to the [OH_Utd](capi-udmf-oh-utd.md) instance.|
135
136**Returns**
137
138| Type       | Description                                                       |
139| ----------- | ----------------------------------------------------------- |
140| const char* | Returns a pointer to the description obtained if the operation is successful; returns **nullptr** otherwise.|
141
142### OH_Utd_GetReferenceUrl()
143
144```
145const char* OH_Utd_GetReferenceUrl(OH_Utd* pThis)
146```
147
148**Description**
149
150Obtains the URL from an [OH_Utd](capi-udmf-oh-utd.md) instance.
151
152**Since**: 12
153
154
155**Parameters**
156
157| Name                         | Description                                                        |
158| ------------------------------- | ------------------------------------------------------------ |
159| [OH_Utd](capi-udmf-oh-utd.md)* pThis | Pointer to the [OH_Utd](capi-udmf-oh-utd.md) instance.|
160
161**Returns**
162
163| Type       | Description                                                      |
164| ----------- | ---------------------------------------------------------- |
165| const char* | Returns a pointer to the URL obtained if the operation is successful; returns **nullptr** otherwise.|
166
167### OH_Utd_GetIconFile()
168
169```
170const char* OH_Utd_GetIconFile(OH_Utd* pThis)
171```
172
173**Description**
174
175Obtains the path of the default icon file from an [OH_Utd](capi-udmf-oh-utd.md) instance.
176
177**Since**: 12
178
179
180**Parameters**
181
182| Name                         | Description                                                        |
183| ------------------------------- | ------------------------------------------------------------ |
184| [OH_Utd](capi-udmf-oh-utd.md)* pThis | Pointer to the [OH_Utd](capi-udmf-oh-utd.md) instance.|
185
186**Returns**
187
188| Type       | Description                                                        |
189| ----------- | ------------------------------------------------------------ |
190| const char* | Returns a pointer to the path of the default icon file obtained if the operation is successful; returns **nullptr** otherwise.|
191
192### OH_Utd_GetBelongingToTypes()
193
194```
195const char** OH_Utd_GetBelongingToTypes(OH_Utd* pThis, unsigned int* count)
196```
197
198**Description**
199
200Obtains the relationships between the data from an [OH_Utd](capi-udmf-oh-utd.md) instance.
201
202**Since**: 12
203
204
205**Parameters**
206
207| Name                         | Description                                                        |
208| ------------------------------- | ------------------------------------------------------------ |
209| [OH_Utd](capi-udmf-oh-utd.md)* pThis | Pointer to the [OH_Utd](capi-udmf-oh-utd.md) instance.|
210| unsigned int* count             | Pointer to the number of data types obtained.          |
211
212**Returns**
213
214| Type        | Description                                                        |
215| ------------ | ------------------------------------------------------------ |
216| const char** | Returns a pointer to the relationship information obtained if the operation is successful; returns **nullptr** otherwise.|
217
218### OH_Utd_GetFilenameExtensions()
219
220```
221const char** OH_Utd_GetFilenameExtensions(OH_Utd* pThis, unsigned int* count)
222```
223
224**Description**
225
226Obtains the file name extensions associated with an [OH_Utd](capi-udmf-oh-utd.md) instance.
227
228**Since**: 12
229
230
231**Parameters**
232
233| Name                         | Description                                                        |
234| ------------------------------- | ------------------------------------------------------------ |
235| [OH_Utd](capi-udmf-oh-utd.md)* pThis | Pointer to the [OH_Utd](capi-udmf-oh-utd.md) instance.|
236| unsigned int* count             | Pointer to the number of file name extensions obtained.    |
237
238**Returns**
239
240| Type        | Description                                                        |
241| ------------ | ------------------------------------------------------------ |
242| const char** | Returns a pointer to the file name extensions obtained if the operation is successful; returns **nullptr** otherwise.|
243
244### OH_Utd_GetMimeTypes()
245
246```
247const char** OH_Utd_GetMimeTypes(OH_Utd* pThis, unsigned int* count)
248```
249
250**Description**
251
252Obtains the MIME types associated with an [OH_Utd](capi-udmf-oh-utd.md) instance.
253
254**Since**: 12
255
256
257**Parameters**
258
259| Name                         | Description                                                        |
260| ------------------------------- | ------------------------------------------------------------ |
261| [OH_Utd](capi-udmf-oh-utd.md)* pThis | Pointer to the [OH_Utd](capi-udmf-oh-utd.md) instance.|
262| unsigned int* count             | Pointer to the number of MIME types obtained.      |
263
264**Returns**
265
266| Type        | Description                                                        |
267| ------------ | ------------------------------------------------------------ |
268| const char** | Returns a pointer to the MIME types obtained if the operation is successful; returns **nullptr** otherwise.|
269
270### OH_Utd_GetTypesByFilenameExtension()
271
272```
273const char** OH_Utd_GetTypesByFilenameExtension(const char* extension, unsigned int* count)
274```
275
276**Description**
277
278Obtains the uniform data types based on the file name extensions.
279
280**Since**: 12
281
282
283**Parameters**
284
285| Name               | Description                                              |
286| --------------------- | -------------------------------------------------- |
287| const char* extension | Pointer to the file name extensions.                                  |
288| unsigned int* count   | Pointer to the number of data types obtained.|
289
290**Returns**
291
292| Type        | Description                                                        |
293| ------------ | ------------------------------------------------------------ |
294| const char** | Returns a pointer to the uniform data types obtained.<br>If it is no longer required, use [OH_Utd_DestroyStringList](capi-utd-h.md#oh_utd_destroystringlist) to destroy it. Otherwise, memory leakage occurs.|
295
296### OH_Utd_GetTypesByMimeType()
297
298```
299const char** OH_Utd_GetTypesByMimeType(const char* mimeType, unsigned int* count)
300```
301
302**Description**
303
304Obtains the uniform data types based on the MIME types.
305
306**Since**: 12
307
308
309**Parameters**
310
311| Name              | Description                                              |
312| -------------------- | -------------------------------------------------- |
313| const char* mimeType | Pointer to the MIME types.                              |
314| unsigned int* count  | Pointer to the number of data types obtained.|
315
316**Returns**
317
318| Type        | Description                                                        |
319| ------------ | ------------------------------------------------------------ |
320| const char** | Returns a pointer to the uniform data types obtained.<br>If it is no longer required, use [OH_Utd_DestroyStringList](capi-utd-h.md#oh_utd_destroystringlist) to destroy it. Otherwise, memory leakage occurs.|
321
322### OH_Utd_BelongsTo()
323
324```
325bool OH_Utd_BelongsTo(const char* srcTypeId, const char* destTypeId)
326```
327
328**Description**
329
330Checks whether a UTD belongs to the target UTD.
331
332**Since**: 12
333
334
335**Parameters**
336
337| Name                | Description                    |
338| ---------------------- | ------------------------ |
339| const char* srcTypeId  | Pointer to the UTD to check.  |
340| const char* destTypeId | Pointer to the target UTD.|
341
342**Returns**
343
344| Type| Description                                                       |
345| ---- | ----------------------------------------------------------- |
346| bool | Returns **true** if the UTD belongs to the target UTD; returns **false** otherwise.|
347
348### OH_Utd_IsLower()
349
350```
351bool OH_Utd_IsLower(const char* srcTypeId, const char* destTypeId)
352```
353
354**Description**
355
356Checks whether a UTD is a lower-level type of the target UTD. For example, **TYPE_SCRIPT** is a lower-level type of **SOURCE_CODE**, and **TYPE_SCRIPT** and **SOURCE_CODE** are lower-level types of **PLAIN_TEXT**.
357
358**Since**: 12
359
360
361**Parameters**
362
363| Name                | Description                    |
364| ---------------------- | ------------------------ |
365| const char* srcTypeId  | Pointer to the UTD to check.  |
366| const char* destTypeId | Pointer to the target UTD.|
367
368**Returns**
369
370| Type| Description                                                       |
371| ---- | ----------------------------------------------------------- |
372| bool | Returns **true** if the UTD is a lower-level type of the target UTD; returns **false** otherwise.|
373
374### OH_Utd_IsHigher()
375
376```
377bool OH_Utd_IsHigher(const char* srcTypeId, const char* destTypeId)
378```
379
380**Description**
381
382Checks whether a UTD is a higher-level type of the target UTD. For example, **SOURCE_CODE** is a higher-level type of **TYPE_SCRIPT**, and **PLAIN_TEXT** is a higher-level type of **SOURCE_CODE** and **TYPE_SCRIPT**.
383
384**Since**: 12
385
386
387**Parameters**
388
389| Name                | Description                    |
390| ---------------------- | ------------------------ |
391| const char* srcTypeId  | Pointer to the UTD to check.  |
392| const char* destTypeId | Pointer to the target UTD.|
393
394**Returns**
395
396| Type| Description                                                       |
397| ---- | ----------------------------------------------------------- |
398| bool | Returns **true** if the UTD is a higher-level type of the target UTD; returns **false** otherwise.|
399
400### OH_Utd_Equals()
401
402```
403bool OH_Utd_Equals(OH_Utd* utd1, OH_Utd* utd2)
404```
405
406**Description**
407
408Checks whether two UTDs are the same.
409
410**Since**: 12
411
412
413**Parameters**
414
415| Name                        | Description                                                        |
416| ------------------------------ | ------------------------------------------------------------ |
417| [OH_Utd](capi-udmf-oh-utd.md)* utd1 | Pointer to a [OH_Utd](capi-udmf-oh-utd.md) instance.|
418| [OH_Utd](capi-udmf-oh-utd.md)* utd2 | Pointer to another [OH_Utd](capi-udmf-oh-utd.md) instance.|
419
420**Returns**
421
422| Type| Description                                           |
423| ---- | ----------------------------------------------- |
424| bool | Returns **true** if the two instances are the same; returns **false** otherwise.|
425
426### OH_Utd_DestroyStringList()
427
428```
429void OH_Utd_DestroyStringList(const char** list, unsigned int count)
430```
431
432**Description**
433
434Destroys a UTD list.
435
436**Since**: 12
437
438
439**Parameters**
440
441| Name            | Description                                |
442| ------------------ | ------------------------------------ |
443| const char** list  | Double pointer to the UTD list to destroy.                |
444| unsigned int count | Length of the UTD list.|
445