| OLD | NEW |
| 1 /* | 1 /* |
| 2 ******************************************************************************* | 2 ******************************************************************************* |
| 3 * Copyright (C) 2007-2013, International Business Machines Corporation and | 3 * Copyright (C) 2007-2014, International Business Machines Corporation and |
| 4 * others. All Rights Reserved. | 4 * others. All Rights Reserved. |
| 5 ******************************************************************************* | 5 ******************************************************************************* |
| 6 * | 6 * |
| 7 * File DTPTNGEN.CPP | 7 * File DTPTNGEN.CPP |
| 8 * | 8 * |
| 9 ******************************************************************************* | 9 ******************************************************************************* |
| 10 */ | 10 */ |
| 11 | 11 |
| 12 #include "unicode/utypes.h" | 12 #include "unicode/utypes.h" |
| 13 #if !UCONFIG_NO_FORMATTING | 13 #if !UCONFIG_NO_FORMATTING |
| 14 | 14 |
| 15 #include "unicode/datefmt.h" | 15 #include "unicode/datefmt.h" |
| 16 #include "unicode/decimfmt.h" | 16 #include "unicode/decimfmt.h" |
| 17 #include "unicode/dtfmtsym.h" | 17 #include "unicode/dtfmtsym.h" |
| 18 #include "unicode/dtptngen.h" | 18 #include "unicode/dtptngen.h" |
| 19 #include "unicode/msgfmt.h" | 19 #include "unicode/msgfmt.h" |
| 20 #include "unicode/smpdtfmt.h" | 20 #include "unicode/smpdtfmt.h" |
| 21 #include "unicode/udat.h" | 21 #include "unicode/udat.h" |
| 22 #include "unicode/udatpg.h" | 22 #include "unicode/udatpg.h" |
| 23 #include "unicode/uniset.h" | 23 #include "unicode/uniset.h" |
| 24 #include "unicode/uloc.h" | 24 #include "unicode/uloc.h" |
| 25 #include "unicode/ures.h" | 25 #include "unicode/ures.h" |
| 26 #include "unicode/ustring.h" | 26 #include "unicode/ustring.h" |
| 27 #include "unicode/rep.h" | 27 #include "unicode/rep.h" |
| 28 #include "cpputils.h" | 28 #include "cpputils.h" |
| 29 #include "ucln_in.h" | |
| 30 #include "mutex.h" | 29 #include "mutex.h" |
| 31 #include "cmemory.h" | 30 #include "cmemory.h" |
| 32 #include "cstring.h" | 31 #include "cstring.h" |
| 33 #include "locbased.h" | 32 #include "locbased.h" |
| 34 #include "gregoimp.h" | 33 #include "gregoimp.h" |
| 35 #include "hash.h" | 34 #include "hash.h" |
| 36 #include "uresimp.h" | 35 #include "uresimp.h" |
| 37 #include "dtptngen_impl.h" | 36 #include "dtptngen_impl.h" |
| 38 | 37 |
| 39 #define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0])) | |
| 40 | |
| 41 #if U_CHARSET_FAMILY==U_EBCDIC_FAMILY | 38 #if U_CHARSET_FAMILY==U_EBCDIC_FAMILY |
| 42 /** | 39 /** |
| 43 * If we are on EBCDIC, use an iterator which will | 40 * If we are on EBCDIC, use an iterator which will |
| 44 * traverse the bundles in ASCII order. | 41 * traverse the bundles in ASCII order. |
| 45 */ | 42 */ |
| 46 #define U_USE_ASCII_BUNDLE_ITERATOR | 43 #define U_USE_ASCII_BUNDLE_ITERATOR |
| 47 #define U_SORT_ASCII_BUNDLE_ITERATOR | 44 #define U_SORT_ASCII_BUNDLE_ITERATOR |
| 48 #endif | 45 #endif |
| 49 | 46 |
| 50 #if defined(U_USE_ASCII_BUNDLE_ITERATOR) | 47 #if defined(U_USE_ASCII_BUNDLE_ITERATOR) |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 CAP_H, LOW_M, LOW_S, CAP_S, LOW_V, 0 | 134 CAP_H, LOW_M, LOW_S, CAP_S, LOW_V, 0 |
| 138 }; | 135 }; |
| 139 | 136 |
| 140 static const dtTypeElem dtTypes[] = { | 137 static const dtTypeElem dtTypes[] = { |
| 141 // patternChar, field, type, minLen, weight | 138 // patternChar, field, type, minLen, weight |
| 142 {CAP_G, UDATPG_ERA_FIELD, DT_SHORT, 1, 3,}, | 139 {CAP_G, UDATPG_ERA_FIELD, DT_SHORT, 1, 3,}, |
| 143 {CAP_G, UDATPG_ERA_FIELD, DT_LONG, 4, 0}, | 140 {CAP_G, UDATPG_ERA_FIELD, DT_LONG, 4, 0}, |
| 144 {LOW_Y, UDATPG_YEAR_FIELD, DT_NUMERIC, 1, 20}, | 141 {LOW_Y, UDATPG_YEAR_FIELD, DT_NUMERIC, 1, 20}, |
| 145 {CAP_Y, UDATPG_YEAR_FIELD, DT_NUMERIC + DT_DELTA, 1, 20}, | 142 {CAP_Y, UDATPG_YEAR_FIELD, DT_NUMERIC + DT_DELTA, 1, 20}, |
| 146 {LOW_U, UDATPG_YEAR_FIELD, DT_NUMERIC + 2*DT_DELTA, 1, 20}, | 143 {LOW_U, UDATPG_YEAR_FIELD, DT_NUMERIC + 2*DT_DELTA, 1, 20}, |
| 144 {LOW_R, UDATPG_YEAR_FIELD, DT_NUMERIC + 3*DT_DELTA, 1, 20}, |
| 147 {CAP_U, UDATPG_YEAR_FIELD, DT_SHORT, 1, 3}, | 145 {CAP_U, UDATPG_YEAR_FIELD, DT_SHORT, 1, 3}, |
| 148 {CAP_U, UDATPG_YEAR_FIELD, DT_LONG, 4, 0}, | 146 {CAP_U, UDATPG_YEAR_FIELD, DT_LONG, 4, 0}, |
| 149 {CAP_U, UDATPG_YEAR_FIELD, DT_NARROW, 5, 0}, | 147 {CAP_U, UDATPG_YEAR_FIELD, DT_NARROW, 5, 0}, |
| 150 {CAP_Q, UDATPG_QUARTER_FIELD, DT_NUMERIC, 1, 2}, | 148 {CAP_Q, UDATPG_QUARTER_FIELD, DT_NUMERIC, 1, 2}, |
| 151 {CAP_Q, UDATPG_QUARTER_FIELD, DT_SHORT, 3, 0}, | 149 {CAP_Q, UDATPG_QUARTER_FIELD, DT_SHORT, 3, 0}, |
| 152 {CAP_Q, UDATPG_QUARTER_FIELD, DT_LONG, 4, 0}, | 150 {CAP_Q, UDATPG_QUARTER_FIELD, DT_LONG, 4, 0}, |
| 153 {LOW_Q, UDATPG_QUARTER_FIELD, DT_NUMERIC + DT_DELTA, 1, 2}, | 151 {LOW_Q, UDATPG_QUARTER_FIELD, DT_NUMERIC + DT_DELTA, 1, 2}, |
| 154 {LOW_Q, UDATPG_QUARTER_FIELD, DT_SHORT + DT_DELTA, 3, 0}, | 152 {LOW_Q, UDATPG_QUARTER_FIELD, DT_SHORT + DT_DELTA, 3, 0}, |
| 155 {LOW_Q, UDATPG_QUARTER_FIELD, DT_LONG + DT_DELTA, 4, 0}, | 153 {LOW_Q, UDATPG_QUARTER_FIELD, DT_LONG + DT_DELTA, 4, 0}, |
| 156 {CAP_M, UDATPG_MONTH_FIELD, DT_NUMERIC, 1, 2}, | 154 {CAP_M, UDATPG_MONTH_FIELD, DT_NUMERIC, 1, 2}, |
| (...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 503 | 501 |
| 504 void | 502 void |
| 505 DateTimePatternGenerator::addCLDRData(const Locale& locale, UErrorCode& err) { | 503 DateTimePatternGenerator::addCLDRData(const Locale& locale, UErrorCode& err) { |
| 506 UResourceBundle *rb, *calTypeBundle, *calBundle; | 504 UResourceBundle *rb, *calTypeBundle, *calBundle; |
| 507 UResourceBundle *patBundle, *fieldBundle, *fBundle; | 505 UResourceBundle *patBundle, *fieldBundle, *fBundle; |
| 508 UnicodeString rbPattern, value, field; | 506 UnicodeString rbPattern, value, field; |
| 509 UnicodeString conflictingPattern; | 507 UnicodeString conflictingPattern; |
| 510 const char *key=NULL; | 508 const char *key=NULL; |
| 511 int32_t i; | 509 int32_t i; |
| 512 | 510 |
| 513 UnicodeString defaultItemFormat(TRUE, UDATPG_ItemFormat, LENGTHOF(UDATPG_Ite
mFormat)-1); // Read-only alias. | 511 UnicodeString defaultItemFormat(TRUE, UDATPG_ItemFormat, UPRV_LENGTHOF(UDATP
G_ItemFormat)-1); // Read-only alias. |
| 514 | 512 |
| 515 err = U_ZERO_ERROR; | 513 err = U_ZERO_ERROR; |
| 516 | 514 |
| 517 fDefaultHourFormatChar = 0; | 515 fDefaultHourFormatChar = 0; |
| 518 for (i=0; i<UDATPG_FIELD_COUNT; ++i ) { | 516 for (i=0; i<UDATPG_FIELD_COUNT; ++i ) { |
| 519 appendItemNames[i]=CAP_F; | 517 appendItemNames[i]=CAP_F; |
| 520 if (i<10) { | 518 if (i<10) { |
| 521 appendItemNames[i]+=(UChar)(i+0x30); | 519 appendItemNames[i]+=(UChar)(i+0x30); |
| 522 } | 520 } |
| 523 else { | 521 else { |
| (...skipping 1686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2210 } | 2208 } |
| 2211 delete fPatterns; | 2209 delete fPatterns; |
| 2212 } | 2210 } |
| 2213 | 2211 |
| 2214 U_NAMESPACE_END | 2212 U_NAMESPACE_END |
| 2215 | 2213 |
| 2216 | 2214 |
| 2217 #endif /* #if !UCONFIG_NO_FORMATTING */ | 2215 #endif /* #if !UCONFIG_NO_FORMATTING */ |
| 2218 | 2216 |
| 2219 //eof | 2217 //eof |
| OLD | NEW |