Wed, 31 Dec 2014 07:22:50 +0100
Correct previous dual key logic pending first delivery installment.
michael@0 | 1 | /* |
michael@0 | 2 | ***************************************************************************************** |
michael@0 | 3 | * Copyright (C) 2013, International Business Machines |
michael@0 | 4 | * Corporation and others. All Rights Reserved. |
michael@0 | 5 | ***************************************************************************************** |
michael@0 | 6 | */ |
michael@0 | 7 | |
michael@0 | 8 | #ifndef UREGION_H |
michael@0 | 9 | #define UREGION_H |
michael@0 | 10 | |
michael@0 | 11 | #include "unicode/utypes.h" |
michael@0 | 12 | #include "unicode/uenum.h" |
michael@0 | 13 | |
michael@0 | 14 | /** |
michael@0 | 15 | * \file |
michael@0 | 16 | * \brief C API: URegion (territory containment and mapping) |
michael@0 | 17 | * |
michael@0 | 18 | * URegion objects represent data associated with a particular Unicode Region Code, also known as a |
michael@0 | 19 | * Unicode Region Subtag, which is defined based upon the BCP 47 standard. These include: |
michael@0 | 20 | * * Two-letter codes defined by ISO 3166-1, with special LDML treatment of certain private-use or |
michael@0 | 21 | * reserved codes; |
michael@0 | 22 | * * A subset of 3-digit numeric codes defined by UN M.49. |
michael@0 | 23 | * URegion objects can also provide mappings to and from additional codes. There are different types |
michael@0 | 24 | * of regions that are important to distinguish: |
michael@0 | 25 | * <p> |
michael@0 | 26 | * Macroregion - A code for a "macro geographical (continental) region, geographical sub-region, or |
michael@0 | 27 | * selected economic and other grouping" as defined in UN M.49. These are typically 3-digit codes, |
michael@0 | 28 | * but contain some 2-letter codes for LDML extensions, such as "QO" for Outlying Oceania. |
michael@0 | 29 | * Macroregions are represented in ICU by one of three region types: WORLD (code 001), |
michael@0 | 30 | * CONTINENTS (regions contained directly by WORLD), and SUBCONTINENTS (regions contained directly |
michael@0 | 31 | * by a continent ). |
michael@0 | 32 | * <p> |
michael@0 | 33 | * TERRITORY - A Region that is not a Macroregion. These are typically codes for countries, but also |
michael@0 | 34 | * include areas that are not separate countries, such as the code "AQ" for Antarctica or the code |
michael@0 | 35 | * "HK" for Hong Kong (SAR China). Overseas dependencies of countries may or may not have separate |
michael@0 | 36 | * codes. The codes are typically 2-letter codes aligned with ISO 3166, but BCP47 allows for the use |
michael@0 | 37 | * of 3-digit codes in the future. |
michael@0 | 38 | * <p> |
michael@0 | 39 | * UNKNOWN - The code ZZ is defined by Unicode LDML for use in indicating that region is unknown, |
michael@0 | 40 | * or that the value supplied as a region was invalid. |
michael@0 | 41 | * <p> |
michael@0 | 42 | * DEPRECATED - Region codes that have been defined in the past but are no longer in modern usage, |
michael@0 | 43 | * usually due to a country splitting into multiple territories or changing its name. |
michael@0 | 44 | * <p> |
michael@0 | 45 | * GROUPING - A widely understood grouping of territories that has a well defined membership such |
michael@0 | 46 | * that a region code has been assigned for it. Some of these are UN M.49 codes that don't fall into |
michael@0 | 47 | * the world/continent/sub-continent hierarchy, while others are just well-known groupings that have |
michael@0 | 48 | * their own region code. Region "EU" (European Union) is one such region code that is a grouping. |
michael@0 | 49 | * Groupings will never be returned by the uregion_getContainingRegion, since a different type of region |
michael@0 | 50 | * (WORLD, CONTINENT, or SUBCONTINENT) will always be the containing region instead. |
michael@0 | 51 | * |
michael@0 | 52 | * URegion objects are const/immutable, owned and maintained by ICU itself, so there are not functions |
michael@0 | 53 | * to open or close them. |
michael@0 | 54 | */ |
michael@0 | 55 | |
michael@0 | 56 | #ifndef U_HIDE_DRAFT_API |
michael@0 | 57 | /** |
michael@0 | 58 | * URegionType is an enumeration defining the different types of regions. Current possible |
michael@0 | 59 | * values are URGN_WORLD, URGN_CONTINENT, URGN_SUBCONTINENT, URGN_TERRITORY, URGN_GROUPING, |
michael@0 | 60 | * URGN_DEPRECATED, and URGN_UNKNOWN. |
michael@0 | 61 | * |
michael@0 | 62 | * @draft ICU 51 |
michael@0 | 63 | */ |
michael@0 | 64 | typedef enum URegionType { |
michael@0 | 65 | /** |
michael@0 | 66 | * Type representing the unknown region. |
michael@0 | 67 | * @draft ICU 51 |
michael@0 | 68 | */ |
michael@0 | 69 | URGN_UNKNOWN, |
michael@0 | 70 | |
michael@0 | 71 | /** |
michael@0 | 72 | * Type representing a territory. |
michael@0 | 73 | * @draft ICU 51 |
michael@0 | 74 | */ |
michael@0 | 75 | URGN_TERRITORY, |
michael@0 | 76 | |
michael@0 | 77 | /** |
michael@0 | 78 | * Type representing the whole world. |
michael@0 | 79 | * @draft ICU 51 |
michael@0 | 80 | */ |
michael@0 | 81 | URGN_WORLD, |
michael@0 | 82 | |
michael@0 | 83 | /** |
michael@0 | 84 | * Type representing a continent. |
michael@0 | 85 | * @draft ICU 51 |
michael@0 | 86 | */ |
michael@0 | 87 | URGN_CONTINENT, |
michael@0 | 88 | |
michael@0 | 89 | /** |
michael@0 | 90 | * Type representing a sub-continent. |
michael@0 | 91 | * @draft ICU 51 |
michael@0 | 92 | */ |
michael@0 | 93 | URGN_SUBCONTINENT, |
michael@0 | 94 | |
michael@0 | 95 | /** |
michael@0 | 96 | * Type representing a grouping of territories that is not to be used in |
michael@0 | 97 | * the normal WORLD/CONTINENT/SUBCONTINENT/TERRITORY containment tree. |
michael@0 | 98 | * @draft ICU 51 |
michael@0 | 99 | */ |
michael@0 | 100 | URGN_GROUPING, |
michael@0 | 101 | |
michael@0 | 102 | /** |
michael@0 | 103 | * Type representing a region whose code has been deprecated, usually |
michael@0 | 104 | * due to a country splitting into multiple territories or changing its name. |
michael@0 | 105 | * @draft ICU 51 |
michael@0 | 106 | */ |
michael@0 | 107 | URGN_DEPRECATED, |
michael@0 | 108 | |
michael@0 | 109 | /** |
michael@0 | 110 | * Maximum value for this unumeration. |
michael@0 | 111 | * @draft ICU 51 |
michael@0 | 112 | */ |
michael@0 | 113 | URGN_LIMIT |
michael@0 | 114 | } URegionType; |
michael@0 | 115 | #endif /* U_HIDE_DRAFT_API */ |
michael@0 | 116 | |
michael@0 | 117 | #if !UCONFIG_NO_FORMATTING |
michael@0 | 118 | |
michael@0 | 119 | #ifndef U_HIDE_DRAFT_API |
michael@0 | 120 | |
michael@0 | 121 | /** |
michael@0 | 122 | * Opaque URegion object for use in C programs. |
michael@0 | 123 | * @draft ICU 52 |
michael@0 | 124 | */ |
michael@0 | 125 | struct URegion; |
michael@0 | 126 | typedef struct URegion URegion; /**< @draft ICU 52 */ |
michael@0 | 127 | |
michael@0 | 128 | /** |
michael@0 | 129 | * Returns a pointer to a URegion for the specified region code: A 2-letter or 3-letter ISO 3166 |
michael@0 | 130 | * code, UN M.49 numeric code (superset of ISO 3166 numeric codes), or other valid Unicode Region |
michael@0 | 131 | * Code as defined by the LDML specification. The code will be canonicalized internally. If the |
michael@0 | 132 | * region code is NULL or not recognized, the appropriate error code will be set |
michael@0 | 133 | * (U_ILLEGAL_ARGUMENT_ERROR). |
michael@0 | 134 | * @draft ICU 52 |
michael@0 | 135 | */ |
michael@0 | 136 | U_DRAFT const URegion* U_EXPORT2 |
michael@0 | 137 | uregion_getRegionFromCode(const char *regionCode, UErrorCode *status); |
michael@0 | 138 | |
michael@0 | 139 | /** |
michael@0 | 140 | * Returns a pointer to a URegion for the specified numeric region code. If the numeric region |
michael@0 | 141 | * code is not recognized, the appropriate error code will be set (U_ILLEGAL_ARGUMENT_ERROR). |
michael@0 | 142 | * @draft ICU 52 |
michael@0 | 143 | */ |
michael@0 | 144 | U_DRAFT const URegion* U_EXPORT2 |
michael@0 | 145 | uregion_getRegionFromNumericCode (int32_t code, UErrorCode *status); |
michael@0 | 146 | |
michael@0 | 147 | /** |
michael@0 | 148 | * Returns an enumeration over the canonical codes of all known regions that match the given type. |
michael@0 | 149 | * The enumeration must be closed with with uenum_close(). |
michael@0 | 150 | * @draft ICU 52 |
michael@0 | 151 | */ |
michael@0 | 152 | U_DRAFT UEnumeration* U_EXPORT2 |
michael@0 | 153 | uregion_getAvailable(URegionType type, UErrorCode *status); |
michael@0 | 154 | |
michael@0 | 155 | /** |
michael@0 | 156 | * Returns true if the specified uregion is equal to the specified otherRegion. |
michael@0 | 157 | * @draft ICU 52 |
michael@0 | 158 | */ |
michael@0 | 159 | U_DRAFT UBool U_EXPORT2 |
michael@0 | 160 | uregion_areEqual(const URegion* uregion, const URegion* otherRegion); |
michael@0 | 161 | |
michael@0 | 162 | /** |
michael@0 | 163 | * Returns a pointer to the URegion that contains the specified uregion. Returns NULL if the |
michael@0 | 164 | * specified uregion is code "001" (World) or "ZZ" (Unknown region). For example, calling |
michael@0 | 165 | * this method with region "IT" (Italy) returns the URegion for "039" (Southern Europe). |
michael@0 | 166 | * @draft ICU 52 |
michael@0 | 167 | */ |
michael@0 | 168 | U_DRAFT const URegion* U_EXPORT2 |
michael@0 | 169 | uregion_getContainingRegion(const URegion* uregion); |
michael@0 | 170 | |
michael@0 | 171 | /** |
michael@0 | 172 | * Return a pointer to the URegion that geographically contains this uregion and matches the |
michael@0 | 173 | * specified type, moving multiple steps up the containment chain if necessary. Returns NULL if no |
michael@0 | 174 | * containing region can be found that matches the specified type. Will return NULL if URegionType |
michael@0 | 175 | * is URGN_GROUPING, URGN_DEPRECATED, or URGN_UNKNOWN which are not appropriate for this API. |
michael@0 | 176 | * For example, calling this method with uregion "IT" (Italy) for type URGN_CONTINENT returns the |
michael@0 | 177 | * URegion "150" (Europe). |
michael@0 | 178 | * @draft ICU 52 |
michael@0 | 179 | */ |
michael@0 | 180 | U_DRAFT const URegion* U_EXPORT2 |
michael@0 | 181 | uregion_getContainingRegionOfType(const URegion* uregion, URegionType type); |
michael@0 | 182 | |
michael@0 | 183 | /** |
michael@0 | 184 | * Return an enumeration over the canonical codes of all the regions that are immediate children |
michael@0 | 185 | * of the specified uregion in the region hierarchy. These returned regions could be either macro |
michael@0 | 186 | * regions, territories, or a mixture of the two, depending on the containment data as defined in |
michael@0 | 187 | * CLDR. This API returns NULL if this uregion doesn't have any sub-regions. For example, calling |
michael@0 | 188 | * this function for uregion "150" (Europe) returns an enumeration containing the various |
michael@0 | 189 | * sub-regions of Europe: "039" (Southern Europe), "151" (Eastern Europe), "154" (Northern Europe), |
michael@0 | 190 | * and "155" (Western Europe). The enumeration must be closed with with uenum_close(). |
michael@0 | 191 | * @draft ICU 52 |
michael@0 | 192 | */ |
michael@0 | 193 | U_DRAFT UEnumeration* U_EXPORT2 |
michael@0 | 194 | uregion_getContainedRegions(const URegion* uregion, UErrorCode *status); |
michael@0 | 195 | |
michael@0 | 196 | /** |
michael@0 | 197 | * Returns an enumeration over the canonical codes of all the regions that are children of the |
michael@0 | 198 | * specified uregion anywhere in the region hierarchy and match the given type. This API may return |
michael@0 | 199 | * an empty enumeration if this uregion doesn't have any sub-regions that match the given type. |
michael@0 | 200 | * For example, calling this method with region "150" (Europe) and type URGN_TERRITORY" returns an |
michael@0 | 201 | * enumeration containing all the territories in Europe: "FR" (France), "IT" (Italy), "DE" (Germany), |
michael@0 | 202 | * etc. The enumeration must be closed with with uenum_close(). |
michael@0 | 203 | * @draft ICU 52 |
michael@0 | 204 | */ |
michael@0 | 205 | U_DRAFT UEnumeration* U_EXPORT2 |
michael@0 | 206 | uregion_getContainedRegionsOfType(const URegion* uregion, URegionType type, UErrorCode *status); |
michael@0 | 207 | |
michael@0 | 208 | /** |
michael@0 | 209 | * Returns true if the specified uregion contains the specified otherRegion anywhere in the region |
michael@0 | 210 | * hierarchy. |
michael@0 | 211 | * @draft ICU 52 |
michael@0 | 212 | */ |
michael@0 | 213 | U_DRAFT UBool U_EXPORT2 |
michael@0 | 214 | uregion_contains(const URegion* uregion, const URegion* otherRegion); |
michael@0 | 215 | |
michael@0 | 216 | /** |
michael@0 | 217 | * If the specified uregion is deprecated, returns an enumeration over the canonical codes of the |
michael@0 | 218 | * regions that are the preferred replacement regions for the specified uregion. If the specified |
michael@0 | 219 | * uregion is not deprecated, returns NULL. For example, calling this method with uregion |
michael@0 | 220 | * "SU" (Soviet Union) returns a list of the regions containing "RU" (Russia), "AM" (Armenia), |
michael@0 | 221 | * "AZ" (Azerbaijan), etc... The enumeration must be closed with with uenum_close(). |
michael@0 | 222 | * @draft ICU 52 |
michael@0 | 223 | */ |
michael@0 | 224 | U_DRAFT UEnumeration* U_EXPORT2 |
michael@0 | 225 | uregion_getPreferredValues(const URegion* uregion, UErrorCode *status); |
michael@0 | 226 | |
michael@0 | 227 | /** |
michael@0 | 228 | * Returns the specified uregion's canonical code. |
michael@0 | 229 | * @draft ICU 52 |
michael@0 | 230 | */ |
michael@0 | 231 | U_DRAFT const char* U_EXPORT2 |
michael@0 | 232 | uregion_getRegionCode(const URegion* uregion); |
michael@0 | 233 | |
michael@0 | 234 | /** |
michael@0 | 235 | * Returns the specified uregion's numeric code, or a negative value if there is no numeric code |
michael@0 | 236 | * for the specified uregion. |
michael@0 | 237 | * @draft ICU 52 |
michael@0 | 238 | */ |
michael@0 | 239 | U_DRAFT int32_t U_EXPORT2 |
michael@0 | 240 | uregion_getNumericCode(const URegion* uregion); |
michael@0 | 241 | |
michael@0 | 242 | /** |
michael@0 | 243 | * Returns the URegionType of the specified uregion. |
michael@0 | 244 | * @draft ICU 52 |
michael@0 | 245 | */ |
michael@0 | 246 | U_DRAFT URegionType U_EXPORT2 |
michael@0 | 247 | uregion_getType(const URegion* uregion); |
michael@0 | 248 | |
michael@0 | 249 | #endif /* U_HIDE_DRAFT_API */ |
michael@0 | 250 | |
michael@0 | 251 | #endif /* #if !UCONFIG_NO_FORMATTING */ |
michael@0 | 252 | |
michael@0 | 253 | #endif |