Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

uresdata.h

Go to the documentation of this file.
00001 /*
00002 *******************************************************************************
00003 *                                                                             *
00004 * Copyright (C) 1999, International Business Machines Corporation and others. *
00005 *                     All Rights Reserved.                                    *
00006 *                                                                             *
00007 *******************************************************************************
00008 *   file name:  uresdata.h
00009 *   encoding:   US-ASCII
00010 *   tab size:   8 (not used)
00011 *   indentation:4
00012 *
00013 *   created on: 1999dec08
00014 *   created by: Markus W. Scherer
00015 */
00016 
00017 #ifndef __RESDATA_H__
00018 #define __RESDATA_H__
00019 
00020 #include "unicode/utypes.h"
00021 #include "unicode/udata.h"
00022 
00023 /*
00024  * A Resource is a 32-bit value that has 2 bit fields:
00025  * 31..28   4-bit type, see enum below
00026  * 27..0    28-bit four-byte-offset or value according to the type
00027  */
00028 typedef uint32_t Resource;
00029 
00030 #define RES_BOGUS 0xffffffff
00031 
00032 #define RES_GET_TYPE(res) ((res)>>28UL)
00033 #define RES_GET_OFFSET(res) ((res)&0x0fffffff)
00034 #define RES_GET_POINTER(pRoot, res) ((pRoot)+RES_GET_OFFSET(res))
00035 
00036 /* get signed and unsigned integer values directly from the Resource handle */
00037 #define RES_GET_INT(res) (((int32_t)((res)<<4L))>>4L)
00038 #define RES_GET_UINT(res) ((res)&0x0fffffff)
00039 
00040 /*
00041  * Resource types:
00042  * Most resources have their values stored at four-byte offsets from the start
00043  * of the resource data. These values are at least 4-aligned.
00044  * Some resource values are stored directly in the offset field of the Resource itself.
00045  *
00046  * Type Name            Memory layout of values
00047  *                      (in parentheses: scalar, non-offset values)
00048  *
00049  * 0  Unicode String:   int32_t length, UChar[length], (UChar)0, (padding)
00050  *                  or  (empty string ("") if offset==0)
00051  * 1  Binary:           int32_t length, uint8_t[length], (padding)
00052  *                      - this value should be 32-aligned -
00053  * 2  Table:            uint16_t count, uint16_t keyStringOffsets[count], (uint16_t padding), Resource[count]
00054  *
00055  * 7  Integer:          (28-bit offset is integer value)
00056  * 8  Array:            int32_t count, Resource[count]
00057  *
00058  * 14 Integer Vector:   int32_t length, int32_t[length]
00059  * 15 Reserved:         This value denotes special purpose resources and is for internal use.
00060  
00061  */
00062 
00063 /*
00064  * Structure for a single, memory-mapped ResourceBundle.
00065  */
00066 typedef struct {
00067     UDataMemory *data;
00068     Resource *pRoot;
00069     Resource rootRes;
00070 } ResourceData;
00071 
00072 /*
00073  * Load a resource bundle file.
00074  * The ResourceData structure must be allocated externally.
00075  */
00076 U_CFUNC UBool
00077 res_load(ResourceData *pResData,
00078          const char *path, const char *name, UErrorCode *errorCode);
00079 
00080 /*
00081  * Release a resource bundle file.
00082  * This does not release the ResourceData structure itself.
00083  */
00084 U_CFUNC void
00085 res_unload(ResourceData *pResData);
00086 
00087 /*
00088  * Return a pointer to a zero-terminated, const UChar* string
00089  * and set its length in *pLength.
00090  * Returns NULL if not found.
00091  */
00092 U_CFUNC const UChar *
00093 res_getString(const ResourceData *pResData, const Resource res, int32_t *pLength);
00094 
00095 U_CFUNC const uint8_t *
00096 res_getBinary(const ResourceData *pResData, const Resource res, int32_t *pLength);
00097 
00098 U_CFUNC Resource
00099 res_getResource(const ResourceData *pResData, const char *key);
00100 
00101 U_CFUNC int32_t
00102 res_countArrayItems(const ResourceData *pResData, const Resource res);
00103 
00104 U_CFUNC void
00105 res_getNextStringTableItem(const ResourceData *pResData, Resource table, 
00106                            const UChar **value, const char **key, int32_t *len, 
00107                            int16_t *indexS);
00108 U_CFUNC int32_t res_getTableSize(const ResourceData *pResData, Resource table);
00109 
00110 U_CFUNC Resource res_getArrayItem(const ResourceData *pResData, const Resource array, const int32_t indexS);
00111 U_CFUNC Resource res_getTableItemByIndex(const ResourceData *pResData, const Resource table, int32_t indexS, const char ** key);
00112 U_CFUNC Resource res_getTableItemByKey(const ResourceData *pResData, const Resource table, int32_t *indexS, const char* * key);
00113 
00114 #endif

Generated at Tue Dec 5 17:55:37 2000 for ICU by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000