michael@0: /* michael@0: ***************************************************************************************** michael@0: * Copyright (C) 2013, International Business Machines michael@0: * Corporation and others. All Rights Reserved. michael@0: ***************************************************************************************** michael@0: */ michael@0: michael@0: #ifndef UREGION_H michael@0: #define UREGION_H michael@0: michael@0: #include "unicode/utypes.h" michael@0: #include "unicode/uenum.h" michael@0: michael@0: /** michael@0: * \file michael@0: * \brief C API: URegion (territory containment and mapping) michael@0: * michael@0: * URegion objects represent data associated with a particular Unicode Region Code, also known as a michael@0: * Unicode Region Subtag, which is defined based upon the BCP 47 standard. These include: michael@0: * * Two-letter codes defined by ISO 3166-1, with special LDML treatment of certain private-use or michael@0: * reserved codes; michael@0: * * A subset of 3-digit numeric codes defined by UN M.49. michael@0: * URegion objects can also provide mappings to and from additional codes. There are different types michael@0: * of regions that are important to distinguish: michael@0: *

michael@0: * Macroregion - A code for a "macro geographical (continental) region, geographical sub-region, or michael@0: * selected economic and other grouping" as defined in UN M.49. These are typically 3-digit codes, michael@0: * but contain some 2-letter codes for LDML extensions, such as "QO" for Outlying Oceania. michael@0: * Macroregions are represented in ICU by one of three region types: WORLD (code 001), michael@0: * CONTINENTS (regions contained directly by WORLD), and SUBCONTINENTS (regions contained directly michael@0: * by a continent ). michael@0: *

michael@0: * TERRITORY - A Region that is not a Macroregion. These are typically codes for countries, but also michael@0: * include areas that are not separate countries, such as the code "AQ" for Antarctica or the code michael@0: * "HK" for Hong Kong (SAR China). Overseas dependencies of countries may or may not have separate michael@0: * codes. The codes are typically 2-letter codes aligned with ISO 3166, but BCP47 allows for the use michael@0: * of 3-digit codes in the future. michael@0: *

michael@0: * UNKNOWN - The code ZZ is defined by Unicode LDML for use in indicating that region is unknown, michael@0: * or that the value supplied as a region was invalid. michael@0: *

michael@0: * DEPRECATED - Region codes that have been defined in the past but are no longer in modern usage, michael@0: * usually due to a country splitting into multiple territories or changing its name. michael@0: *

