ICU-5787 code cleanup.
X-SVN-Rev: 22485
This commit is contained in:
parent
a9d956e2d8
commit
12dd691583
@ -123,12 +123,15 @@ static const char* Resource_Fields[] = {
|
|||||||
static const UChar UDATPG_ItemFormat[]= {0x7B, 0x30, 0x7D, 0x20, 0x251C, 0x7B, 0x32, 0x7D, 0x3A,
|
static const UChar UDATPG_ItemFormat[]= {0x7B, 0x30, 0x7D, 0x20, 0x251C, 0x7B, 0x32, 0x7D, 0x3A,
|
||||||
0x20, 0x7B, 0x31, 0x7D, 0x2524, 0}; // {0} \u251C{2}: {1}\u2524
|
0x20, 0x7B, 0x31, 0x7D, 0x2524, 0}; // {0} \u251C{2}: {1}\u2524
|
||||||
|
|
||||||
|
static const UChar repeatedPatterns[6]={CAP_G, CAP_E, LOW_Z, LOW_V, CAP_Q, 0}; // "GEzvQ"
|
||||||
|
|
||||||
static const char DT_DateTimePatternsTag[]="DateTimePatterns";
|
static const char DT_DateTimePatternsTag[]="DateTimePatterns";
|
||||||
static const char DT_DateTimeCalendarTag[]="calendar";
|
static const char DT_DateTimeCalendarTag[]="calendar";
|
||||||
static const char DT_DateTimeGregorianTag[]="gregorian";
|
static const char DT_DateTimeGregorianTag[]="gregorian";
|
||||||
static const char DT_DateTimeAppendItemsTag[]="appendItems";
|
static const char DT_DateTimeAppendItemsTag[]="appendItems";
|
||||||
static const char DT_DateTimeFieldsTag[]="fields";
|
static const char DT_DateTimeFieldsTag[]="fields";
|
||||||
static const char DT_DateTimeAvailableFormatsTag[]="availableFormats";
|
static const char DT_DateTimeAvailableFormatsTag[]="availableFormats";
|
||||||
|
static const UnicodeString repeatedPattern=UnicodeString(repeatedPatterns);
|
||||||
|
|
||||||
UOBJECT_DEFINE_RTTI_IMPLEMENTATION(DateTimePatternGenerator)
|
UOBJECT_DEFINE_RTTI_IMPLEMENTATION(DateTimePatternGenerator)
|
||||||
UOBJECT_DEFINE_RTTI_IMPLEMENTATION(DTSkeletonEnumeration)
|
UOBJECT_DEFINE_RTTI_IMPLEMENTATION(DTSkeletonEnumeration)
|
||||||
@ -303,7 +306,7 @@ DateTimePatternGenerator::addICUPatterns(const Locale& locale, UErrorCode& statu
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
DateTimePatternGenerator::hackTimes(UnicodeString& hackPattern, UErrorCode& status) {
|
DateTimePatternGenerator::hackTimes(const UnicodeString& hackPattern, UErrorCode& status) {
|
||||||
UDateTimePatternConflict conflictingStatus;
|
UDateTimePatternConflict conflictingStatus;
|
||||||
UnicodeString conflictingString;
|
UnicodeString conflictingString;
|
||||||
|
|
||||||
@ -702,7 +705,7 @@ DateTimePatternGenerator::addPattern(
|
|||||||
|
|
||||||
|
|
||||||
UDateTimePatternField
|
UDateTimePatternField
|
||||||
DateTimePatternGenerator::getAppendFormatNumber(const char* field) {
|
DateTimePatternGenerator::getAppendFormatNumber(const char* field) const {
|
||||||
for (int32_t i=0; i<UDATPG_FIELD_COUNT; ++i ) {
|
for (int32_t i=0; i<UDATPG_FIELD_COUNT; ++i ) {
|
||||||
if (uprv_strcmp(CLDR_FIELD_APPEND[i], field)==0) {
|
if (uprv_strcmp(CLDR_FIELD_APPEND[i], field)==0) {
|
||||||
return (UDateTimePatternField)i;
|
return (UDateTimePatternField)i;
|
||||||
@ -712,7 +715,7 @@ DateTimePatternGenerator::getAppendFormatNumber(const char* field) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
UDateTimePatternField
|
UDateTimePatternField
|
||||||
DateTimePatternGenerator::getAppendNameNumber(const char* field) {
|
DateTimePatternGenerator::getAppendNameNumber(const char* field) const {
|
||||||
for (int32_t i=0; i<UDATPG_FIELD_COUNT; ++i ) {
|
for (int32_t i=0; i<UDATPG_FIELD_COUNT; ++i ) {
|
||||||
if (uprv_strcmp(CLDR_FIELD_NAME[i],field)==0) {
|
if (uprv_strcmp(CLDR_FIELD_NAME[i],field)==0) {
|
||||||
return (UDateTimePatternField)i;
|
return (UDateTimePatternField)i;
|
||||||
@ -881,7 +884,7 @@ DateTimePatternGenerator::setAvailableFormat(const UnicodeString &key, UErrorCod
|
|||||||
}
|
}
|
||||||
|
|
||||||
UBool
|
UBool
|
||||||
DateTimePatternGenerator::isAvailableFormatSet(const UnicodeString &key) {
|
DateTimePatternGenerator::isAvailableFormatSet(const UnicodeString &key) const {
|
||||||
return (UBool)(fAvailableFormatKeyHash->geti(key) == 1);
|
return (UBool)(fAvailableFormatKeyHash->geti(key) == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -966,7 +969,7 @@ DateTimePatternGenerator::getRedundants(UErrorCode& status) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
UBool
|
UBool
|
||||||
DateTimePatternGenerator::isCanonicalItem(const UnicodeString& item) {
|
DateTimePatternGenerator::isCanonicalItem(const UnicodeString& item) const {
|
||||||
if ( item.length() != 1 ) {
|
if ( item.length() != 1 ) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
@ -1080,31 +1083,12 @@ PatternMap::add(const UnicodeString& basePattern,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (baseChar >= LOW_A) {
|
if (baseChar >= LOW_A) {
|
||||||
Mutex mutex;
|
boot[26 + (baseChar-LOW_A)] = curElem;
|
||||||
if ( boot[26 + (baseChar-LOW_A)]==NULL ) {
|
|
||||||
boot[26 + (baseChar-LOW_A)] = curElem;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
uprv_free(curElem);
|
|
||||||
curElem=NULL;
|
|
||||||
baseElem = boot[26 + (baseChar-LOW_A)];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Mutex mutex;
|
boot[baseChar-CAP_A] = curElem;
|
||||||
if (boot[baseChar-CAP_A] == NULL ) {
|
|
||||||
boot[baseChar-CAP_A] = curElem;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
uprv_free(curElem);
|
|
||||||
curElem=NULL;
|
|
||||||
baseElem = boot[baseChar-CAP_A];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ( curElem != NULL ) {
|
|
||||||
curElem->skeleton = new PtnSkeleton(skeleton);
|
|
||||||
curElem->next = NULL;
|
|
||||||
}
|
}
|
||||||
|
curElem->skeleton = new PtnSkeleton(skeleton);
|
||||||
}
|
}
|
||||||
if ( baseElem != NULL ) {
|
if ( baseElem != NULL ) {
|
||||||
curElem = getDuplicateElem(basePattern, skeleton, baseElem);
|
curElem = getDuplicateElem(basePattern, skeleton, baseElem);
|
||||||
@ -1112,21 +1096,17 @@ PatternMap::add(const UnicodeString& basePattern,
|
|||||||
if (curElem == NULL) {
|
if (curElem == NULL) {
|
||||||
// add new element to the list.
|
// add new element to the list.
|
||||||
curElem = baseElem;
|
curElem = baseElem;
|
||||||
|
while( curElem -> next != NULL )
|
||||||
{
|
{
|
||||||
Mutex mutex;
|
curElem = curElem->next;
|
||||||
while( curElem -> next != NULL )
|
|
||||||
{
|
|
||||||
curElem = curElem->next;
|
|
||||||
}
|
|
||||||
if ((curElem->next = new PtnElem(basePattern, value)) == NULL ) {
|
|
||||||
// out of memory
|
|
||||||
status = U_MEMORY_ALLOCATION_ERROR;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
curElem=curElem->next;
|
|
||||||
}
|
}
|
||||||
|
if ((curElem->next = new PtnElem(basePattern, value)) == NULL ) {
|
||||||
|
// out of memory
|
||||||
|
status = U_MEMORY_ALLOCATION_ERROR;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
curElem=curElem->next;
|
||||||
curElem->skeleton = new PtnSkeleton(skeleton);
|
curElem->skeleton = new PtnSkeleton(skeleton);
|
||||||
curElem->next = NULL;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Pattern exists in the list already.
|
// Pattern exists in the list already.
|
||||||
@ -1278,10 +1258,6 @@ DateTimeMatcher::set(const UnicodeString& pattern, FormatParser* fp) {
|
|||||||
|
|
||||||
void
|
void
|
||||||
DateTimeMatcher::set(const UnicodeString& pattern, FormatParser* fp, PtnSkeleton& skeleton) {
|
DateTimeMatcher::set(const UnicodeString& pattern, FormatParser* fp, PtnSkeleton& skeleton) {
|
||||||
|
|
||||||
static const UChar repeatedPatterns[6]={CAP_G, CAP_E, LOW_Z, LOW_V, CAP_Q, 0}; // "GEzvQ"
|
|
||||||
UnicodeString repeatedPattern=UnicodeString(repeatedPatterns);
|
|
||||||
|
|
||||||
for (int32_t i=0; i<UDATPG_FIELD_COUNT; ++i) {
|
for (int32_t i=0; i<UDATPG_FIELD_COUNT; ++i) {
|
||||||
skeleton.type[i]=NONE;
|
skeleton.type[i]=NONE;
|
||||||
}
|
}
|
||||||
@ -1315,11 +1291,7 @@ DateTimeMatcher::set(const UnicodeString& pattern, FormatParser* fp, PtnSkeleton
|
|||||||
}
|
}
|
||||||
skeleton.type[typeValue] = (int8_t)subTypeValue;
|
skeleton.type[typeValue] = (int8_t)subTypeValue;
|
||||||
}
|
}
|
||||||
{
|
copyFrom(skeleton);
|
||||||
Mutex mutex;
|
|
||||||
copyFrom(skeleton);
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1347,7 +1319,7 @@ DateTimeMatcher::getPattern() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int32_t
|
int32_t
|
||||||
DateTimeMatcher::getDistance(DateTimeMatcher& other, int32_t includeMask, DistanceInfo& distanceInfo) {
|
DateTimeMatcher::getDistance(const DateTimeMatcher& other, int32_t includeMask, DistanceInfo& distanceInfo) {
|
||||||
int32_t result=0;
|
int32_t result=0;
|
||||||
distanceInfo.clear();
|
distanceInfo.clear();
|
||||||
for (int32_t i=0; i<UDATPG_FIELD_COUNT; ++i ) {
|
for (int32_t i=0; i<UDATPG_FIELD_COUNT; ++i ) {
|
||||||
@ -1396,7 +1368,7 @@ DateTimeMatcher::copyFrom() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
UBool
|
UBool
|
||||||
DateTimeMatcher::equals(DateTimeMatcher* other) {
|
DateTimeMatcher::equals(const DateTimeMatcher* other) const {
|
||||||
if (other==NULL) {
|
if (other==NULL) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
@ -1507,7 +1479,7 @@ FormatParser::getCanonicalIndex(const UnicodeString& s) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
UBool
|
UBool
|
||||||
FormatParser::isQuoteLiteral(UnicodeString s) {
|
FormatParser::isQuoteLiteral(const UnicodeString& s) const {
|
||||||
return (UBool)(s.charAt(0)==SINGLE_QUOTE);
|
return (UBool)(s.charAt(0)==SINGLE_QUOTE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1517,6 +1489,7 @@ void
|
|||||||
FormatParser::getQuoteLiteral(UnicodeString& quote, int32_t *itemIndex) {
|
FormatParser::getQuoteLiteral(UnicodeString& quote, int32_t *itemIndex) {
|
||||||
int32_t i=*itemIndex;
|
int32_t i=*itemIndex;
|
||||||
|
|
||||||
|
quote.remove();
|
||||||
if (items[i].charAt(0)==SINGLE_QUOTE) {
|
if (items[i].charAt(0)==SINGLE_QUOTE) {
|
||||||
quote += items[i];
|
quote += items[i];
|
||||||
++i;
|
++i;
|
||||||
@ -1525,7 +1498,8 @@ FormatParser::getQuoteLiteral(UnicodeString& quote, int32_t *itemIndex) {
|
|||||||
if ( items[i].charAt(0)==SINGLE_QUOTE ) {
|
if ( items[i].charAt(0)==SINGLE_QUOTE ) {
|
||||||
if ( (i+1<itemNumber) && (items[i+1].charAt(0)==SINGLE_QUOTE)) {
|
if ( (i+1<itemNumber) && (items[i+1].charAt(0)==SINGLE_QUOTE)) {
|
||||||
// two single quotes e.g. 'o''clock'
|
// two single quotes e.g. 'o''clock'
|
||||||
quote += items[++i];
|
quote += items[i++];
|
||||||
|
quote += items[i++];
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -1710,10 +1684,10 @@ PtnSkeleton::~PtnSkeleton() {
|
|||||||
|
|
||||||
PtnElem::PtnElem(const UnicodeString &basePat, const UnicodeString &pat) :
|
PtnElem::PtnElem(const UnicodeString &basePat, const UnicodeString &pat) :
|
||||||
basePattern(basePat),
|
basePattern(basePat),
|
||||||
pattern(pat)
|
pattern(pat),
|
||||||
|
skeleton(NULL),
|
||||||
|
next(NULL)
|
||||||
{
|
{
|
||||||
skeleton=NULL;
|
|
||||||
next=NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PtnElem::~PtnElem() {
|
PtnElem::~PtnElem() {
|
||||||
|
@ -137,31 +137,8 @@ public:
|
|||||||
|
|
||||||
FormatParser();
|
FormatParser();
|
||||||
virtual ~FormatParser();
|
virtual ~FormatParser();
|
||||||
/**
|
|
||||||
* Set the string to parse
|
|
||||||
* @param string
|
|
||||||
* @return this, for chaining
|
|
||||||
* @deprecated
|
|
||||||
* @internal
|
|
||||||
*/
|
|
||||||
void set(const UnicodeString& patternString);
|
void set(const UnicodeString& patternString);
|
||||||
/**
|
UBool isQuoteLiteral(const UnicodeString& s) const;
|
||||||
* Check string 's' is a quoted literal
|
|
||||||
* @param string with quoted literals
|
|
||||||
* @param starting index of items and return the next index of items of end quoted literal
|
|
||||||
* @return TRUE if s is a quote literal, FALSE if s is not a quote literal.
|
|
||||||
* @deprecated
|
|
||||||
* @internal
|
|
||||||
*/
|
|
||||||
UBool isQuoteLiteral(UnicodeString s);
|
|
||||||
/**
|
|
||||||
* produce a quoted literal
|
|
||||||
* @param string with quoted literals
|
|
||||||
* @param starting index of items and return the next index of items of end quoted literal
|
|
||||||
* @return none
|
|
||||||
* @deprecated
|
|
||||||
* @internal
|
|
||||||
*/
|
|
||||||
void getQuoteLiteral(UnicodeString& quote, int32_t *itemIndex);
|
void getQuoteLiteral(UnicodeString& quote, int32_t *itemIndex);
|
||||||
int32_t getCanonicalIndex(const UnicodeString& s);
|
int32_t getCanonicalIndex(const UnicodeString& s);
|
||||||
UBool isPatternSeparator(UnicodeString& field);
|
UBool isPatternSeparator(UnicodeString& field);
|
||||||
@ -176,12 +153,9 @@ private:
|
|||||||
} ToeknStatus;
|
} ToeknStatus;
|
||||||
|
|
||||||
TokenStatus status;
|
TokenStatus status;
|
||||||
UnicodeSet *quoteFilter;
|
|
||||||
|
|
||||||
virtual TokenStatus setTokens(const UnicodeString& pattern, int32_t startPos, int32_t *len);
|
virtual TokenStatus setTokens(const UnicodeString& pattern, int32_t startPos, int32_t *len);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class DistanceInfo : public UMemory {
|
class DistanceInfo : public UMemory {
|
||||||
public:
|
public:
|
||||||
int32_t missingFieldMask;
|
int32_t missingFieldMask;
|
||||||
@ -206,8 +180,8 @@ public:
|
|||||||
void copyFrom(PtnSkeleton& skeleton);
|
void copyFrom(PtnSkeleton& skeleton);
|
||||||
void copyFrom();
|
void copyFrom();
|
||||||
PtnSkeleton* getSkeletonPtr();
|
PtnSkeleton* getSkeletonPtr();
|
||||||
UBool equals(DateTimeMatcher* other);
|
UBool equals(const DateTimeMatcher* other) const;
|
||||||
int32_t getDistance(DateTimeMatcher& other, int32_t includeMask, DistanceInfo& distanceInfo);
|
int32_t getDistance(const DateTimeMatcher& other, int32_t includeMask, DistanceInfo& distanceInfo);
|
||||||
DateTimeMatcher();
|
DateTimeMatcher();
|
||||||
virtual ~DateTimeMatcher() {};
|
virtual ~DateTimeMatcher() {};
|
||||||
int32_t getFieldMask();
|
int32_t getFieldMask();
|
||||||
|
@ -59,7 +59,7 @@ public:
|
|||||||
static DateTimePatternGenerator* U_EXPORT2 createInstance(const Locale& uLocale, UErrorCode& status);
|
static DateTimePatternGenerator* U_EXPORT2 createInstance(const Locale& uLocale, UErrorCode& status);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create an empty generator, to be constructed with add(...) etc.
|
* Create an empty generator, to be constructed with addPattern(...) etc.
|
||||||
* @param status Output param set to success/failure code on exit,
|
* @param status Output param set to success/failure code on exit,
|
||||||
* which must not indicate a failure before the function call.
|
* which must not indicate a failure before the function call.
|
||||||
* @draft ICU 3.8
|
* @draft ICU 3.8
|
||||||
@ -390,24 +390,24 @@ private:
|
|||||||
void initData(const Locale &locale);
|
void initData(const Locale &locale);
|
||||||
void addCanonicalItems();
|
void addCanonicalItems();
|
||||||
void addICUPatterns(const Locale& locale, UErrorCode& status);
|
void addICUPatterns(const Locale& locale, UErrorCode& status);
|
||||||
void hackTimes(UnicodeString& hackPattern, UErrorCode& status);
|
void hackTimes(const UnicodeString& hackPattern, UErrorCode& status);
|
||||||
void addCLDRData(const Locale& locale);
|
void addCLDRData(const Locale& locale);
|
||||||
void initHashtable(UErrorCode& status);
|
void initHashtable(UErrorCode& status);
|
||||||
void setDateTimeFromCalendar(const Locale& locale, UErrorCode& status);
|
void setDateTimeFromCalendar(const Locale& locale, UErrorCode& status);
|
||||||
void setDecimalSymbols(const Locale& locale, UErrorCode& status);
|
void setDecimalSymbols(const Locale& locale, UErrorCode& status);
|
||||||
UDateTimePatternField getAppendFormatNumber(const char* field);
|
UDateTimePatternField getAppendFormatNumber(const char* field) const;
|
||||||
UDateTimePatternField getAppendNameNumber(const char* field);
|
UDateTimePatternField getAppendNameNumber(const char* field) const;
|
||||||
void getAppendName(UDateTimePatternField field, UnicodeString& value);
|
void getAppendName(UDateTimePatternField field, UnicodeString& value);
|
||||||
int32_t getCanonicalIndex(const UnicodeString& field);
|
int32_t getCanonicalIndex(const UnicodeString& field);
|
||||||
const UnicodeString* getBestRaw(DateTimeMatcher& source, int32_t includeMask, DistanceInfo* missingFields);
|
const UnicodeString* getBestRaw(DateTimeMatcher& source, int32_t includeMask, DistanceInfo* missingFields);
|
||||||
UnicodeString adjustFieldTypes(const UnicodeString& pattern, UBool fixFractionalSeconds);
|
UnicodeString adjustFieldTypes(const UnicodeString& pattern, UBool fixFractionalSeconds);
|
||||||
UnicodeString getBestAppending(const int32_t missingFields);
|
UnicodeString getBestAppending(int32_t missingFields);
|
||||||
int32_t getTopBitNumber(int32_t foundMask);
|
int32_t getTopBitNumber(int32_t foundMask);
|
||||||
void setAvailableFormat(const UnicodeString &key, UErrorCode& status);
|
void setAvailableFormat(const UnicodeString &key, UErrorCode& status);
|
||||||
UBool isAvailableFormatSet(const UnicodeString &key);
|
UBool isAvailableFormatSet(const UnicodeString &key) const;
|
||||||
void copyHashtable(Hashtable *other);
|
void copyHashtable(Hashtable *other);
|
||||||
UBool isCanonicalItem(const UnicodeString& item);
|
UBool isCanonicalItem(const UnicodeString& item) const;
|
||||||
UErrorCode getStatus() { return fStatus; } ;
|
UErrorCode getStatus() const { return fStatus; } ;
|
||||||
} ;// end class DateTimePatternGenerator
|
} ;// end class DateTimePatternGenerator
|
||||||
|
|
||||||
U_NAMESPACE_END
|
U_NAMESPACE_END
|
||||||
|
Loading…
Reference in New Issue
Block a user