1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/textandloc/fontservices/textshaperplugin/IcuSource/common/ucmndata.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,109 @@
1.4 +/*
1.5 +******************************************************************************
1.6 +*
1.7 +* Copyright (C) 1999-2003, 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 +/*
1.78 + * "Virtual" functions for data lookup.
1.79 + * To call one, given a UDataMemory *p, the code looks like this:
1.80 + * p->vFuncs.Lookup(p, tocEntryName, pErrorCode);
1.81 + * (I sure do wish this was written in C++, not C)
1.82 + */
1.83 +
1.84 +typedef const DataHeader *
1.85 +(* LookupFn)(const UDataMemory *pData,
1.86 + const char *tocEntryName,
1.87 + int32_t *pLength,
1.88 + UErrorCode *pErrorCode);
1.89 +
1.90 +typedef uint32_t
1.91 +(* NumEntriesFn)(const UDataMemory *pData);
1.92 +
1.93 +typedef struct {
1.94 + LookupFn Lookup;
1.95 + NumEntriesFn NumEntries;
1.96 +} commonDataFuncs;
1.97 +
1.98 +
1.99 +/*
1.100 + * Functions to check whether a UDataMemory refers to memory containing
1.101 + * a recognizable header and table of contents a Common Data Format
1.102 + *
1.103 + * If a valid header and TOC are found,
1.104 + * set the CommonDataFuncs function dispatch vector in the UDataMemory
1.105 + * to point to the right functions for the TOC type.
1.106 + * otherwise
1.107 + * set an errorcode.
1.108 + */
1.109 +void udata_checkCommonData(UDataMemory *pData, UErrorCode *pErrorCode);
1.110 +
1.111 +
1.112 +#endif