michael@0: * GROUPING - A widely understood grouping of territories that has a well defined membership such michael@0: * that a region code has been assigned for it. Some of these are UN M.49 codes that don't fall into michael@0: * the world/continent/sub-continent hierarchy, while others are just well-known groupings that have michael@0: * their own region code. Region "EU" (European Union) is one such region code that is a grouping. michael@0: * Groupings will never be returned by the uregion_getContainingRegion, since a different type of region michael@0: * (WORLD, CONTINENT, or SUBCONTINENT) will always be the containing region instead. michael@0: * michael@0: * URegion objects are const/immutable, owned and maintained by ICU itself, so there are not functions michael@0: * to open or close them. michael@0: */ michael@0: michael@0: #ifndef U_HIDE_DRAFT_API michael@0: /** michael@0: * URegionType is an enumeration defining the different types of regions. Current possible michael@0: * values are URGN_WORLD, URGN_CONTINENT, URGN_SUBCONTINENT, URGN_TERRITORY, URGN_GROUPING, michael@0: * URGN_DEPRECATED, and URGN_UNKNOWN. michael@0: * michael@0: * @draft ICU 51 michael@0: */ michael@0: typedef enum URegionType { michael@0: /** michael@0: * Type representing the unknown region. michael@0: * @draft ICU 51 michael@0: */ michael@0: URGN_UNKNOWN, michael@0: michael@0: /** michael@0: * Type representing a territory. michael@0: * @draft ICU 51 michael@0: */ michael@0: URGN_TERRITORY, michael@0: michael@0: /** michael@0: * Type representing the whole world. michael@0: * @draft ICU 51 michael@0: */ michael@0: URGN_WORLD, michael@0: michael@0: /** michael@0: * Type representing a continent. michael@0: * @draft ICU 51 michael@0: */ michael@0: URGN_CONTINENT, michael@0: michael@0: /** michael@0: * Type representing a sub-continent. michael@0: * @draft ICU 51 michael@0: */ michael@0: URGN_SUBCONTINENT, michael@0: michael@0: /** michael@0: * Type representing a grouping of territories that is not to be used in michael@0: * the normal WORLD/CONTINENT/SUBCONTINENT/TERRITORY containment tree. michael@0: * @draft ICU 51 michael@0: */ michael@0: URGN_GROUPING, michael@0: michael@0: /** michael@0: * Type representing a region whose code has been deprecated, usually michael@0: * due to a country splitting into multiple territories or changing its name. michael@0: * @draft ICU 51 michael@0: */ michael@0: URGN_DEPRECATED, michael@0: michael@0: /** michael@0: * Maximum value for this unumeration. michael@0: * @draft ICU 51 michael@0: */ michael@0: URGN_LIMIT michael@0: } URegionType; michael@0: #endif /* U_HIDE_DRAFT_API */ michael@0: michael@0: #if !UCONFIG_NO_FORMATTING michael@0: michael@0: #ifndef U_HIDE_DRAFT_API michael@0: michael@0: /** michael@0: * Opaque URegion object for use in C programs. michael@0: * @draft ICU 52 michael@0: */ michael@0: struct URegion; michael@0: typedef struct URegion URegion; /**< @draft ICU 52 */ michael@0: michael@0: /** michael@0: * Returns a pointer to a URegion for the specified region code: A 2-letter or 3-letter ISO 3166 michael@0: * code, UN M.49 numeric code (superset of ISO 3166 numeric codes), or other valid Unicode Region michael@0: * Code as defined by the LDML specification. The code will be canonicalized internally. If the michael@0: * region code is NULL or not recognized, the appropriate error code will be set michael@0: * (U_ILLEGAL_ARGUMENT_ERROR). michael@0: * @draft ICU 52 michael@0: */ michael@0: U_DRAFT const URegion* U_EXPORT2 michael@0: uregion_getRegionFromCode(const char *regionCode, UErrorCode *status); michael@0: michael@0: /** michael@0: * Returns a pointer to a URegion for the specified numeric region code. If the numeric region michael@0: * code is not recognized, the appropriate error code will be set (U_ILLEGAL_ARGUMENT_ERROR). michael@0: * @draft ICU 52 michael@0: */ michael@0: U_DRAFT const URegion* U_EXPORT2 michael@0: uregion_getRegionFromNumericCode (int32_t code, UErrorCode *status); michael@0: michael@0: /** michael@0: * Returns an enumeration over the canonical codes of all known regions that match the given type. michael@0: * The enumeration must be closed with with uenum_close(). michael@0: * @draft ICU 52 michael@0: */ michael@0: U_DRAFT UEnumeration* U_EXPORT2 michael@0: uregion_getAvailable(URegionType type, UErrorCode *status); michael@0: michael@0: /** michael@0: * Returns true if the specified uregion is equal to the specified otherRegion. michael@0: * @draft ICU 52 michael@0: */ michael@0: U_DRAFT UBool U_EXPORT2 michael@0: uregion_areEqual(const URegion* uregion, const URegion* otherRegion); michael@0: michael@0: /** michael@0: * Returns a pointer to the URegion that contains the specified uregion. Returns NULL if the michael@0: * specified uregion is code "001" (World) or "ZZ" (Unknown region). For example, calling michael@0: * this method with region "IT" (Italy) returns the URegion for "039" (Southern Europe). michael@0: * @draft ICU 52 michael@0: */ michael@0: U_DRAFT const URegion* U_EXPORT2 michael@0: uregion_getContainingRegion(const URegion* uregion); michael@0: michael@0: /** michael@0: * Return a pointer to the URegion that geographically contains this uregion and matches the michael@0: * specified type, moving multiple steps up the containment chain if necessary. Returns NULL if no michael@0: * containing region can be found that matches the specified type. Will return NULL if URegionType michael@0: * is URGN_GROUPING, URGN_DEPRECATED, or URGN_UNKNOWN which are not appropriate for this API. michael@0: * For example, calling this method with uregion "IT" (Italy) for type URGN_CONTINENT returns the michael@0: * URegion "150" (Europe). michael@0: * @draft ICU 52 michael@0: */ michael@0: U_DRAFT const URegion* U_EXPORT2 michael@0: uregion_getContainingRegionOfType(const URegion* uregion, URegionType type); michael@0: michael@0: /** michael@0: * Return an enumeration over the canonical codes of all the regions that are immediate children michael@0: * of the specified uregion in the region hierarchy. These returned regions could be either macro michael@0: * regions, territories, or a mixture of the two, depending on the containment data as defined in michael@0: * CLDR. This API returns NULL if this uregion doesn't have any sub-regions. For example, calling michael@0: * this function for uregion "150" (Europe) returns an enumeration containing the various michael@0: * sub-regions of Europe: "039" (Southern Europe), "151" (Eastern Europe), "154" (Northern Europe), michael@0: * and "155" (Western Europe). The enumeration must be closed with with uenum_close(). michael@0: * @draft ICU 52 michael@0: */ michael@0: U_DRAFT UEnumeration* U_EXPORT2 michael@0: uregion_getContainedRegions(const URegion* uregion, UErrorCode *status); michael@0: michael@0: /** michael@0: * Returns an enumeration over the canonical codes of all the regions that are children of the michael@0: * specified uregion anywhere in the region hierarchy and match the given type. This API may return michael@0: * an empty enumeration if this uregion doesn't have any sub-regions that match the given type. michael@0: * For example, calling this method with region "150" (Europe) and type URGN_TERRITORY" returns an michael@0: * enumeration containing all the territories in Europe: "FR" (France), "IT" (Italy), "DE" (Germany), michael@0: * etc. The enumeration must be closed with with uenum_close(). michael@0: * @draft ICU 52 michael@0: */ michael@0: U_DRAFT UEnumeration* U_EXPORT2 michael@0: uregion_getContainedRegionsOfType(const URegion* uregion, URegionType type, UErrorCode *status); michael@0: michael@0: /** michael@0: * Returns true if the specified uregion contains the specified otherRegion anywhere in the region michael@0: * hierarchy. michael@0: * @draft ICU 52 michael@0: */ michael@0: U_DRAFT UBool U_EXPORT2 michael@0: uregion_contains(const URegion* uregion, const URegion* otherRegion); michael@0: michael@0: /** michael@0: * If the specified uregion is deprecated, returns an enumeration over the canonical codes of the michael@0: * regions that are the preferred replacement regions for the specified uregion. If the specified michael@0: * uregion is not deprecated, returns NULL. For example, calling this method with uregion michael@0: * "SU" (Soviet Union) returns a list of the regions containing "RU" (Russia), "AM" (Armenia), michael@0: * "AZ" (Azerbaijan), etc... The enumeration must be closed with with uenum_close(). michael@0: * @draft ICU 52 michael@0: */ michael@0: U_DRAFT UEnumeration* U_EXPORT2 michael@0: uregion_getPreferredValues(const URegion* uregion, UErrorCode *status); michael@0: michael@0: /** michael@0: * Returns the specified uregion's canonical code. michael@0: * @draft ICU 52 michael@0: */ michael@0: U_DRAFT const char* U_EXPORT2 michael@0: uregion_getRegionCode(const URegion* uregion); michael@0: michael@0: /** michael@0: * Returns the specified uregion's numeric code, or a negative value if there is no numeric code michael@0: * for the specified uregion. michael@0: * @draft ICU 52 michael@0: */ michael@0: U_DRAFT int32_t U_EXPORT2 michael@0: uregion_getNumericCode(const URegion* uregion); michael@0: michael@0: /** michael@0: * Returns the URegionType of the specified uregion. michael@0: * @draft ICU 52 michael@0: */ michael@0: U_DRAFT URegionType U_EXPORT2 michael@0: uregion_getType(const URegion* uregion); michael@0: michael@0: #endif /* U_HIDE_DRAFT_API */ michael@0: michael@0: #endif /* #if !UCONFIG_NO_FORMATTING */ michael@0: michael@0: #endif