]> git.saurik.com Git - apple/icu.git/blame - icuSources/common/ucmndata.h
ICU-59180.0.1.tar.gz
[apple/icu.git] / icuSources / common / ucmndata.h
CommitLineData
f3c0d7a5
A
1// © 2016 and later: Unicode, Inc. and others.
2// License & terms of use: http://www.unicode.org/copyright.html
b75a7d8f
A
3/*
4******************************************************************************
5*
4388f060 6* Copyright (C) 1999-2011, International Business Machines
b75a7d8f
A
7* Corporation and others. All Rights Reserved.
8*
9******************************************************************************/
10
11
12/*----------------------------------------------------------------------------------
13 *
14 * UCommonData An abstract interface for dealing with ICU Common Data Files.
15 * ICU Common Data Files are a grouping of a number of individual
16 * data items (resources, converters, tables, anything) into a
17 * single file or dll. The combined format includes a table of
18 * contents for locating the individual items by name.
19 *
20 * Two formats for the table of contents are supported, which is
21 * why there is an abstract inteface involved.
22 *
23 * These functions are part of the ICU internal implementation, and
24 * are not inteded to be used directly by applications.
25 */
26
27#ifndef __UCMNDATA_H__
28#define __UCMNDATA_H__
29
30#include "unicode/udata.h"
31#include "umapfile.h"
32
33
34#define COMMON_DATA_NAME U_ICUDATA_NAME
35
36typedef struct {
37 uint16_t headerSize;
38 uint8_t magic1;
39 uint8_t magic2;
40} MappedData;
41
42
43typedef struct {
44 MappedData dataHeader;
45 UDataInfo info;
46} DataHeader;
47
374ca955
A
48typedef struct {
49 uint32_t nameOffset;
50 uint32_t dataOffset;
51} UDataOffsetTOCEntry;
52
53typedef struct {
54 uint32_t count;
55 UDataOffsetTOCEntry entry[2]; /* Actual size of array is from count. */
56} UDataOffsetTOC;
57
58/**
59 * Get the header size from a const DataHeader *udh.
60 * Handles opposite-endian data.
61 *
62 * @internal
63 */
64U_CFUNC uint16_t
65udata_getHeaderSize(const DataHeader *udh);
66
67/**
68 * Get the UDataInfo.size from a const UDataInfo *info.
69 * Handles opposite-endian data.
70 *
71 * @internal
72 */
73U_CFUNC uint16_t
74udata_getInfoSize(const UDataInfo *info);
b75a7d8f 75
4388f060 76U_CDECL_BEGIN
b75a7d8f
A
77/*
78 * "Virtual" functions for data lookup.
79 * To call one, given a UDataMemory *p, the code looks like this:
80 * p->vFuncs.Lookup(p, tocEntryName, pErrorCode);
81 * (I sure do wish this was written in C++, not C)
82 */
83
84typedef const DataHeader *
4388f060
A
85(U_CALLCONV * LookupFn)(const UDataMemory *pData,
86 const char *tocEntryName,
87 int32_t *pLength,
88 UErrorCode *pErrorCode);
b75a7d8f
A
89
90typedef uint32_t
4388f060
A
91(U_CALLCONV * NumEntriesFn)(const UDataMemory *pData);
92
93U_CDECL_END
b75a7d8f
A
94
95typedef struct {
96 LookupFn Lookup;
97 NumEntriesFn NumEntries;
98} commonDataFuncs;
99
100
101/*
102 * Functions to check whether a UDataMemory refers to memory containing
103 * a recognizable header and table of contents a Common Data Format
104 *
105 * If a valid header and TOC are found,
106 * set the CommonDataFuncs function dispatch vector in the UDataMemory
107 * to point to the right functions for the TOC type.
108 * otherwise
109 * set an errorcode.
110 */
729e4ab9 111U_CFUNC void udata_checkCommonData(UDataMemory *pData, UErrorCode *pErrorCode);
b75a7d8f
A
112
113#endif