]>
git.saurik.com Git - apple/icu.git/blob - icuSources/common/propname.h
2 **********************************************************************
3 * Copyright (c) 2002-2011, International Business Machines
4 * Corporation and others. All Rights Reserved.
5 **********************************************************************
7 * Created: October 30 2002
9 * 2010nov19 Markus Scherer Rewrite for formatVersion 2.
10 **********************************************************************
15 #include "unicode/utypes.h"
16 #include "unicode/bytestrie.h"
17 #include "unicode/uchar.h"
22 * This header defines the in-memory layout of the property names data
23 * structure representing the UCD data files PropertyAliases.txt and
24 * PropertyValueAliases.txt. It is used by:
25 * propname.cpp - reads data
26 * genpname - creates data
29 /* low-level char * property name comparison -------------------------------- */
34 * \var uprv_comparePropertyNames
35 * Unicode property names and property value names are compared "loosely".
37 * UCD.html 4.0.1 says:
38 * For all property names, property value names, and for property values for
39 * Enumerated, Binary, or Catalog properties, use the following
40 * loose matching rule:
42 * LM3. Ignore case, whitespace, underscore ('_'), and hyphens.
44 * This function does just that, for (char *) name strings.
45 * It is almost identical to ucnv_compareNames() but also ignores
46 * C0 White_Space characters (U+0009..U+000d, and U+0085 on EBCDIC).
51 U_CAPI
int32_t U_EXPORT2
52 uprv_compareASCIIPropertyNames(const char *name1
, const char *name2
);
54 U_CAPI
int32_t U_EXPORT2
55 uprv_compareEBCDICPropertyNames(const char *name1
, const char *name2
);
57 #if U_CHARSET_FAMILY==U_ASCII_FAMILY
58 # define uprv_comparePropertyNames uprv_compareASCIIPropertyNames
59 #elif U_CHARSET_FAMILY==U_EBCDIC_FAMILY
60 # define uprv_comparePropertyNames uprv_compareEBCDICPropertyNames
62 # error U_CHARSET_FAMILY is not valid
67 /* UDataMemory structure and signatures ------------------------------------- */
69 #define PNAME_DATA_NAME "pnames"
70 #define PNAME_DATA_TYPE "icu"
72 /* Fields in UDataInfo: */
74 /* PNAME_SIG[] is encoded as numeric literals for compatibility with the HP compiler */
75 #define PNAME_SIG_0 ((uint8_t)0x70) /* p */
76 #define PNAME_SIG_1 ((uint8_t)0x6E) /* n */
77 #define PNAME_SIG_2 ((uint8_t)0x61) /* a */
78 #define PNAME_SIG_3 ((uint8_t)0x6D) /* m */
85 // Byte offsets from the start of the data, after the generic header.
88 IX_NAME_GROUPS_OFFSET
,
99 static const char *getPropertyName(int32_t property
, int32_t nameChoice
);
100 static const char *getPropertyValueName(int32_t property
, int32_t value
, int32_t nameChoice
);
102 static int32_t getPropertyEnum(const char *alias
);
103 static int32_t getPropertyValueEnum(int32_t property
, const char *alias
);
106 static int32_t findProperty(int32_t property
);
107 static int32_t findPropertyValueNameGroup(int32_t valueMapIndex
, int32_t value
);
108 static const char *getName(const char *nameGroup
, int32_t nameIndex
);
109 static UBool
containsName(BytesTrie
&trie
, const char *name
);
111 static int32_t getPropertyOrValueEnum(int32_t bytesTrieOffset
, const char *alias
);
113 static const int32_t indexes
[];
114 static const int32_t valueMaps
[];
115 static const uint8_t bytesTries
[];
116 static const char nameGroups
[];
120 * pnames.icu formatVersion 2
122 * formatVersion 2 is new in ICU 4.8.
123 * In ICU 4.8, the pnames.icu data file is used only in ICU4J.
124 * ICU4C 4.8 has the same data structures hardcoded in source/common/propname_data.h.
126 * For documentation of pnames.icu formatVersion 1 see ICU4C 4.6 (2010-dec-01)
127 * or earlier versions of this header file (source/common/propname.h).
129 * The pnames.icu begins with the standard ICU DataHeader/UDataInfo.
132 * int32_t indexes[8];
134 * (See the PropNameData::IX_... constants.)
136 * The first 6 indexes are byte offsets from the beginning of the data
137 * (beginning of indexes[]) to following structures.
138 * The length of each structure is the difference between its offset
140 * All offsets are filled in: Where there is no data between two offsets,
141 * those two offsets are the same.
142 * The last offset (indexes[PropNameData::IX_TOTAL_SIZE]) indicates the
143 * total number of bytes in the file. (Not counting the standard headers.)
145 * The sixth index (indexes[PropNameData::IX_MAX_NAME_LENGTH]) has the
146 * maximum length of any Unicode property (or property value) alias.
147 * (Without normalization, that is, including underscores etc.)
149 * int32_t valueMaps[];
151 * The valueMaps[] begins with a map from UProperty enums to properties,
152 * followed by the per-property value maps from property values to names,
153 * for those properties that have named values.
154 * (Binary & enumerated, plus General_Category_Mask.)
156 * valueMaps[0] contains the number of UProperty enum ranges.
158 * int32_t start, limit -- first and last+1 UProperty enum of a dense range
159 * Followed by (limit-start) pairs of
160 * int32_t nameGroupOffset;
161 * Offset into nameGroups[] for the property's names/aliases.
162 * int32_t valueMapIndex;
163 * Offset of the property's value map in the valueMaps[] array.
164 * If the valueMapIndex is 0, then the property does not have named values.
166 * For each property's value map:
167 * int32_t bytesTrieOffset; -- Offset into bytesTries[] for name->value mapping.
169 * If numRanges is in the range 1..15, then that many ranges of values follow.
171 * int32_t start, limit -- first and last+1 UProperty enum of a range
172 * Followed by (limit-start) entries of
173 * int32_t nameGroupOffset;
174 * Offset into nameGroups[] for the property value's names/aliases.
175 * If the nameGroupOffset is 0, then this is not a named value for this property.
176 * (That is, the ranges need not be dense.)
177 * If numRanges is >=0x10, then (numRanges-0x10) sorted values
178 * and then (numRanges-0x10) corresponding nameGroupOffsets follow.
179 * Values are sorted as signed integers.
180 * In this case, the set of values is dense; no nameGroupOffset will be 0.
182 * For both properties and property values, ranges are sorted by their start/limit values.
184 * uint8_t bytesTries[];
186 * This is a sequence of BytesTrie structures, byte-serialized tries for
187 * mapping from names/aliases to values.
188 * The first one maps from property names/aliases to UProperty enum constants.
189 * The following ones are indexed by property value map bytesTrieOffsets
190 * for mapping each property's names/aliases to their property values.
194 * This is a sequence of property name groups.
195 * Each group is a list of names/aliases (invariant-character strings) for
196 * one property or property value, in the order of UCharNameChoice.
197 * The first byte of each group is the number of names in the group.
198 * It is followed by that many NUL-terminated strings.
199 * The first string is for the short name; if there is no short name,
200 * then the first string is empty.
201 * The second string is the long name. Further strings are additional aliases.
203 * The first name group is for a property rather than a property value,
204 * so that a nameGroupOffset of 0 can be used to indicate "no value"
205 * in a property's sparse value ranges.