1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/intl/icu/source/common/ucmndata.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,111 @@ 1.4 +/* 1.5 +****************************************************************************** 1.6 +* 1.7 +* Copyright (C) 1999-2011, International Business Machines 1.8 +* Corporation and others. All Rights Reserved. 1.9 +* 1.10 +******************************************************************************/ 1.11 + 1.12 + 1.13 +/*---------------------------------------------------------------------------------- 1.14 + * 1.15 + * UCommonData An abstract interface for dealing with ICU Common Data Files. 1.16 + * ICU Common Data Files are a grouping of a number of individual 1.17 + * data items (resources, converters, tables, anything) into a 1.18 + * single file or dll. The combined format includes a table of 1.19 + * contents for locating the individual items by name. 1.20 + * 1.21 + * Two formats for the table of contents are supported, which is 1.22 + * why there is an abstract inteface involved. 1.23 + * 1.24 + * These functions are part of the ICU internal implementation, and 1.25 + * are not inteded to be used directly by applications. 1.26 + */ 1.27 + 1.28 +#ifndef __UCMNDATA_H__ 1.29 +#define __UCMNDATA_H__ 1.30 + 1.31 +#include "unicode/udata.h" 1.32 +#include "umapfile.h" 1.33 + 1.34 + 1.35 +#define COMMON_DATA_NAME U_ICUDATA_NAME 1.36 + 1.37 +typedef struct { 1.38 + uint16_t headerSize; 1.39 + uint8_t magic1; 1.40 + uint8_t magic2; 1.41 +} MappedData; 1.42 + 1.43 + 1.44 +typedef struct { 1.45 + MappedData dataHeader; 1.46 + UDataInfo info; 1.47 +} DataHeader; 1.48 + 1.49 +typedef struct { 1.50 + uint32_t nameOffset; 1.51 + uint32_t dataOffset; 1.52 +} UDataOffsetTOCEntry; 1.53 + 1.54 +typedef struct { 1.55 + uint32_t count; 1.56 + UDataOffsetTOCEntry entry[2]; /* Actual size of array is from count. */ 1.57 +} UDataOffsetTOC; 1.58 + 1.59 +/** 1.60 + * Get the header size from a const DataHeader *udh. 1.61 + * Handles opposite-endian data. 1.62 + * 1.63 + * @internal 1.64 + */ 1.65 +U_CFUNC uint16_t 1.66 +udata_getHeaderSize(const DataHeader *udh); 1.67 + 1.68 +/** 1.69 + * Get the UDataInfo.size from a const UDataInfo *info. 1.70 + * Handles opposite-endian data. 1.71 + * 1.72 + * @internal 1.73 + */ 1.74 +U_CFUNC uint16_t 1.75 +udata_getInfoSize(const UDataInfo *info); 1.76 + 1.77 +U_CDECL_BEGIN 1.78 +/* 1.79 + * "Virtual" functions for data lookup. 1.80 + * To call one, given a UDataMemory *p, the code looks like this: 1.81 + * p->vFuncs.Lookup(p, tocEntryName, pErrorCode); 1.82 + * (I sure do wish this was written in C++, not C) 1.83 + */ 1.84 + 1.85 +typedef const DataHeader * 1.86 +(U_CALLCONV * LookupFn)(const UDataMemory *pData, 1.87 + const char *tocEntryName, 1.88 + int32_t *pLength, 1.89 + UErrorCode *pErrorCode); 1.90 + 1.91 +typedef uint32_t 1.92 +(U_CALLCONV * NumEntriesFn)(const UDataMemory *pData); 1.93 + 1.94 +U_CDECL_END 1.95 + 1.96 +typedef struct { 1.97 + LookupFn Lookup; 1.98 + NumEntriesFn NumEntries; 1.99 +} commonDataFuncs; 1.100 + 1.101 + 1.102 +/* 1.103 + * Functions to check whether a UDataMemory refers to memory containing 1.104 + * a recognizable header and table of contents a Common Data Format 1.105 + * 1.106 + * If a valid header and TOC are found, 1.107 + * set the CommonDataFuncs function dispatch vector in the UDataMemory 1.108 + * to point to the right functions for the TOC type. 1.109 + * otherwise 1.110 + * set an errorcode. 1.111 + */ 1.112 +U_CFUNC void udata_checkCommonData(UDataMemory *pData, UErrorCode *pErrorCode); 1.113 + 1.114 +#endif