* 10/12/05 emmons Added setters for eraNames, month/day by width/context
*******************************************************************************
*/
+
+#include <utility>
+
#include "unicode/utypes.h"
#if !UCONFIG_NO_FORMATTING
static const char gContextTransformsTag[]="contextTransforms";
-static UMutex LOCK = U_MUTEX_INITIALIZER;
-
/**
* Jitterbug 2974: MSVC has a bug whereby new X[0] behaves badly.
* Work around this.
DateFormatSymbols::getZoneStrings(int32_t& rowCount, int32_t& columnCount) const
{
const UnicodeString **result = NULL;
+ static UMutex LOCK;
umtx_lock(&LOCK);
if (fZoneStrings == NULL) {
UDate now = Calendar::getNow();
UnicodeString tzDispName;
- while ((tzid = tzids->snext(status))) {
+ while ((tzid = tzids->snext(status)) != 0) {
if (U_FAILURE(status)) {
break;
}
* To avoid double deletion, 'maps' won't take ownership of the objects. Instead,
* 'mapRefs' will own them and will delete them when CalendarDataSink is deleted.
*/
- UVector mapRefs;
+ MemoryPool<Hashtable> mapRefs;
// Paths and the aliases they point to
UVector aliasPathPairs;
// Initializes CalendarDataSink with default values
CalendarDataSink(UErrorCode& status)
: arrays(FALSE, status), arraySizes(FALSE, status), maps(FALSE, status),
- mapRefs(deleteHashtable, NULL, 10, status),
+ mapRefs(),
aliasPathPairs(uprv_deleteUObject, uhash_compareUnicodeString, status),
currentCalendarType(), nextCalendarType(),
resourcesToVisit(NULL), aliasRelativePath() {
// Set the resources to visit on the next calendar
if (!resourcesToVisitNext.isNull()) {
- resourcesToVisit.moveFrom(resourcesToVisitNext);
+ resourcesToVisit = std::move(resourcesToVisitNext);
}
}
if (value.getType() == URES_STRING) {
// We are on a leaf, store the map elements into the stringMap
if (i == 0) {
- LocalPointer<Hashtable> stringMapPtr(new Hashtable(FALSE, errorCode), errorCode);
- stringMap = stringMapPtr.getAlias();
+ // mapRefs will keep ownership of 'stringMap':
+ stringMap = mapRefs.create(FALSE, errorCode);
+ if (stringMap == NULL) {
+ errorCode = U_MEMORY_ALLOCATION_ERROR;
+ return;
+ }
maps.put(path, stringMap, errorCode);
- // mapRefs will take ownership of 'stringMap':
- mapRefs.addElement(stringMap, errorCode);
if (U_FAILURE(errorCode)) { return; }
- // Only release ownership after mapRefs takes it (no error happened):
- stringMapPtr.orphan();
stringMap->setValueDeleter(uprv_deleteUObject);
}
U_ASSERT(stringMap != NULL);
static void U_CALLCONV deleteUnicodeStringArray(void *uArray) {
delete[] static_cast<UnicodeString *>(uArray);
}
-
- // Deleter function to be used by 'maps'
- static void U_CALLCONV deleteHashtable(void *table) {
- delete static_cast<Hashtable *>(table);
- }
};
// Virtual destructors have to be defined out of line
CalendarDataSink::~CalendarDataSink() {
// The ordering of the following statements is important.
if (fLeapMonthPatterns[kLeapMonthPatternFormatAbbrev].isEmpty()) {
fLeapMonthPatterns[kLeapMonthPatternFormatAbbrev].setTo(fLeapMonthPatterns[kLeapMonthPatternFormatWide]);
- };
+ }
if (fLeapMonthPatterns[kLeapMonthPatternFormatNarrow].isEmpty()) {
fLeapMonthPatterns[kLeapMonthPatternFormatNarrow].setTo(fLeapMonthPatterns[kLeapMonthPatternStandaloneNarrow]);
- };
+ }
if (fLeapMonthPatterns[kLeapMonthPatternStandaloneWide].isEmpty()) {
fLeapMonthPatterns[kLeapMonthPatternStandaloneWide].setTo(fLeapMonthPatterns[kLeapMonthPatternFormatWide]);
- };
+ }
if (fLeapMonthPatterns[kLeapMonthPatternStandaloneAbbrev].isEmpty()) {
fLeapMonthPatterns[kLeapMonthPatternStandaloneAbbrev].setTo(fLeapMonthPatterns[kLeapMonthPatternFormatAbbrev]);
- };
+ }
// end of hack
fLeapMonthPatternsCount = kMonthPatternsCount;
} else {
++typeMapPtr;
}
if (typeMapPtr->usageTypeName != NULL && compResult == 0) {
- fCapitalization[typeMapPtr->usageTypeEnumValue][0] = intVector[0];
- fCapitalization[typeMapPtr->usageTypeEnumValue][1] = intVector[1];
+ fCapitalization[typeMapPtr->usageTypeEnumValue][0] = static_cast<UBool>(intVector[0]);
+ fCapitalization[typeMapPtr->usageTypeEnumValue][1] = static_cast<UBool>(intVector[1]);
}
}
}
assignArray(fStandaloneNarrowMonths, fStandaloneNarrowMonthsCount, fShortMonths, fShortMonthsCount);
}
- // Load AM/PM markers
+ // Load AM/PM markers; if wide or narrow not available, use short
+ UErrorCode ampmStatus = U_ZERO_ERROR;
initField(&fAmPms, fAmPmsCount, calendarSink,
- buildResourcePath(path, gAmPmMarkersTag, status), status);
+ buildResourcePath(path, gAmPmMarkersTag, ampmStatus), ampmStatus);
+ if (U_FAILURE(ampmStatus)) {
+ initField(&fAmPms, fAmPmsCount, calendarSink,
+ buildResourcePath(path, gAmPmMarkersAbbrTag, status), status);
+ }
+ ampmStatus = U_ZERO_ERROR;
initField(&fNarrowAmPms, fNarrowAmPmsCount, calendarSink,
- buildResourcePath(path, gAmPmMarkersNarrowTag, status), status);
+ buildResourcePath(path, gAmPmMarkersNarrowTag, ampmStatus), ampmStatus);
+ if (U_FAILURE(ampmStatus)) {
+ initField(&fNarrowAmPms, fNarrowAmPmsCount, calendarSink,
+ buildResourcePath(path, gAmPmMarkersAbbrTag, status), status);
+ }
// Load quarters
initField(&fQuarters, fQuartersCount, calendarSink,