~ubuntu-branches/ubuntu/gutsy/icu/gutsy-updates

« back to all changes in this revision

Viewing changes to source/common/uresdata.h

  • Committer: Package Import Robot
  • Author(s): Jay Berkenbilt
  • Date: 2005-11-19 11:29:31 UTC
  • mfrom: (1.1.2)
  • Revision ID: package-import@ubuntu.com-20051119112931-vcizkrp10tli4enw
Tags: 3.4-3
Explicitly build with g++ 3.4.  The current ICU fails its test suite
with 4.0 but not with 3.4.  Future versions should work properly with
4.0.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
******************************************************************************
3
 
*                                                                            *
4
 
* Copyright (C) 1999-2001, International Business Machines                   *
5
 
*                Corporation and others. All Rights Reserved.                *
6
 
*                                                                            *
7
 
******************************************************************************
8
 
*   file name:  uresdata.h
9
 
*   encoding:   US-ASCII
10
 
*   tab size:   8 (not used)
11
 
*   indentation:4
12
 
*
13
 
*   created on: 1999dec08
14
 
*   created by: Markus W. Scherer
15
 
*/
16
 
 
17
 
#ifndef __RESDATA_H__
18
 
#define __RESDATA_H__
19
 
 
20
 
#include "unicode/utypes.h"
21
 
#include "unicode/udata.h"
22
 
 
23
 
/*
24
 
 * A Resource is a 32-bit value that has 2 bit fields:
25
 
 * 31..28   4-bit type, see enum below
26
 
 * 27..0    28-bit four-byte-offset or value according to the type
27
 
 */
28
 
typedef uint32_t Resource;
29
 
 
30
 
#define RES_BOGUS 0xffffffff
31
 
 
32
 
#define RES_GET_TYPE(res) ((res)>>28UL)
33
 
#define RES_GET_OFFSET(res) ((res)&0x0fffffff)
34
 
#define RES_GET_POINTER(pRoot, res) ((pRoot)+RES_GET_OFFSET(res))
35
 
 
36
 
/* get signed and unsigned integer values directly from the Resource handle */
37
 
#define RES_GET_INT(res) (((int32_t)((res)<<4L))>>4L)
38
 
#define RES_GET_UINT(res) ((res)&0x0fffffff)
39
 
 
40
 
/*
41
 
 * Resource types:
42
 
 * Most resources have their values stored at four-byte offsets from the start
43
 
 * of the resource data. These values are at least 4-aligned.
44
 
 * Some resource values are stored directly in the offset field of the Resource itself.
45
 
 *
46
 
 * Type Name            Memory layout of values
47
 
 *                      (in parentheses: scalar, non-offset values)
48
 
 *
49
 
 * 0  Unicode String:   int32_t length, UChar[length], (UChar)0, (padding)
50
 
 *                  or  (empty string ("") if offset==0)
51
 
 * 1  Binary:           int32_t length, uint8_t[length], (padding)
52
 
 *                      - this value should be 32-aligned -
53
 
 * 2  Table:            uint16_t count, uint16_t keyStringOffsets[count], (uint16_t padding), Resource[count]
54
 
 *
55
 
 * 7  Integer:          (28-bit offset is integer value)
56
 
 * 8  Array:            int32_t count, Resource[count]
57
 
 *
58
 
 * 14 Integer Vector:   int32_t length, int32_t[length]
59
 
 * 15 Reserved:         This value denotes special purpose resources and is for internal use.
60
 
 
61
 
 */
62
 
 
63
 
/*
64
 
 * Structure for a single, memory-mapped ResourceBundle.
65
 
 */
66
 
typedef struct {
67
 
    UDataMemory *data;
68
 
    Resource *pRoot;
69
 
    Resource rootRes;
70
 
} ResourceData;
71
 
 
72
 
/*
73
 
 * Load a resource bundle file.
74
 
 * The ResourceData structure must be allocated externally.
75
 
 */
76
 
U_CFUNC UBool
77
 
res_load(ResourceData *pResData,
78
 
         const char *path, const char *name, UErrorCode *errorCode);
79
 
 
80
 
/*
81
 
 * Release a resource bundle file.
82
 
 * This does not release the ResourceData structure itself.
83
 
 */
84
 
U_CFUNC void
85
 
res_unload(ResourceData *pResData);
86
 
 
87
 
/*
88
 
 * Return a pointer to a zero-terminated, const UChar* string
89
 
 * and set its length in *pLength.
90
 
 * Returns NULL if not found.
91
 
 */
92
 
U_CFUNC const UChar *
93
 
res_getString(const ResourceData *pResData, const Resource res, int32_t *pLength);
94
 
 
95
 
U_CFUNC const uint8_t *
96
 
res_getBinary(const ResourceData *pResData, const Resource res, int32_t *pLength);
97
 
 
98
 
U_CFUNC const int32_t *
99
 
res_getIntVector(const ResourceData *pResData, const Resource res, int32_t *pLength);
100
 
 
101
 
U_CFUNC Resource
102
 
res_getResource(const ResourceData *pResData, const char *key);
103
 
 
104
 
U_CFUNC int32_t
105
 
res_countArrayItems(const ResourceData *pResData, const Resource res);
106
 
 
107
 
U_CFUNC int32_t res_getTableSize(const ResourceData *pResData, Resource table);
108
 
 
109
 
U_CFUNC Resource res_getArrayItem(const ResourceData *pResData, const Resource array, const int32_t indexS);
110
 
U_CFUNC Resource res_getTableItemByIndex(const ResourceData *pResData, const Resource table, int32_t indexS, const char ** key);
111
 
U_CFUNC Resource res_getTableItemByKey(const ResourceData *pResData, const Resource table, int32_t *indexS, const char* * key);
112
 
 
113
 
#endif