OLD | NEW |
1 /* | 1 /* |
2 ******************************************************************************* | 2 ******************************************************************************* |
3 * Copyright (C) 2014-2015, International Business Machines Corporation and | 3 * Copyright (C) 2014-2015, International Business Machines Corporation and |
4 * others. All Rights Reserved. | 4 * others. All Rights Reserved. |
5 ******************************************************************************* | 5 ******************************************************************************* |
6 * | 6 * |
7 * | 7 * |
8 * File REGION.CPP | 8 * File REGION.CPP |
9 * | 9 * |
10 * Modification History:* | 10 * Modification History:* |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 static UVector* availableRegions[URGN_LIMIT]; | 60 static UVector* availableRegions[URGN_LIMIT]; |
61 | 61 |
62 static UHashtable *regionAliases = NULL; | 62 static UHashtable *regionAliases = NULL; |
63 static UHashtable *regionIDMap = NULL; | 63 static UHashtable *regionIDMap = NULL; |
64 static UHashtable *numericCodeMap = NULL; | 64 static UHashtable *numericCodeMap = NULL; |
65 static UVector *allRegions = NULL; | 65 static UVector *allRegions = NULL; |
66 | 66 |
67 static const UChar UNKNOWN_REGION_ID [] = { 0x5A, 0x5A, 0 }; /* "ZZ" */ | 67 static const UChar UNKNOWN_REGION_ID [] = { 0x5A, 0x5A, 0 }; /* "ZZ" */ |
68 static const UChar OUTLYING_OCEANIA_REGION_ID [] = { 0x51, 0x4F, 0 }; /* "QO" *
/ | 68 static const UChar OUTLYING_OCEANIA_REGION_ID [] = { 0x51, 0x4F, 0 }; /* "QO" *
/ |
69 static const UChar WORLD_ID [] = { 0x30, 0x30, 0x31, 0 }; /* "001" */ | 69 static const UChar WORLD_ID [] = { 0x30, 0x30, 0x31, 0 }; /* "001" */ |
70 static const UChar RANGE_MARKER [] = { 0x7e, 0 }; /* "~" */ | 70 static const UChar RANGE_MARKER = 0x7eu; /* '~' */ |
71 static const UnicodeString RANGE_MARKER_STRING(RANGE_MARKER); | |
72 | 71 |
73 UOBJECT_DEFINE_RTTI_IMPLEMENTATION(RegionNameEnumeration) | 72 UOBJECT_DEFINE_RTTI_IMPLEMENTATION(RegionNameEnumeration) |
74 | 73 |
75 /* | 74 /* |
76 * Initializes the region data from the ICU resource bundles. The region data | 75 * Initializes the region data from the ICU resource bundles. The region data |
77 * contains the basic relationships such as which regions are known, what the nu
meric | 76 * contains the basic relationships such as which regions are known, what the nu
meric |
78 * codes are, any known aliases, and the territory containment data. | 77 * codes are, any known aliases, and the territory containment data. |
79 * | 78 * |
80 * If the region data has already loaded, then this method simply returns withou
t doing | 79 * If the region data has already loaded, then this method simply returns withou
t doing |
81 * anything meaningful. | 80 * anything meaningful. |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 } | 113 } |
115 | 114 |
116 // now, initialize | 115 // now, initialize |
117 df->setParseIntegerOnly(TRUE); | 116 df->setParseIntegerOnly(TRUE); |
118 uhash_setValueDeleter(newRegionIDMap.getAlias(), deleteRegion); // regionID
Map owns objs | 117 uhash_setValueDeleter(newRegionIDMap.getAlias(), deleteRegion); // regionID
Map owns objs |
119 uhash_setKeyDeleter(newRegionAliases.getAlias(), uprv_deleteUObject); // reg
ionAliases owns the string keys | 118 uhash_setKeyDeleter(newRegionAliases.getAlias(), uprv_deleteUObject); // reg
ionAliases owns the string keys |
120 | 119 |
121 | 120 |
122 while ( ures_hasNext(regionRegular.getAlias()) ) { | 121 while ( ures_hasNext(regionRegular.getAlias()) ) { |
123 UnicodeString regionName = ures_getNextUnicodeString(regionRegular.getAl
ias(),NULL,&status); | 122 UnicodeString regionName = ures_getNextUnicodeString(regionRegular.getAl
ias(),NULL,&status); |
124 int32_t rangeMarkerLocation = regionName.indexOf(RANGE_MARKER_STRING); | 123 int32_t rangeMarkerLocation = regionName.indexOf(RANGE_MARKER); |
125 UChar buf[6]; | 124 UChar buf[6]; |
126 regionName.extract(buf,6,status); | 125 regionName.extract(buf,6,status); |
127 if ( rangeMarkerLocation > 0 ) { | 126 if ( rangeMarkerLocation > 0 ) { |
128 UChar endRange = regionName.charAt(rangeMarkerLocation+1); | 127 UChar endRange = regionName.charAt(rangeMarkerLocation+1); |
129 buf[rangeMarkerLocation] = 0; | 128 buf[rangeMarkerLocation] = 0; |
130 while ( buf[rangeMarkerLocation-1] <= endRange ) { | 129 while ( buf[rangeMarkerLocation-1] <= endRange ) { |
131 LocalPointer<UnicodeString> newRegion(new UnicodeString(buf), st
atus); | 130 LocalPointer<UnicodeString> newRegion(new UnicodeString(buf), st
atus); |
132 allRegions->addElement(newRegion.orphan(),status); | 131 allRegions->addElement(newRegion.orphan(),status); |
133 buf[rangeMarkerLocation-1]++; | 132 buf[rangeMarkerLocation-1]++; |
134 } | 133 } |
135 } else { | 134 } else { |
136 LocalPointer<UnicodeString> newRegion(new UnicodeString(regionName),
status); | 135 LocalPointer<UnicodeString> newRegion(new UnicodeString(regionName),
status); |
137 allRegions->addElement(newRegion.orphan(),status); | 136 allRegions->addElement(newRegion.orphan(),status); |
138 } | 137 } |
139 } | 138 } |
140 | 139 |
141 while ( ures_hasNext(regionMacro.getAlias()) ) { | 140 while ( ures_hasNext(regionMacro.getAlias()) ) { |
142 UnicodeString regionName = ures_getNextUnicodeString(regionMacro.getAlia
s(),NULL,&status); | 141 UnicodeString regionName = ures_getNextUnicodeString(regionMacro.getAlia
s(),NULL,&status); |
143 int32_t rangeMarkerLocation = regionName.indexOf(RANGE_MARKER_STRING); | 142 int32_t rangeMarkerLocation = regionName.indexOf(RANGE_MARKER); |
144 UChar buf[6]; | 143 UChar buf[6]; |
145 regionName.extract(buf,6,status); | 144 regionName.extract(buf,6,status); |
146 if ( rangeMarkerLocation > 0 ) { | 145 if ( rangeMarkerLocation > 0 ) { |
147 UChar endRange = regionName.charAt(rangeMarkerLocation+1); | 146 UChar endRange = regionName.charAt(rangeMarkerLocation+1); |
148 buf[rangeMarkerLocation] = 0; | 147 buf[rangeMarkerLocation] = 0; |
149 while ( buf[rangeMarkerLocation-1] <= endRange ) { | 148 while ( buf[rangeMarkerLocation-1] <= endRange ) { |
150 LocalPointer<UnicodeString> newRegion(new UnicodeString(buf), st
atus); | 149 LocalPointer<UnicodeString> newRegion(new UnicodeString(buf), st
atus); |
151 allRegions->addElement(newRegion.orphan(),status); | 150 allRegions->addElement(newRegion.orphan(),status); |
152 buf[rangeMarkerLocation-1]++; | 151 buf[rangeMarkerLocation-1]++; |
153 } | 152 } |
(...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
738 | 737 |
739 RegionNameEnumeration::~RegionNameEnumeration() { | 738 RegionNameEnumeration::~RegionNameEnumeration() { |
740 delete fRegionNames; | 739 delete fRegionNames; |
741 } | 740 } |
742 | 741 |
743 U_NAMESPACE_END | 742 U_NAMESPACE_END |
744 | 743 |
745 #endif /* #if !UCONFIG_NO_FORMATTING */ | 744 #endif /* #if !UCONFIG_NO_FORMATTING */ |
746 | 745 |
747 //eof | 746 //eof |
OLD | NEW |