]> git.saurik.com Git - apple/icu.git/blobdiff - icuSources/common/uprops.h
ICU-491.11.1.tar.gz
[apple/icu.git] / icuSources / common / uprops.h
index 9b573c3f13bcbfe78af0a1573a55a23fa8c91fee..c1667c96b9d0aaf9961f95c50927656b3a0cdcdf 100644 (file)
@@ -1,7 +1,7 @@
 /*
 *******************************************************************************
 *
-*   Copyright (C) 2002-2004, International Business Machines
+*   Copyright (C) 2002-2011, International Business Machines
 *   Corporation and others.  All Rights Reserved.
 *
 *******************************************************************************
@@ -14,7 +14,7 @@
 *   created by: Markus W. Scherer
 *
 *   Constants for mostly non-core Unicode character properties
-*   stored in uprops.dat.
+*   stored in uprops.icu.
 */
 
 #ifndef __UPROPS_H__
@@ -23,7 +23,6 @@
 #include "unicode/utypes.h"
 #include "unicode/uset.h"
 #include "uset_imp.h"
-#include "ucase.h"
 #include "udataswp.h"
 
 /* indexes[] entries */
@@ -36,7 +35,13 @@ enum {
     UPROPS_ADDITIONAL_VECTORS_INDEX,
     UPROPS_ADDITIONAL_VECTORS_COLUMNS_INDEX,
 
-    UPROPS_RESERVED_INDEX, /* 6 */
+    UPROPS_SCRIPT_EXTENSIONS_INDEX,
+
+    UPROPS_RESERVED_INDEX_7,
+    UPROPS_RESERVED_INDEX_8,
+
+    /* size of the data file (number of 32-bit units after the header) */
+    UPROPS_DATA_TOP_INDEX,
 
     /* maximum values for code values in vector word 0 */
     UPROPS_MAX_VALUES_INDEX=10,
@@ -49,44 +54,34 @@ enum {
 /* definitions for the main properties words */
 enum {
     /* general category shift==0                                0 (5 bits) */
-    UPROPS_EXCEPTION_SHIFT=5,                               /*  5 (1 bit)  */
-    UPROPS_BIDI_SHIFT,                                      /*  6 (5 bits) */
-    UPROPS_MIRROR_SHIFT=UPROPS_BIDI_SHIFT+5,                /* 11 (1 bit)  */
-    UPROPS_NUMERIC_TYPE_SHIFT,                              /* 12 (3 bits) */
-    UPROPS_CASE_SENSITIVE_SHIFT=UPROPS_NUMERIC_TYPE_SHIFT+3,/* 15 (1 bit) format version 3.2 */
-    UPROPS_RESERVED_SHIFT,                                  /* 16 (4 bits) */
-    UPROPS_VALUE_SHIFT=20,                                  /* 20 */
-
-    UPROPS_EXCEPTION_BIT=1UL<<UPROPS_EXCEPTION_SHIFT,
-    UPROPS_VALUE_BITS=32-UPROPS_VALUE_SHIFT,
-
-    UPROPS_MIN_VALUE=-(1L<<(UPROPS_VALUE_BITS-1)),
-    UPROPS_MAX_VALUE=(1L<<(UPROPS_VALUE_BITS-1))-1,
-    UPROPS_MAX_EXCEPTIONS_COUNT=1L<<UPROPS_VALUE_BITS
+    /* reserved                                                 5 (1 bit) */
+    UPROPS_NUMERIC_TYPE_VALUE_SHIFT=6                       /*  6 (10 bits) */
 };
 
-#define PROPS_VALUE_IS_EXCEPTION(props) ((props)&UPROPS_EXCEPTION_BIT)
 #define GET_CATEGORY(props) ((props)&0x1f)
-#define GET_BIDI_CLASS(props) ((props>>UPROPS_BIDI_SHIFT)&0x1f)
-#define GET_NUMERIC_TYPE(props) (((props)>>UPROPS_NUMERIC_TYPE_SHIFT)&7)
-#define GET_UNSIGNED_VALUE(props) ((props)>>UPROPS_VALUE_SHIFT)
-#define GET_SIGNED_VALUE(props) ((int32_t)(props)>>UPROPS_VALUE_SHIFT)
-#define GET_EXCEPTIONS(props) (exceptionsTable+GET_UNSIGNED_VALUE(props))
-
 #define CAT_MASK(props) U_MASK(GET_CATEGORY(props))
 
+#define GET_NUMERIC_TYPE_VALUE(props) ((props)>>UPROPS_NUMERIC_TYPE_VALUE_SHIFT)
+
+/* constants for the storage form of numeric types and values */
 enum {
-    EXC_UPPERCASE,
-    EXC_LOWERCASE,
-    EXC_TITLECASE,
-    EXC_UNUSED,
-    EXC_NUMERIC_VALUE,
-    EXC_DENOMINATOR_VALUE,
-    EXC_MIRROR_MAPPING,
-    EXC_SPECIAL_CASING,
-    EXC_CASE_FOLDING
+    UPROPS_NTV_NONE=0,
+    UPROPS_NTV_DECIMAL_START=1,
+    UPROPS_NTV_DIGIT_START=11,
+    UPROPS_NTV_NUMERIC_START=21,
+    UPROPS_NTV_FRACTION_START=0xb0,
+    UPROPS_NTV_LARGE_START=0x1e0,
+    UPROPS_NTV_RESERVED_START=0x300,
+
+    UPROPS_NTV_MAX_SMALL_INT=UPROPS_NTV_FRACTION_START-UPROPS_NTV_NUMERIC_START-1
 };
 
+#define UPROPS_NTV_GET_TYPE(ntv) \
+    ((ntv==UPROPS_NTV_NONE) ? U_NT_NONE : \
+    (ntv<UPROPS_NTV_DIGIT_START) ?  U_NT_DECIMAL : \
+    (ntv<UPROPS_NTV_NUMERIC_START) ? U_NT_DIGIT : \
+    U_NT_NUMERIC)
+
 /* number of properties vector words */
 #define UPROPS_VECTOR_WORDS     3
 
@@ -94,27 +89,37 @@ enum {
  * Properties in vector word 0
  * Bits
  * 31..24   DerivedAge version major/minor one nibble each
- * 23       reserved
- * 22..18   Line Break
- * 17..15   East Asian Width
- * 14.. 7   UBlockCode
- *  6.. 0   UScriptCode
+ * 23..22   3..1: Bits 7..0 = Script_Extensions index
+ *             3: Script value from Script_Extensions
+ *             2: Script=Inherited
+ *             1: Script=Common
+ *             0: Script=bits 7..0
+ * 21..20   reserved
+ * 19..17   East Asian Width
+ * 16.. 8   UBlockCode
+ *  7.. 0   UScriptCode, or index to Script_Extensions
  */
 
 /* derived age: one nibble each for major and minor version numbers */
 #define UPROPS_AGE_MASK         0xff000000
 #define UPROPS_AGE_SHIFT        24
 
-#define UPROPS_LB_MASK          0x007C0000
-#define UPROPS_LB_SHIFT         18
+/* Script_Extensions: mask includes Script */
+#define UPROPS_SCRIPT_X_MASK    0x00c000ff
+#define UPROPS_SCRIPT_X_SHIFT   22
+
+#define UPROPS_EA_MASK          0x000e0000
+#define UPROPS_EA_SHIFT         17
 
-#define UPROPS_EA_MASK          0x00038000
-#define UPROPS_EA_SHIFT         15
+#define UPROPS_BLOCK_MASK       0x0001ff00
+#define UPROPS_BLOCK_SHIFT      8
 
-#define UPROPS_BLOCK_MASK       0x00007f80
-#define UPROPS_BLOCK_SHIFT      7
+#define UPROPS_SCRIPT_MASK      0x000000ff
 
-#define UPROPS_SCRIPT_MASK      0x0000007f
+/* UPROPS_SCRIPT_X_WITH_COMMON must be the lowest value that involves Script_Extensions. */
+#define UPROPS_SCRIPT_X_WITH_COMMON     0x400000
+#define UPROPS_SCRIPT_X_WITH_INHERITED  0x800000
+#define UPROPS_SCRIPT_X_WITH_OTHER      0xc00000
 
 /*
  * Properties in vector word 1
@@ -129,8 +134,6 @@ enum {
  */
 enum {
     UPROPS_WHITE_SPACE,
-    UPROPS_BIDI_CONTROL,
-    UPROPS_JOIN_CONTROL,
     UPROPS_DASH,
     UPROPS_HYPHEN,
     UPROPS_QUOTATION_MARK,
@@ -142,8 +145,6 @@ enum {
     UPROPS_IDEOGRAPHIC,
     UPROPS_DIACRITIC,
     UPROPS_EXTENDER,
-    UPROPS_LOWERCASE,
-    UPROPS_UPPERCASE,
     UPROPS_NONCHARACTER_CODE_POINT,
     UPROPS_GRAPHEME_EXTEND,
     UPROPS_GRAPHEME_LINK,
@@ -153,42 +154,54 @@ enum {
     UPROPS_UNIFIED_IDEOGRAPH,
     UPROPS_DEFAULT_IGNORABLE_CODE_POINT,
     UPROPS_DEPRECATED,
-    UPROPS_SOFT_DOTTED,
     UPROPS_LOGICAL_ORDER_EXCEPTION,
     UPROPS_XID_START,
     UPROPS_XID_CONTINUE,
     UPROPS_ID_START,                            /* ICU 2.6, uprops format version 3.2 */
     UPROPS_ID_CONTINUE,
     UPROPS_GRAPHEME_BASE,
+    UPROPS_S_TERM,                              /* new in ICU 3.0 and Unicode 4.0.1 */
+    UPROPS_VARIATION_SELECTOR,
+    UPROPS_PATTERN_SYNTAX,                      /* new in ICU 3.4 and Unicode 4.1 */
+    UPROPS_PATTERN_WHITE_SPACE,
+    UPROPS_RESERVED,                            /* reserved & unused */
     UPROPS_BINARY_1_TOP                         /* ==32 - full! */
 };
 
 /*
  * Properties in vector word 2
  * Bits
- * 31..24   More binary properties
- * 13..11   Joining Type
- * 10.. 5   Joining Group
+ * 31..26   reserved
+ * 25..20   Line Break
+ * 19..15   Sentence Break
+ * 14..10   Word Break
+ *  9.. 5   Grapheme Cluster Break
  *  4.. 0   Decomposition Type
  */
-#define UPROPS_JT_MASK          0x00003800
-#define UPROPS_JT_SHIFT         11
+#define UPROPS_LB_MASK          0x03f00000
+#define UPROPS_LB_SHIFT         20
+
+#define UPROPS_SB_MASK          0x000f8000
+#define UPROPS_SB_SHIFT         15
 
-#define UPROPS_JG_MASK          0x000007e0
-#define UPROPS_JG_SHIFT         5
+#define UPROPS_WB_MASK          0x00007c00
+#define UPROPS_WB_SHIFT         10
+
+#define UPROPS_GCB_MASK         0x000003e0
+#define UPROPS_GCB_SHIFT        5
 
 #define UPROPS_DT_MASK          0x0000001f
 
-enum {
-    UPROPS_V2_S_TERM=24,                        /* new in ICU 3.0 and Unicode 4.0.1 */
-    UPROPS_V2_VARIATION_SELECTOR,
-    UPROPS_V2_TOP                               /* must be <=32 */
-};
+/**
+ * Gets the main properties value for a code point.
+ * Implemented in uchar.c for uprops.cpp.
+ */
+U_CFUNC uint32_t
+u_getMainProperties(UChar32 c);
 
 /**
  * Get a properties vector word for a code point.
- * Implemented in uchar.c for uprops.c.
- * column==-1 gets the 32-bit main properties word instead.
+ * Implemented in uchar.c for uprops.cpp.
  * @return 0 if no data or illegal argument
  */
 U_CFUNC uint32_t
@@ -211,11 +224,29 @@ U_CFUNC int32_t
 uprv_getMaxValues(int32_t column);
 
 /**
- * Get the Hangul Syllable Type for c.
+ * Checks if c is alphabetic, or a decimal digit; implements UCHAR_POSIX_ALNUM.
  * @internal
  */
-U_CFUNC UHangulSyllableType
-uchar_getHST(UChar32 c);
+U_CFUNC UBool
+u_isalnumPOSIX(UChar32 c);
+
+/**
+ * Checks if c is in
+ * [^\p{space}\p{gc=Control}\p{gc=Surrogate}\p{gc=Unassigned}]
+ * with space=\p{Whitespace} and Control=Cc.
+ * Implements UCHAR_POSIX_GRAPH.
+ * @internal
+ */
+U_CFUNC UBool
+u_isgraphPOSIX(UChar32 c);
+
+/**
+ * Checks if c is in \p{graph}\p{blank} - \p{cntrl}.
+ * Implements UCHAR_POSIX_PRINT.
+ * @internal
+ */
+U_CFUNC UBool
+u_isprintPOSIX(UChar32 c);
 
 /** Turn a bit index into a bit flag. @internal */
 #define FLAG(n) ((uint32_t)1<<(n))
@@ -226,7 +257,7 @@ uchar_getHST(UChar32 c);
 #define _Ll     FLAG(U_LOWERCASE_LETTER)
 #define _Lt     FLAG(U_TITLECASE_LETTER)
 #define _Lm     FLAG(U_MODIFIER_LETTER)
-#define _Lo     FLAG(U_OTHER_LETTER)
+/* #define _Lo     FLAG(U_OTHER_LETTER) -- conflicts with MS Visual Studio 9.0 xiosbase */
 #define _Mn     FLAG(U_NON_SPACING_MARK)
 #define _Me     FLAG(U_ENCLOSING_MARK)
 #define _Mc     FLAG(U_COMBINING_SPACING_MARK)
@@ -242,15 +273,15 @@ uchar_getHST(UChar32 c);
 #define _Cs     FLAG(U_SURROGATE)
 #define _Pd     FLAG(U_DASH_PUNCTUATION)
 #define _Ps     FLAG(U_START_PUNCTUATION)
-#define _Pe     FLAG(U_END_PUNCTUATION)
-#define _Pc     FLAG(U_CONNECTOR_PUNCTUATION)
+/* #define _Pe     FLAG(U_END_PUNCTUATION) -- conflicts with MS Visual Studio 9.0 xlocnum */
+/* #define _Pc     FLAG(U_CONNECTOR_PUNCTUATION) -- conflicts with MS Visual Studio 9.0 streambuf */
 #define _Po     FLAG(U_OTHER_PUNCTUATION)
 #define _Sm     FLAG(U_MATH_SYMBOL)
 #define _Sc     FLAG(U_CURRENCY_SYMBOL)
 #define _Sk     FLAG(U_MODIFIER_SYMBOL)
 #define _So     FLAG(U_OTHER_SYMBOL)
 #define _Pi     FLAG(U_INITIAL_PUNCTUATION)
-#define _Pf     FLAG(U_FINAL_PUNCTUATION)
+/* #define _Pf     FLAG(U_FINAL_PUNCTUATION) -- conflicts with MS Visual Studio 9.0 streambuf */
 
 /** Some code points. @internal */
 enum {
@@ -259,8 +290,10 @@ enum {
     FF      =0x000c,
     CR      =0x000d,
     U_A     =0x0041,
+    U_F     =0x0046,
     U_Z     =0x005a,
     U_a     =0x0061,
+    U_f     =0x0066,
     U_z     =0x007a,
     DEL     =0x007f,
     NL      =0x0085,
@@ -275,6 +308,12 @@ enum {
     WJ      =0x2060,
     INHSWAP =0x206a,
     NOMDIG  =0x206f,
+    U_FW_A  =0xff21,
+    U_FW_F  =0xff26,
+    U_FW_Z  =0xff3a,
+    U_FW_a  =0xff41,
+    U_FW_f  =0xff46,
+    U_FW_z  =0xff5a,
     ZWNBSP  =0xfeff
 };
 
@@ -285,19 +324,6 @@ enum {
 U_CAPI int32_t U_EXPORT2
 uprv_getMaxCharNameLength(void);
 
-#if 0
-/* 
-Currently not used but left for future use. Probably by UnicodeSet. 
-urename.h and unames.c changed accordingly. 
-*/
-/**
- * Get the maximum length of an ISO comment.
- * @return 0 if no ISO comments available.
- */
-U_CAPI int32_t U_EXPORT2
-uprv_getMaxISOCommentLength();
-#endif
-
 /**
  * Fills set with characters that are used in Unicode character names.
  * Includes all characters that are used in regular/Unicode 1.0/extended names.
@@ -305,22 +331,7 @@ uprv_getMaxISOCommentLength();
  * @param sa USetAdder to receive characters.
  */
 U_CAPI void U_EXPORT2
-uprv_getCharNameCharacters(USetAdder *sa);
-
-#if 0
-/* 
-Currently not used but left for future use. Probably by UnicodeSet. 
-urename.h and unames.c changed accordingly. 
-*/
-/**
- * Fills set with characters that are used in Unicode character names.
- * Just empties the set if no ISO comments are available.
- * @param sa USetAdder to receive characters.
- */
-U_CAPI void U_EXPORT2
-uprv_getISOCommentCharacters(USetAdder *sa);
-*/
-#endif
+uprv_getCharNameCharacters(const USetAdder *sa);
 
 /**
  * Constants for which data and implementation files provide which properties.
@@ -330,19 +341,29 @@ uprv_getISOCommentCharacters(USetAdder *sa);
 enum UPropertySource {
     /** No source, not a supported property. */
     UPROPS_SRC_NONE,
-    /** From uchar.c/uprops.icu */
+    /** From uchar.c/uprops.icu main trie */
     UPROPS_SRC_CHAR,
-    /** Hangul_Syllable_Type, from uchar.c/uprops.icu */
-    UPROPS_SRC_HST,
+    /** From uchar.c/uprops.icu properties vectors trie */
+    UPROPS_SRC_PROPSVEC,
     /** From unames.c/unames.icu */
     UPROPS_SRC_NAMES,
-    /** From unorm.cpp/unorm.icu */
-    UPROPS_SRC_NORM,
     /** From ucase.c/ucase.icu */
     UPROPS_SRC_CASE,
-    /** From ubidi.c/ubidi.icu */
+    /** From ubidi_props.c/ubidi.icu */
     UPROPS_SRC_BIDI,
-    /** One more than the highes UPropertySource (UPROPS_SRC_) constant. */
+    /** From uchar.c/uprops.icu main trie as well as properties vectors trie */
+    UPROPS_SRC_CHAR_AND_PROPSVEC,
+    /** From ucase.c/ucase.icu as well as unorm.cpp/unorm.icu */
+    UPROPS_SRC_CASE_AND_NORM,
+    /** From normalizer2impl.cpp/nfc.nrm */
+    UPROPS_SRC_NFC,
+    /** From normalizer2impl.cpp/nfkc.nrm */
+    UPROPS_SRC_NFKC,
+    /** From normalizer2impl.cpp/nfkc_cf.nrm */
+    UPROPS_SRC_NFKC_CF,
+    /** From normalizer2impl.cpp/nfc.nrm canonical iterator data */
+    UPROPS_SRC_NFC_CANON_ITER,
+    /** One more than the highest UPropertySource (UPROPS_SRC_) constant. */
     UPROPS_SRC_COUNT
 };
 typedef enum UPropertySource UPropertySource;
@@ -351,23 +372,24 @@ typedef enum UPropertySource UPropertySource;
  * @see UPropertySource
  * @internal
  */
-U_CAPI UPropertySource U_EXPORT2
+U_CFUNC UPropertySource U_EXPORT2
 uprops_getSource(UProperty which);
 
 /**
- * Enumerate each core properties data trie and add the
+ * Enumerate uprops.icu's main data trie and add the
  * start of each range of same properties to the set.
  * @internal
  */
-U_CAPI void U_EXPORT2
-uchar_addPropertyStarts(USetAdder *sa, UErrorCode *pErrorCode);
+U_CFUNC void U_EXPORT2
+uchar_addPropertyStarts(const USetAdder *sa, UErrorCode *pErrorCode);
 
 /**
- * Same as uchar_addPropertyStarts() but only for Hangul_Syllable_Type.
+ * Enumerate uprops.icu's properties vectors trie and add the
+ * start of each range of same properties to the set.
  * @internal
  */
-U_CAPI void U_EXPORT2
-uhst_addPropertyStarts(USetAdder *sa, UErrorCode *pErrorCode);
+U_CFUNC void U_EXPORT2
+upropsvec_addPropertyStarts(const USetAdder *sa, UErrorCode *pErrorCode);
 
 /**
  * Return a set of characters for property enumeration.
@@ -377,17 +399,9 @@ uhst_addPropertyStarts(USetAdder *sa, UErrorCode *pErrorCode);
  * @param sa USetAdder to receive result. Existing contents are lost.
  * @internal
  */
-U_CAPI void U_EXPORT2
-uprv_getInclusions(USetAdder *sa, UErrorCode *pErrorCode);
-
-/**
- * Swap the ICU Unicode properties file. See uchar.c.
- * @internal
- */
-U_CAPI int32_t U_EXPORT2
-uprops_swap(const UDataSwapper *ds,
-            const void *inData, int32_t length, void *outData,
-            UErrorCode *pErrorCode);
+/*U_CFUNC void U_EXPORT2
+uprv_getInclusions(const USetAdder *sa, UErrorCode *pErrorCode);
+*/
 
 /**
  * Swap the ICU Unicode character names file. See uchar.c.
@@ -398,4 +412,18 @@ uchar_swapNames(const UDataSwapper *ds,
                 const void *inData, int32_t length, void *outData,
                 UErrorCode *pErrorCode);
 
+#ifdef __cplusplus
+
+U_NAMESPACE_BEGIN
+
+class UnicodeSet;
+
+// implemented in uniset_props.cpp
+U_CFUNC UnicodeSet *
+uniset_getUnicode32Instance(UErrorCode &errorCode);
+
+U_NAMESPACE_END
+
+#endif
+
 #endif