ICU 69.1 69.1

dtfmtsym.h
Go to the documentation of this file.
1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
3 /*
4 ********************************************************************************
5 * Copyright (C) 1997-2016, International Business Machines
6 * Corporation and others. All Rights Reserved.
7 ********************************************************************************
8 *
9 * File DTFMTSYM.H
10 *
11 * Modification History:
12 *
13 * Date Name Description
14 * 02/19/97 aliu Converted from java.
15 * 07/21/98 stephen Added getZoneIndex()
16 * Changed to match C++ conventions
17 ********************************************************************************
18 */
19
20 #ifndef DTFMTSYM_H
21 #define DTFMTSYM_H
22
23 #include "unicode/utypes.h"
24
25 #if U_SHOW_CPLUSPLUS_API
26
27 #if !UCONFIG_NO_FORMATTING
28
29 #include "unicode/calendar.h"
30 #include "unicode/strenum.h"
31 #include "unicode/uobject.h"
32 #include "unicode/locid.h"
33 #include "unicode/udat.h"
34 #include "unicode/ures.h"
35
41 U_NAMESPACE_BEGIN
42
43 /* forward declaration */
44 class SimpleDateFormat;
45 class Hashtable;
46
84 class U_I18N_API DateFormatSymbols U_FINAL : public UObject {
85 public:
99 DateFormatSymbols(UErrorCode& status);
100
111 DateFormatSymbols(const Locale& locale,
112 UErrorCode& status);
113
114 #ifndef U_HIDE_INTERNAL_API
115
131 DateFormatSymbols(const char *type, UErrorCode& status);
132
146 DateFormatSymbols(const Locale& locale,
147 const char *type,
148 UErrorCode& status);
149 #endif /* U_HIDE_INTERNAL_API */
150
155 DateFormatSymbols(const DateFormatSymbols&);
156
161 DateFormatSymbols& operator=(const DateFormatSymbols&);
162
168 virtual ~DateFormatSymbols();
169
177 UBool operator==(const DateFormatSymbols& other) const;
178
186 UBool operator!=(const DateFormatSymbols& other) const { return !operator==(other); }
187
195 const UnicodeString* getEras(int32_t& count) const;
196
203 void setEras(const UnicodeString* eras, int32_t count);
204
212 const UnicodeString* getEraNames(int32_t& count) const;
213
220 void setEraNames(const UnicodeString* eraNames, int32_t count);
221
229 const UnicodeString* getNarrowEras(int32_t& count) const;
230
237 void setNarrowEras(const UnicodeString* narrowEras, int32_t count);
238
245 const UnicodeString* getMonths(int32_t& count) const;
246
254 void setMonths(const UnicodeString* months, int32_t count);
255
263 const UnicodeString* getShortMonths(int32_t& count) const;
264
271 void setShortMonths(const UnicodeString* shortMonths, int32_t count);
272
277 enum DtContextType {
278 FORMAT,
279 STANDALONE,
280 #ifndef U_HIDE_DEPRECATED_API
281
285 DT_CONTEXT_COUNT
286 #endif // U_HIDE_DEPRECATED_API
287 };
288
293 enum DtWidthType {
294 ABBREVIATED,
295 WIDE,
296 NARROW,
301 SHORT,
302 #ifndef U_HIDE_DEPRECATED_API
303
307 DT_WIDTH_COUNT = 4
308 #endif // U_HIDE_DEPRECATED_API
309 };
310
319 const UnicodeString* getMonths(int32_t& count, DtContextType context, DtWidthType width) const;
320
330 void setMonths(const UnicodeString* months, int32_t count, DtContextType context, DtWidthType width);
331
338 const UnicodeString* getWeekdays(int32_t& count) const;
339
340
347 void setWeekdays(const UnicodeString* weekdays, int32_t count);
348
356 const UnicodeString* getShortWeekdays(int32_t& count) const;
357
365 void setShortWeekdays(const UnicodeString* abbrevWeekdays, int32_t count);
366
375 const UnicodeString* getWeekdays(int32_t& count, DtContextType context, DtWidthType width) const;
376
385 void setWeekdays(const UnicodeString* weekdays, int32_t count, DtContextType context, DtWidthType width);
386
396 const UnicodeString* getQuarters(int32_t& count, DtContextType context, DtWidthType width) const;
397
408 void setQuarters(const UnicodeString* quarters, int32_t count, DtContextType context, DtWidthType width);
409
416 const UnicodeString* getAmPmStrings(int32_t& count) const;
417
424 void setAmPmStrings(const UnicodeString* ampms, int32_t count);
425
426 #ifndef U_HIDE_INTERNAL_API
427
432 static const char16_t DEFAULT_TIME_SEPARATOR = 0x003a; // ':'
433
438 static const char16_t ALTERNATE_TIME_SEPARATOR = 0x002e; // '.'
439
446 UnicodeString& getTimeSeparatorString(UnicodeString& result) const;
447
453 void setTimeSeparatorString(const UnicodeString& newTimeSeparator);
454 #endif /* U_HIDE_INTERNAL_API */
455
466 const UnicodeString* getYearNames(int32_t& count,
467 DtContextType context, DtWidthType width) const;
468
478 void setYearNames(const UnicodeString* yearNames, int32_t count,
479 DtContextType context, DtWidthType width);
480
491 const UnicodeString* getZodiacNames(int32_t& count,
492 DtContextType context, DtWidthType width) const;
493
503 void setZodiacNames(const UnicodeString* zodiacNames, int32_t count,
504 DtContextType context, DtWidthType width);
505
506 #ifndef U_HIDE_INTERNAL_API
507
515 enum EMonthPatternType
516 {
517 kLeapMonthPatternFormatWide,
518 kLeapMonthPatternFormatAbbrev,
519 kLeapMonthPatternFormatNarrow,
520 kLeapMonthPatternStandaloneWide,
521 kLeapMonthPatternStandaloneAbbrev,
522 kLeapMonthPatternStandaloneNarrow,
523 kLeapMonthPatternNumeric,
524 kMonthPatternsCount
525 };
526
539 const UnicodeString* getLeapMonthPatterns(int32_t& count) const;
540
541 #endif /* U_HIDE_INTERNAL_API */
542
543 #ifndef U_HIDE_DEPRECATED_API
544
551 const UnicodeString** getZoneStrings(int32_t& rowCount, int32_t& columnCount) const;
552 #endif /* U_HIDE_DEPRECATED_API */
553
565 void setZoneStrings(const UnicodeString* const* strings, int32_t rowCount, int32_t columnCount);
566
572 static const char16_t * U_EXPORT2 getPatternUChars(void);
573
584 UnicodeString& getLocalPatternChars(UnicodeString& result) const;
585
592 void setLocalPatternChars(const UnicodeString& newLocalPatternChars);
593
599 Locale getLocale(ULocDataLocaleType type, UErrorCode& status) const;
600
601 /* The following type and kCapContextUsageTypeCount cannot be #ifndef U_HIDE_INTERNAL_API,
602 they are needed for .h file declarations. */
607 enum ECapitalizationContextUsageType
608 {
609 #ifndef U_HIDE_INTERNAL_API
610 kCapContextUsageOther = 0,
611 kCapContextUsageMonthFormat, /* except narrow */
612 kCapContextUsageMonthStandalone, /* except narrow */
613 kCapContextUsageMonthNarrow,
614 kCapContextUsageDayFormat, /* except narrow */
615 kCapContextUsageDayStandalone, /* except narrow */
616 kCapContextUsageDayNarrow,
617 kCapContextUsageEraWide,
618 kCapContextUsageEraAbbrev,
619 kCapContextUsageEraNarrow,
620 kCapContextUsageZoneLong,
621 kCapContextUsageZoneShort,
622 kCapContextUsageMetazoneLong,
623 kCapContextUsageMetazoneShort,
624 #endif /* U_HIDE_INTERNAL_API */
625 kCapContextUsageTypeCount = 14
626 };
627
633 virtual UClassID getDynamicClassID() const;
634
640 static UClassID U_EXPORT2 getStaticClassID();
641
642 private:
643
644 friend class SimpleDateFormat;
645 friend class DateFormatSymbolsSingleSetter; // see udat.cpp
646
650 UnicodeString* fEras;
651 int32_t fErasCount;
652
656 UnicodeString* fEraNames;
657 int32_t fEraNamesCount;
658
662 UnicodeString* fNarrowEras;
663 int32_t fNarrowErasCount;
664
668 UnicodeString* fMonths;
669 int32_t fMonthsCount;
670
674 UnicodeString* fShortMonths;
675 int32_t fShortMonthsCount;
676
680 UnicodeString* fNarrowMonths;
681 int32_t fNarrowMonthsCount;
682
686 UnicodeString* fStandaloneMonths;
687 int32_t fStandaloneMonthsCount;
688
692 UnicodeString* fStandaloneShortMonths;
693 int32_t fStandaloneShortMonthsCount;
694
698 UnicodeString* fStandaloneNarrowMonths;
699 int32_t fStandaloneNarrowMonthsCount;
700
704 UnicodeString* fWeekdays;
705 int32_t fWeekdaysCount;
706
710 UnicodeString* fShortWeekdays;
711 int32_t fShortWeekdaysCount;
712
716 UnicodeString* fShorterWeekdays;
717 int32_t fShorterWeekdaysCount;
718
722 UnicodeString* fNarrowWeekdays;
723 int32_t fNarrowWeekdaysCount;
724
728 UnicodeString* fStandaloneWeekdays;
729 int32_t fStandaloneWeekdaysCount;
730
734 UnicodeString* fStandaloneShortWeekdays;
735 int32_t fStandaloneShortWeekdaysCount;
736
740 UnicodeString* fStandaloneShorterWeekdays;
741 int32_t fStandaloneShorterWeekdaysCount;
742
746 UnicodeString* fStandaloneNarrowWeekdays;
747 int32_t fStandaloneNarrowWeekdaysCount;
748
752 UnicodeString* fAmPms;
753 int32_t fAmPmsCount;
754
758 UnicodeString* fNarrowAmPms;
759 int32_t fNarrowAmPmsCount;
760
764 UnicodeString fTimeSeparator;
765
769 UnicodeString *fQuarters;
770 int32_t fQuartersCount;
771
775 UnicodeString *fShortQuarters;
776 int32_t fShortQuartersCount;
777
781 UnicodeString *fStandaloneQuarters;
782 int32_t fStandaloneQuartersCount;
783
787 UnicodeString *fStandaloneShortQuarters;
788 int32_t fStandaloneShortQuartersCount;
789
793 UnicodeString *fLeapMonthPatterns;
794 int32_t fLeapMonthPatternsCount;
795
801 UnicodeString *fShortYearNames;
802 int32_t fShortYearNamesCount;
803
809 UnicodeString *fShortZodiacNames;
810 int32_t fShortZodiacNamesCount;
811
849 UnicodeString **fZoneStrings; // Zone string array set by setZoneStrings
850 UnicodeString **fLocaleZoneStrings; // Zone string array created by the locale
851 int32_t fZoneStringsRowCount;
852 int32_t fZoneStringsColCount;
853
854 Locale fZSFLocale; // Locale used for getting ZoneStringFormat
855
859 UnicodeString fLocalPatternChars;
860
866 UBool fCapitalization[kCapContextUsageTypeCount][2];
867
871 UnicodeString *fAbbreviatedDayPeriods;
872 int32_t fAbbreviatedDayPeriodsCount;
873
877 UnicodeString *fWideDayPeriods;
878 int32_t fWideDayPeriodsCount;
879
883 UnicodeString *fNarrowDayPeriods;
884 int32_t fNarrowDayPeriodsCount;
885
889 UnicodeString *fStandaloneAbbreviatedDayPeriods;
890 int32_t fStandaloneAbbreviatedDayPeriodsCount;
891
895 UnicodeString *fStandaloneWideDayPeriods;
896 int32_t fStandaloneWideDayPeriodsCount;
897
901 UnicodeString *fStandaloneNarrowDayPeriods;
902 int32_t fStandaloneNarrowDayPeriodsCount;
903
904 private:
908 char validLocale[ULOC_FULLNAME_CAPACITY];
909 char actualLocale[ULOC_FULLNAME_CAPACITY];
910
911 DateFormatSymbols(); // default constructor not implemented
912
922 void initializeData(const Locale& locale, const char *type,
923 UErrorCode& status, UBool useLastResortData = false);
924
933 static void assignArray(UnicodeString*& dstArray,
934 int32_t& dstCount,
935 const UnicodeString* srcArray,
936 int32_t srcCount);
937
948 static UBool arrayCompare(const UnicodeString* array1,
949 const UnicodeString* array2,
950 int32_t count);
951
957 void createZoneStrings(const UnicodeString *const * otherStrings);
958
962 void dispose(void);
963
968 void copyData(const DateFormatSymbols& other);
969
973 void initZoneStringsArray(void);
974
978 void disposeZoneStrings(void);
979
984 static UDateFormatField U_EXPORT2 getPatternCharIndex(char16_t c);
985
989 static UBool U_EXPORT2 isNumericField(UDateFormatField f, int32_t count);
990
994 static UBool U_EXPORT2 isNumericPatternChar(char16_t c, int32_t count);
995 public:
996 #ifndef U_HIDE_INTERNAL_API
997
1008 static DateFormatSymbols * U_EXPORT2 createForLocale(
1009 const Locale &locale, UErrorCode &status);
1010 #endif /* U_HIDE_INTERNAL_API */
1011 };
1012
1013 U_NAMESPACE_END
1014
1015 #endif /* #if !UCONFIG_NO_FORMATTING */
1016
1017 #endif /* U_SHOW_CPLUSPLUS_API */
1018
1019 #endif // _DTFMTSYM
1020 //eof
U_FINAL
#define U_FINAL
Definition: umachine.h:141
UDateFormatField
UDateFormatField
FieldPosition and UFieldPosition selectors for format fields defined by DateFormat and UDateFormat.
Definition: udat.h:515
icu::DateFormatSymbols::ECapitalizationContextUsageType
ECapitalizationContextUsageType
Constants for capitalization context usage types.
Definition: dtfmtsym.h:607
icu::DateFormatSymbols::EMonthPatternType
EMonthPatternType
Somewhat temporary constants for leap month pattern types, adequate for supporting just leap month pa...
Definition: dtfmtsym.h:515
utypes.h
Basic definitions for ICU, for both C and C++ APIs.
U_I18N_API
#define U_I18N_API
Definition: utypes.h:301
UBool
int8_t UBool
The ICU boolean type, a signed-byte integer.
Definition: umachine.h:269
ULocDataLocaleType
ULocDataLocaleType
Constants for *_getLocale() Allow user to select whether she wants information on requested,...
Definition: uloc.h:338
icu::operator==
U_EXPORT UBool operator==(const StringPiece &x, const StringPiece &y)
Global operator == for StringPiece.
icu::DateFormatSymbols::DtContextType
DtContextType
Selector for date formatting context.
Definition: dtfmtsym.h:277
icu::SimpleDateFormat
SimpleDateFormat is a concrete class for formatting and parsing dates in a language-independent manne...
Definition: smpdtfmt.h:726
icu::DateFormatSymbols::DtWidthType
DtWidthType
Selector for date formatting width.
Definition: dtfmtsym.h:293
ures.h
C API: Resource Bundle.
icu::UnicodeString
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition: unistr.h:295
icu::UObject
UObject is the common ICU "boilerplate" class.
Definition: uobject.h:223
icu::DateFormatSymbols::operator!=
UBool operator!=(const DateFormatSymbols &other) const
Return true if another object is semantically unequal to this one.
Definition: dtfmtsym.h:186
UClassID
void * UClassID
UClassID is used to identify classes without using the compiler's RTTI.
Definition: uobject.h:96
UErrorCode
UErrorCode
Standard ICU4C error code type, a substitute for exceptions.
Definition: utypes.h:415
icu::UObject::getDynamicClassID
virtual UClassID getDynamicClassID() const
ICU4C "poor man's RTTI", returns a UClassID for the actual ICU class.
icu::DateFormatSymbols::SHORT
@ SHORT
Short width is currently only supported for weekday names.
Definition: dtfmtsym.h:301
calendar.h
C++ API: Calendar object.
ULOC_FULLNAME_CAPACITY
#define ULOC_FULLNAME_CAPACITY
Useful constant for the maximum size of the whole locale ID (including the terminating NULL and all k...
Definition: uloc.h:264
icu::DateFormatSymbols
DateFormatSymbols is a public class for encapsulating localizable date-time formatting data – includi...
Definition: dtfmtsym.h:84
strenum.h
C++ API: String Enumeration.
locid.h
C++ API: Locale ID object.
uobject.h
C++ API: Common ICU base class UObject.
udat.h
C API: DateFormat.
icu::Locale
A Locale object represents a specific geographical, political, or cultural region.
Definition: locid.h:195