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 
128  const Region* getContainingRegion(URegionType type) const;
129 
130 #ifndef U_HIDE_DRAFT_API
131 
140  StringEnumeration* getContainedRegions(UErrorCode &status) const;
141 
149  StringEnumeration* getContainedRegions( URegionType type, UErrorCode &status ) const;
150 #endif /* U_HIDE_DRAFT_API */
151 
156  UBool contains(const Region &other) const;
157 
158 #ifndef U_HIDE_DRAFT_API
159 
165  StringEnumeration* getPreferredValues(UErrorCode &status) const;
166 #endif /* U_HIDE_DRAFT_API */
167 
172  const char* getRegionCode() const;
173 
179  int32_t getNumericCode() const;
180 
185  URegionType getType() const;
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
URegionType
URegionType is an enumeration defining the different types of regions.
Definition: uregion.h:63
C++ API: Unicode String.
U_EXPORT UBool operator==(const StringPiece &x, const StringPiece &y)
Global operator == for StringPiece.
Region is the class representing a Unicode Region Code, also known as a Unicode Region Subtag...
Definition: region.h:68
Base class for 'pure' C++ implementations of uenum api.
Definition: strenum.h:55
#define U_I18N_API
Set to export library symbols from inside the i18n library, and to import them from outside...
Definition: utypes.h:358
C API: URegion (territory containment and mapping)
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition: uversion.h:129
UBool operator!=(const StringPiece &x, const StringPiece &y)
Global operator != for StringPiece.
Definition: stringpiece.h:218
C++ API: Common ICU base class UObject.
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
Definition: uversion.h:130
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers...
Definition: utypes.h:476
C++ API: String Enumeration.
Basic definitions for ICU, for both C and C++ APIs.
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition: unistr.h:245
UObject is the common ICU "boilerplate" class.
Definition: uobject.h:221
int8_t UBool
The ICU boolean type.
Definition: umachine.h:234
C++ API: Unicode Set.