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