ICU 55.1  55.1
region.h
Go to the documentation of this file.
1 /*
2  *******************************************************************************
3  * Copyright (C) 2014-2015, International Business Machines Corporation and others.
4  * All Rights Reserved.
5  *******************************************************************************
6  */
7 
8 #ifndef REGION_H
9 #define REGION_H
10 
16 #include "unicode/utypes.h"
17 #include "unicode/uregion.h"
18 
19 #if !UCONFIG_NO_FORMATTING
20 
21 #include "unicode/uobject.h"
22 #include "unicode/uniset.h"
23 #include "unicode/unistr.h"
24 #include "unicode/strenum.h"
25 
27 
68 class U_I18N_API Region : public UObject {
69 public:
74  virtual ~Region();
75 
80  UBool operator==(const Region &that) const;
81 
86  UBool operator!=(const Region &that) const;
87 
95  static const Region* U_EXPORT2 getInstance(const char *region_code, UErrorCode &status);
96 
102  static const Region* U_EXPORT2 getInstance (int32_t code, UErrorCode &status);
103 
104 #ifndef U_HIDE_DRAFT_API
105 
109  static StringEnumeration* U_EXPORT2 getAvailable(URegionType type, UErrorCode &status);
110 #endif /* U_HIDE_DRAFT_API */
111 
118  const Region* getContainingRegion() const;
119 
129 
130 #ifndef U_HIDE_DRAFT_API
131 
141 
150 #endif /* U_HIDE_DRAFT_API */
151 
156  UBool contains(const Region &other) const;
157 
158 #ifndef U_HIDE_DRAFT_API
159 
166 #endif /* U_HIDE_DRAFT_API */
167 
172  const char* getRegionCode() const;
173 
179  int32_t getNumericCode() const;
180 
186 
187 #ifndef U_HIDE_INTERNAL_API
188 
192  static void cleanupRegionData();
193 #endif /* U_HIDE_INTERNAL_API */
194 
195 private:
196  char id[4];
197  UnicodeString idStr;
198  int32_t code;
199  URegionType type;
200  Region *containingRegion;
201  UVector *containedRegions;
202  UVector *preferredValues;
203 
207  Region();
208 
209 
210  /*
211  * Initializes the region data from the ICU resource bundles. The region data
212  * contains the basic relationships such as which regions are known, what the numeric
213  * codes are, any known aliases, and the territory containment data.
214  *
215  * If the region data has already loaded, then this method simply returns without doing
216  * anything meaningful.
217  */
218 
219  static void loadRegionData(UErrorCode &status);
220 
221 };
222 
224 
225 #endif /* #if !UCONFIG_NO_FORMATTING */
226 #endif // REGION_H
227 
228 //eof
icu::Region::~Region
virtual ~Region()
Destructor.
uregion.h
C API: URegion (territory containment and mapping)
utypes.h
Basic definitions for ICU, for both C and C++ APIs.
U_I18N_API
#define U_I18N_API
Set to export library symbols from inside the i18n library, and to import them from outside.
Definition: utypes.h:358
UBool
int8_t UBool
The ICU boolean type.
Definition: umachine.h:234
icu::Region::operator!=
UBool operator!=(const Region &that) const
Returns true if the two regions are NOT equal; that is, if operator ==() returns false.
URegionType
URegionType
URegionType is an enumeration defining the different types of regions.
Definition: uregion.h:63
icu::Region::getContainedRegions
StringEnumeration * getContainedRegions(UErrorCode &status) const
Return an enumeration over the IDs of all the regions that are immediate children of this region in t...
icu::Region::getType
URegionType getType() const
Returns the region type of this region.
icu::Region::getPreferredValues
StringEnumeration * getPreferredValues(UErrorCode &status) const
For deprecated regions, return an enumeration over the IDs of the regions that are the preferred repl...
icu::UnicodeString
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition: unistr.h:246
icu::Region::getContainingRegion
const Region * getContainingRegion(URegionType type) const
Return a pointer to the region that geographically contains this region and matches the given type,...
icu::UObject
UObject is the common ICU "boilerplate" class.
Definition: uobject.h:221
UErrorCode
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers,...
Definition: utypes.h:476
icu::StringEnumeration
Base class for 'pure' C++ implementations of uenum api.
Definition: strenum.h:55
icu::Region::getAvailable
static StringEnumeration * getAvailable(URegionType type, UErrorCode &status)
Returns an enumeration over the IDs of all known regions that match the given type.
icu::Region::contains
UBool contains(const Region &other) const
Returns true if this region contains the supplied other region anywhere in the region hierarchy.
icu::Region::getInstance
static const Region * getInstance(int32_t code, UErrorCode &status)
Returns a pointer to a Region using the given numeric region code.
icu::Region::operator==
UBool operator==(const Region &that) const
Returns true if the two regions are equal.
icu::Region
Region is the class representing a Unicode Region Code, also known as a Unicode Region Subtag,...
Definition: region.h:68
icu::Region::getNumericCode
int32_t getNumericCode() const
Return this region's numeric code.
icu::Region::cleanupRegionData
static void cleanupRegionData()
Cleans up statically allocated memory.
icu::Region::getInstance
static const Region * getInstance(const char *region_code, UErrorCode &status)
Returns a pointer to a Region using the given region code.
strenum.h
C++ API: String Enumeration.
icu::Region::getContainedRegions
StringEnumeration * getContainedRegions(URegionType type, UErrorCode &status) const
Returns an enumeration over the IDs of all the regions that are children of this region anywhere in t...
uobject.h
C++ API: Common ICU base class UObject.
uniset.h
C++ API: Unicode Set.
U_NAMESPACE_END
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
Definition: uversion.h:130
U_NAMESPACE_BEGIN
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition: uversion.h:129
unistr.h
C++ API: Unicode String.
icu::Region::getContainingRegion
const Region * getContainingRegion() const
Returns a pointer to the region that contains this region.
icu::Region::getRegionCode
const char * getRegionCode() const
Return this region's canonical region code.