ICU 57.1  57.1
region.h
Go to the documentation of this file.
1 /*
2  *******************************************************************************
3  * Copyright (C) 2014-2016, 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 
108  static StringEnumeration* U_EXPORT2 getAvailable(URegionType type, UErrorCode &status);
109 
116  const Region* getContainingRegion() const;
117 
126  const Region* getContainingRegion(URegionType type) const;
127 
137  StringEnumeration* getContainedRegions(UErrorCode &status) const;
138 
146  StringEnumeration* getContainedRegions( URegionType type, UErrorCode &status ) const;
147 
152  UBool contains(const Region &other) const;
153 
160  StringEnumeration* getPreferredValues(UErrorCode &status) const;
161 
166  const char* getRegionCode() const;
167 
173  int32_t getNumericCode() const;
174 
179  URegionType getType() const;
180 
181 #ifndef U_HIDE_INTERNAL_API
182 
186  static void cleanupRegionData();
187 #endif /* U_HIDE_INTERNAL_API */
188 
189 private:
190  char id[4];
191  UnicodeString idStr;
192  int32_t code;
193  URegionType type;
194  Region *containingRegion;
195  UVector *containedRegions;
196  UVector *preferredValues;
197 
201  Region();
202 
203 
204  /*
205  * Initializes the region data from the ICU resource bundles. The region data
206  * contains the basic relationships such as which regions are known, what the numeric
207  * codes are, any known aliases, and the territory containment data.
208  *
209  * If the region data has already loaded, then this method simply returns without doing
210  * anything meaningful.
211  */
212 
213  static void loadRegionData(UErrorCode &status);
214 
215 };
216 
218 
219 #endif /* #if !UCONFIG_NO_FORMATTING */
220 #endif // REGION_H
221 
222 //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:293
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.