ICU 55.1 55.1

- Main Page
- Related Pages
- Modules
- Namespaces
- Data Structures
- Files

- File List
- Globals

All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
dtfmtsym.h
Go to the documentation of this file.
1 /*
2 ********************************************************************************
3 * Copyright (C) 1997-2015, International Business Machines
4 * Corporation and others. All Rights Reserved.
5 ********************************************************************************
6 *
7 * File DTFMTSYM.H
8 *
9 * Modification History:
10 *
11 * Date Name Description
12 * 02/19/97 aliu Converted from java.
13 * 07/21/98 stephen Added getZoneIndex()
14 * Changed to match C++ conventions
15 ********************************************************************************
16 */
17
18 #ifndef DTFMTSYM_H
19 #define DTFMTSYM_H
20
21 #include "unicode/utypes.h"
22
23 #if !UCONFIG_NO_FORMATTING
24
25 #include "unicode/calendar.h"
26 #include "unicode/uobject.h"
27 #include "unicode/locid.h"
28 #include "unicode/udat.h"
29 #include "unicode/ures.h"
30
36 U_NAMESPACE_BEGIN
37
38 /* forward declaration */
39 class SimpleDateFormat;
40 class Hashtable;
41
79 class U_I18N_API DateFormatSymbols U_FINAL : public UObject {
80 public:
94 DateFormatSymbols(UErrorCode& status);
95
106 DateFormatSymbols(const Locale& locale,
107 UErrorCode& status);
108
109 #ifndef U_HIDE_INTERNAL_API
110
126 DateFormatSymbols(const char *type, UErrorCode& status);
127
141 DateFormatSymbols(const Locale& locale,
142 const char *type,
143 UErrorCode& status);
144 #endif /* U_HIDE_INTERNAL_API */
145
150 DateFormatSymbols(const DateFormatSymbols&);
151
156 DateFormatSymbols& operator=(const DateFormatSymbols&);
157
163 virtual ~DateFormatSymbols();
164
172 UBool operator==(const DateFormatSymbols& other) const;
173
181 UBool operator!=(const DateFormatSymbols& other) const { return !operator==(other); }
182
190 const UnicodeString* getEras(int32_t& count) const;
191
198 void setEras(const UnicodeString* eras, int32_t count);
199
207 const UnicodeString* getEraNames(int32_t& count) const;
208
215 void setEraNames(const UnicodeString* eraNames, int32_t count);
216
224 const UnicodeString* getNarrowEras(int32_t& count) const;
225
232 void setNarrowEras(const UnicodeString* narrowEras, int32_t count);
233
240 const UnicodeString* getMonths(int32_t& count) const;
241
249 void setMonths(const UnicodeString* months, int32_t count);
250
258 const UnicodeString* getShortMonths(int32_t& count) const;
259
266 void setShortMonths(const UnicodeString* shortMonths, int32_t count);
267
272 enum DtContextType {
273 FORMAT,
274 STANDALONE,
275 DT_CONTEXT_COUNT
276 };
277
282 enum DtWidthType {
283 ABBREVIATED,
284 WIDE,
285 NARROW,
290 SHORT,
293 DT_WIDTH_COUNT = 4
294 };
295
304 const UnicodeString* getMonths(int32_t& count, DtContextType context, DtWidthType width) const;
305
315 void setMonths(const UnicodeString* months, int32_t count, DtContextType context, DtWidthType width);
316
323 const UnicodeString* getWeekdays(int32_t& count) const;
324
325
332 void setWeekdays(const UnicodeString* weekdays, int32_t count);
333
341 const UnicodeString* getShortWeekdays(int32_t& count) const;
342
350 void setShortWeekdays(const UnicodeString* abbrevWeekdays, int32_t count);
351
360 const UnicodeString* getWeekdays(int32_t& count, DtContextType context, DtWidthType width) const;
361
370 void setWeekdays(const UnicodeString* weekdays, int32_t count, DtContextType context, DtWidthType width);
371
381 const UnicodeString* getQuarters(int32_t& count, DtContextType context, DtWidthType width) const;
382
393 void setQuarters(const UnicodeString* quarters, int32_t count, DtContextType context, DtWidthType width);
394
401 const UnicodeString* getAmPmStrings(int32_t& count) const;
402
409 void setAmPmStrings(const UnicodeString* ampms, int32_t count);
410
411 #ifndef U_HIDE_INTERNAL_API
412
417 static const UChar DEFAULT_TIME_SEPARATOR = 0x003a; // ':'
418
423 static const UChar ALTERNATE_TIME_SEPARATOR = 0x002e; // '.'
424 #endif /* U_HIDE_INTERNAL_API */
425
426 #ifndef U_HIDE_DRAFT_API
427
433 UnicodeString& getTimeSeparatorString(UnicodeString& result) const;
434
440 void setTimeSeparatorString(const UnicodeString& newTimeSeparator);
441 #endif /* U_HIDE_DRAFT_API */
442
443 #ifndef U_HIDE_DRAFT_API
444
454 const UnicodeString* getYearNames(int32_t& count,
455 DtContextType context, DtWidthType width) const;
456
466 void setYearNames(const UnicodeString* yearNames, int32_t count,
467 DtContextType context, DtWidthType width);
468
479 const UnicodeString* getZodiacNames(int32_t& count,
480 DtContextType context, DtWidthType width) const;
481
491 void setZodiacNames(const UnicodeString* zodiacNames, int32_t count,
492 DtContextType context, DtWidthType width);
493
494 #endif /* U_HIDE_DRAFT_API */
495
496 #ifndef U_HIDE_INTERNAL_API
497
505 enum EMonthPatternType
506 {
507 kLeapMonthPatternFormatWide,
508 kLeapMonthPatternFormatAbbrev,
509 kLeapMonthPatternFormatNarrow,
510 kLeapMonthPatternStandaloneWide,
511 kLeapMonthPatternStandaloneAbbrev,
512 kLeapMonthPatternStandaloneNarrow,
513 kLeapMonthPatternNumeric,
514 kMonthPatternsCount
515 };
516
529 const UnicodeString* getLeapMonthPatterns(int32_t& count) const;
530
531 #endif /* U_HIDE_INTERNAL_API */
532
533 #ifndef U_HIDE_DEPRECATED_API
534
541 const UnicodeString** getZoneStrings(int32_t& rowCount, int32_t& columnCount) const;
542 #endif /* U_HIDE_DEPRECATED_API */
543
555 void setZoneStrings(const UnicodeString* const* strings, int32_t rowCount, int32_t columnCount);
556
562 static const UChar * U_EXPORT2 getPatternUChars(void);
563
574 UnicodeString& getLocalPatternChars(UnicodeString& result) const;
575
582 void setLocalPatternChars(const UnicodeString& newLocalPatternChars);
583
589 Locale getLocale(ULocDataLocaleType type, UErrorCode& status) const;
590
591 /* The following type and kCapContextUsageTypeCount cannot be #ifndef U_HIDE_INTERNAL_API,
592 they are needed for .h file declarations. */
597 enum ECapitalizationContextUsageType
598 {
599 #ifndef U_HIDE_INTERNAL_API
600 kCapContextUsageOther = 0,
601 kCapContextUsageMonthFormat, /* except narrow */
602 kCapContextUsageMonthStandalone, /* except narrow */
603 kCapContextUsageMonthNarrow,
604 kCapContextUsageDayFormat, /* except narrow */
605 kCapContextUsageDayStandalone, /* except narrow */
606 kCapContextUsageDayNarrow,
607 kCapContextUsageEraWide,
608 kCapContextUsageEraAbbrev,
609 kCapContextUsageEraNarrow,
610 kCapContextUsageZoneLong,
611 kCapContextUsageZoneShort,
612 kCapContextUsageMetazoneLong,
613 kCapContextUsageMetazoneShort,
614 #endif /* U_HIDE_INTERNAL_API */
615 kCapContextUsageTypeCount = 14
616 };
617
623 virtual UClassID getDynamicClassID() const;
624
630 static UClassID U_EXPORT2 getStaticClassID();
631
632 private:
633
634 friend class SimpleDateFormat;
635 friend class DateFormatSymbolsSingleSetter; // see udat.cpp
636
640 UnicodeString* fEras;
641 int32_t fErasCount;
642
646 UnicodeString* fEraNames;
647 int32_t fEraNamesCount;
648
652 UnicodeString* fNarrowEras;
653 int32_t fNarrowErasCount;
654
658 UnicodeString* fMonths;
659 int32_t fMonthsCount;
660
664 UnicodeString* fShortMonths;
665 int32_t fShortMonthsCount;
666
670 UnicodeString* fNarrowMonths;
671 int32_t fNarrowMonthsCount;
672
676 UnicodeString* fStandaloneMonths;
677 int32_t fStandaloneMonthsCount;
678
682 UnicodeString* fStandaloneShortMonths;
683 int32_t fStandaloneShortMonthsCount;
684
688 UnicodeString* fStandaloneNarrowMonths;
689 int32_t fStandaloneNarrowMonthsCount;
690
694 UnicodeString* fWeekdays;
695 int32_t fWeekdaysCount;
696
700 UnicodeString* fShortWeekdays;
701 int32_t fShortWeekdaysCount;
702
706 UnicodeString* fShorterWeekdays;
707 int32_t fShorterWeekdaysCount;
708
712 UnicodeString* fNarrowWeekdays;
713 int32_t fNarrowWeekdaysCount;
714
718 UnicodeString* fStandaloneWeekdays;
719 int32_t fStandaloneWeekdaysCount;
720
724 UnicodeString* fStandaloneShortWeekdays;
725 int32_t fStandaloneShortWeekdaysCount;
726
730 UnicodeString* fStandaloneShorterWeekdays;
731 int32_t fStandaloneShorterWeekdaysCount;
732
736 UnicodeString* fStandaloneNarrowWeekdays;
737 int32_t fStandaloneNarrowWeekdaysCount;
738
742 UnicodeString* fAmPms;
743 int32_t fAmPmsCount;
744
748 UnicodeString* fNarrowAmPms;
749 int32_t fNarrowAmPmsCount;
750
754 UnicodeString fTimeSeparator;
755
759 UnicodeString *fQuarters;
760 int32_t fQuartersCount;
761
765 UnicodeString *fShortQuarters;
766 int32_t fShortQuartersCount;
767
771 UnicodeString *fStandaloneQuarters;
772 int32_t fStandaloneQuartersCount;
773
777 UnicodeString *fStandaloneShortQuarters;
778 int32_t fStandaloneShortQuartersCount;
779
783 UnicodeString *fLeapMonthPatterns;
784 int32_t fLeapMonthPatternsCount;
785
791 UnicodeString *fShortYearNames;
792 int32_t fShortYearNamesCount;
793
799 UnicodeString *fShortZodiacNames;
800 int32_t fShortZodiacNamesCount;
801
839 UnicodeString **fZoneStrings; // Zone string array set by setZoneStrings
840 UnicodeString **fLocaleZoneStrings; // Zone string array created by the locale
841 int32_t fZoneStringsRowCount;
842 int32_t fZoneStringsColCount;
843
844 Locale fZSFLocale; // Locale used for getting ZoneStringFormat
845
849 UnicodeString fLocalPatternChars;
850
856 UBool fCapitalization[kCapContextUsageTypeCount][2];
857
858 private:
862 char validLocale[ULOC_FULLNAME_CAPACITY];
863 char actualLocale[ULOC_FULLNAME_CAPACITY];
864
865 DateFormatSymbols(); // default constructor not implemented
866
876 void initializeData(const Locale& locale, const char *type, UErrorCode& status, UBool useLastResortData = FALSE);
877
886 static void assignArray(UnicodeString*& dstArray,
887 int32_t& dstCount,
888 const UnicodeString* srcArray,
889 int32_t srcCount);
890
901 static UBool arrayCompare(const UnicodeString* array1,
902 const UnicodeString* array2,
903 int32_t count);
904
910 void createZoneStrings(const UnicodeString *const * otherStrings);
911
915 void dispose(void);
916
921 void copyData(const DateFormatSymbols& other);
922
926 void initZoneStringsArray(void);
927
931 void disposeZoneStrings(void);
932
937 static UDateFormatField U_EXPORT2 getPatternCharIndex(UChar c);
938
942 static UBool U_EXPORT2 isNumericField(UDateFormatField f, int32_t count);
943
947 static UBool U_EXPORT2 isNumericPatternChar(UChar c, int32_t count);
948 public:
949 #ifndef U_HIDE_INTERNAL_API
950
961 static DateFormatSymbols * U_EXPORT2 createForLocale(
962 const Locale &locale, UErrorCode &status);
963 #endif /* U_HIDE_INTERNAL_API */
964 };
965
966 U_NAMESPACE_END
967
968 #endif /* #if !UCONFIG_NO_FORMATTING */
969
970 #endif // _DTFMTSYM
971 //eof