ICU4C 79
Loading...
Searching...
No Matches
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
41U_NAMESPACE_BEGIN
42
43/* forward declaration */
44class SimpleDateFormat;
45class Hashtable;
46
85public:
100
112
113#ifndef U_HIDE_INTERNAL_API
131
145 U_I18N_API DateFormatSymbols(const Locale& locale, const char* type, UErrorCode& status);
146#endif /* U_HIDE_INTERNAL_API */
147
153
159
166
175
184
193
201
210
218
227
235
243
252
261
269
275 FORMAT,
276 STANDALONE,
277#ifndef U_HIDE_DEPRECATED_API
282 DT_CONTEXT_COUNT
283#endif // U_HIDE_DEPRECATED_API
284 };
285
291 ABBREVIATED,
292 WIDE,
293 NARROW,
299#ifndef U_HIDE_DEPRECATED_API
304 DT_WIDTH_COUNT = 4
305#endif // U_HIDE_DEPRECATED_API
306 };
307
317 DtContextType context,
318 DtWidthType width) const;
319
330 int32_t count,
331 DtContextType context,
333
341
349
358
367
377 DtContextType context,
378 DtWidthType width) const;
379
389 int32_t count,
390 DtContextType context,
392
402 DtContextType context,
403 DtWidthType width) const;
404
415 int32_t count,
416 DtContextType context,
418
426
434
435#ifndef U_HIDE_DRAFT_API
445 DtContextType context,
446 DtWidthType width) const;
447
457 int32_t count,
458 DtContextType context,
460#endif /* U_HIDE_DRAFT_API */
461
462#ifndef U_HIDE_INTERNAL_API
476 DtWidthType width) const;
477
492 DtContextType context,
493 DtWidthType width) const;
494#endif /* U_HIDE_INTERNAL_API */
495
496#ifndef U_HIDE_INTERNAL_API
502 U_I18N_API static const char16_t DEFAULT_TIME_SEPARATOR = 0x003a; // ':'
503
508 U_I18N_API static const char16_t ALTERNATE_TIME_SEPARATOR = 0x002e; // '.'
509
517
524#endif /* U_HIDE_INTERNAL_API */
525
537 DtContextType context,
538 DtWidthType width) const;
539
550 int32_t count,
551 DtContextType context,
553
565 DtContextType context,
566 DtWidthType width) const;
567
578 int32_t count,
579 DtContextType context,
581
582#ifndef U_HIDE_INTERNAL_API
592 {
593 kLeapMonthPatternFormatWide,
594 kLeapMonthPatternFormatAbbrev,
595 kLeapMonthPatternFormatNarrow,
596 kLeapMonthPatternStandaloneWide,
597 kLeapMonthPatternStandaloneAbbrev,
598 kLeapMonthPatternStandaloneNarrow,
599 kLeapMonthPatternNumeric,
600 kMonthPatternsCount
601 };
602
616
617#endif /* U_HIDE_INTERNAL_API */
618
619#ifndef U_HIDE_DEPRECATED_API
628#endif /* U_HIDE_DEPRECATED_API */
629
641 U_I18N_API void setZoneStrings(const UnicodeString* const* strings,
644
650 U_I18N_API static const char16_t* getPatternUChars();
651
663
671
678
679 /* The following type and kCapContextUsageTypeCount cannot be #ifndef U_HIDE_INTERNAL_API,
680 they are needed for .h file declarations. */
686 {
687#ifndef U_HIDE_INTERNAL_API
688 kCapContextUsageOther = 0,
689 kCapContextUsageMonthFormat, /* except narrow */
690 kCapContextUsageMonthStandalone, /* except narrow */
691 kCapContextUsageMonthNarrow,
692 kCapContextUsageDayFormat, /* except narrow */
693 kCapContextUsageDayStandalone, /* except narrow */
694 kCapContextUsageDayNarrow,
695 kCapContextUsageEraWide,
696 kCapContextUsageEraAbbrev,
697 kCapContextUsageEraNarrow,
698 kCapContextUsageZoneLong,
699 kCapContextUsageZoneShort,
700 kCapContextUsageMetazoneLong,
701 kCapContextUsageMetazoneShort,
702#endif /* U_HIDE_INTERNAL_API */
703 kCapContextUsageTypeCount = 14
704 };
705
711 U_I18N_API virtual UClassID getDynamicClassID() const override;
712
719
720private:
721
722 friend class SimpleDateFormat;
723 friend class DateFormatSymbolsSingleSetter; // see udat.cpp
724
728 UnicodeString* fEras;
729 int32_t fErasCount;
730
734 UnicodeString* fEraNames;
735 int32_t fEraNamesCount;
736
740 UnicodeString* fNarrowEras;
741 int32_t fNarrowErasCount;
742
746 UnicodeString* fMonths;
747 int32_t fMonthsCount;
748
752 UnicodeString* fShortMonths;
753 int32_t fShortMonthsCount;
754
758 UnicodeString* fNarrowMonths;
759 int32_t fNarrowMonthsCount;
760
764 UnicodeString* fStandaloneMonths;
765 int32_t fStandaloneMonthsCount;
766
770 UnicodeString* fStandaloneShortMonths;
771 int32_t fStandaloneShortMonthsCount;
772
776 UnicodeString* fStandaloneNarrowMonths;
777 int32_t fStandaloneNarrowMonthsCount;
778
782 UnicodeString* fWeekdays;
783 int32_t fWeekdaysCount;
784
788 UnicodeString* fShortWeekdays;
789 int32_t fShortWeekdaysCount;
790
794 UnicodeString* fShorterWeekdays;
795 int32_t fShorterWeekdaysCount;
796
800 UnicodeString* fNarrowWeekdays;
801 int32_t fNarrowWeekdaysCount;
802
806 UnicodeString* fStandaloneWeekdays;
807 int32_t fStandaloneWeekdaysCount;
808
812 UnicodeString* fStandaloneShortWeekdays;
813 int32_t fStandaloneShortWeekdaysCount;
814
818 UnicodeString* fStandaloneShorterWeekdays;
819 int32_t fStandaloneShorterWeekdaysCount;
820
824 UnicodeString* fStandaloneNarrowWeekdays;
825 int32_t fStandaloneNarrowWeekdaysCount;
826
830 UnicodeString* fAmPms;
831 int32_t fAmPmsCount;
832
837 UnicodeString* fWideAmPms;
838 int32_t fWideAmPmsCount;
839
843 UnicodeString* fNarrowAmPms;
844 int32_t fNarrowAmPmsCount;
845
849 UnicodeString fTimeSeparator;
850
854 UnicodeString *fQuarters;
855 int32_t fQuartersCount;
856
860 UnicodeString *fShortQuarters;
861 int32_t fShortQuartersCount;
862
867 UnicodeString *fNarrowQuarters;
868 int32_t fNarrowQuartersCount;
869
873 UnicodeString *fStandaloneQuarters;
874 int32_t fStandaloneQuartersCount;
875
879 UnicodeString *fStandaloneShortQuarters;
880 int32_t fStandaloneShortQuartersCount;
881
886 UnicodeString *fStandaloneNarrowQuarters;
887 int32_t fStandaloneNarrowQuartersCount;
888
892 UnicodeString *fLeapMonthPatterns;
893 int32_t fLeapMonthPatternsCount;
894
900 UnicodeString *fShortYearNames;
901 int32_t fShortYearNamesCount;
902
908 UnicodeString *fShortZodiacNames;
909 int32_t fShortZodiacNamesCount;
910
948 UnicodeString **fZoneStrings; // Zone string array set by setZoneStrings
949 UnicodeString **fLocaleZoneStrings; // Zone string array created by the locale
950 int32_t fZoneStringsRowCount;
951 int32_t fZoneStringsColCount;
952
953 Locale fZSFLocale; // Locale used for getting ZoneStringFormat
954
958 UnicodeString fLocalPatternChars;
959
965 UBool fCapitalization[kCapContextUsageTypeCount][2];
966
970 UnicodeString *fAbbreviatedDayPeriods;
971 int32_t fAbbreviatedDayPeriodsCount;
972
976 UnicodeString *fWideDayPeriods;
977 int32_t fWideDayPeriodsCount;
978
982 UnicodeString *fNarrowDayPeriods;
983 int32_t fNarrowDayPeriodsCount;
984
988 UnicodeString *fStandaloneAbbreviatedDayPeriods;
989 int32_t fStandaloneAbbreviatedDayPeriodsCount;
990
994 UnicodeString *fStandaloneWideDayPeriods;
995 int32_t fStandaloneWideDayPeriodsCount;
996
1000 UnicodeString *fStandaloneNarrowDayPeriods;
1001 int32_t fStandaloneNarrowDayPeriodsCount;
1002
1007 UnicodeString *fDayOfMonthOrdinalNames = nullptr;
1008
1014 UnicodeString *fDayOfMonthCardinalNames = nullptr;
1015 int32_t fDayOfMonthCardinalNamesCount = 0;
1016
1017private:
1021 Locale validLocale;
1022 Locale actualLocale;
1023
1024 DateFormatSymbols() = delete; // default constructor not implemented
1025
1035 void initializeData(const Locale& locale, const char *type,
1037
1046 static void assignArray(UnicodeString*& dstArray,
1048 const UnicodeString* srcArray,
1050
1061 static UBool arrayCompare(const UnicodeString* array1,
1062 const UnicodeString* array2,
1063 int32_t count);
1064
1070 void createZoneStrings(const UnicodeString *const * otherStrings);
1071
1075 void dispose();
1076
1081 void copyData(const DateFormatSymbols& other);
1082
1086 void initZoneStringsArray();
1087
1091 void disposeZoneStrings();
1092
1097 static UDateFormatField U_EXPORT2 getPatternCharIndex(char16_t c);
1098
1102 static UBool U_EXPORT2 isNumericField(UDateFormatField f, int32_t count);
1103
1107 static UBool U_EXPORT2 isNumericPatternChar(char16_t c, int32_t count);
1108public:
1109#ifndef U_HIDE_INTERNAL_API
1122#endif /* U_HIDE_INTERNAL_API */
1123};
1124
1126
1127#endif /* #if !UCONFIG_NO_FORMATTING */
1128
1129#endif /* U_SHOW_CPLUSPLUS_API */
1130
1131#endif // _DTFMTSYM
1132//eof
C++ API: Calendar object.
DateFormatSymbols is a public class for encapsulating localizable date-time formatting data – includi...
Definition dtfmtsym.h:84
U_I18N_API void setMonths(const UnicodeString *months, int32_t count, DtContextType context, DtWidthType width)
Sets month strings by width and context.
U_I18N_API DateFormatSymbols(const Locale &locale, const char *type, UErrorCode &status)
Construct a DateFormatSymbols object by loading format data from resources for the given locale,...
U_I18N_API void setTimeSeparatorString(const UnicodeString &newTimeSeparator)
Sets the time separator string.
U_I18N_API const UnicodeString * getShortWeekdays(int32_t &count) const
Gets abbreviated weekday strings.
U_I18N_API DateFormatSymbols(const Locale &locale, UErrorCode &status)
Construct a DateFormatSymbols object by loading format data from resources for the given locale,...
U_I18N_API const UnicodeString * getMonths(int32_t &count) const
Gets month strings.
U_I18N_API void setAmPmStrings(const UnicodeString *ampms, int32_t count, DtContextType context, DtWidthType width)
Sets AM/PM strings with the specified width.
static U_I18N_API const char16_t * getPatternUChars()
Get the non-localized date-time pattern characters.
U_I18N_API const UnicodeString ** getZoneStrings(int32_t &rowCount, int32_t &columnCount) const
Gets timezone strings.
U_I18N_API bool operator==(const DateFormatSymbols &other) const
Return true if another object is semantically equal to this one.
virtual U_I18N_API ~DateFormatSymbols()
Destructor.
U_I18N_API void setZoneStrings(const UnicodeString *const *strings, int32_t rowCount, int32_t columnCount)
Sets timezone strings.
U_I18N_API const UnicodeString * getWeekdays(int32_t &count, DtContextType context, DtWidthType width) const
Gets weekday strings by width and context.
U_I18N_API const UnicodeString * getAmPmStrings(int32_t &count) const
Gets AM/PM strings.
U_I18N_API UnicodeString & getTimeSeparatorString(UnicodeString &result) const
Gets the time separator string.
U_I18N_API const UnicodeString * getEraNames(int32_t &count) const
Gets era name strings.
DtWidthType
Selector for date formatting width.
Definition dtfmtsym.h:290
@ SHORT
Short width is currently only supported for weekday names.
Definition dtfmtsym.h:298
U_I18N_API void setLocalPatternChars(const UnicodeString &newLocalPatternChars)
Sets localized date-time pattern characters.
U_I18N_API const UnicodeString * getZodiacNames(int32_t &count, DtContextType context, DtWidthType width) const
Gets calendar zodiac name strings if the calendar has them, by width and context.
U_I18N_API void setShortWeekdays(const UnicodeString *abbrevWeekdays, int32_t count)
Sets abbreviated weekday strings.
U_I18N_API void setWeekdays(const UnicodeString *weekdays, int32_t count, DtContextType context, DtWidthType width)
Sets weekday strings by width and context.
U_I18N_API void setMonths(const UnicodeString *months, int32_t count)
Sets month strings.
U_I18N_API DateFormatSymbols & operator=(const DateFormatSymbols &)
Assignment operator.
U_I18N_API const UnicodeString * getShortMonths(int32_t &count) const
Gets short month strings.
virtual U_I18N_API UClassID getDynamicClassID() const override
ICU "poor man's RTTI", returns a UClassID for the actual class.
static U_I18N_API UClassID getStaticClassID()
ICU "poor man's RTTI", returns a UClassID for this class.
U_I18N_API const UnicodeString * getWeekdays(int32_t &count) const
Gets wide weekday strings.
U_I18N_API const UnicodeString * getQuarters(int32_t &count, DtContextType context, DtWidthType width) const
Gets quarter strings by width and context.
U_I18N_API void setEras(const UnicodeString *eras, int32_t count)
Sets abbreviated era strings.
U_I18N_API const UnicodeString * getEras(int32_t &count) const
Gets abbreviated era strings.
U_I18N_API UnicodeString & getLocalPatternChars(UnicodeString &result) const
Gets localized date-time pattern characters.
U_I18N_API void setShortMonths(const UnicodeString *shortMonths, int32_t count)
Sets short month strings.
U_I18N_API const UnicodeString * getNarrowEras(int32_t &count) const
Gets narrow era strings.
U_I18N_API void setYearNames(const UnicodeString *yearNames, int32_t count, DtContextType context, DtWidthType width)
Sets cyclic year name strings by width and context.
U_I18N_API void setEraNames(const UnicodeString *eraNames, int32_t count)
Sets era name strings.
U_I18N_API const UnicodeString * getDayOfMonthOrdinalNames(DtContextType context, DtWidthType width) const
Gets day-of-month ordinal name format patterns by width and context.
U_I18N_API const UnicodeString * getMonths(int32_t &count, DtContextType context, DtWidthType width) const
Gets month strings by width and context.
U_I18N_API Locale getLocale(ULocDataLocaleType type, UErrorCode &status) const
Returns the locale for this object.
U_I18N_API DateFormatSymbols(const DateFormatSymbols &)
Copy constructor.
U_I18N_API DateFormatSymbols(UErrorCode &status)
Construct a DateFormatSymbols object by loading format data from resources for the default locale,...
U_I18N_API void setAmPmStrings(const UnicodeString *ampms, int32_t count)
Sets ampm strings.
U_I18N_API const UnicodeString * getAmPmStrings(int32_t &count, DtContextType context, DtWidthType width) const
Gets AM/PM strings with the specified width.
U_I18N_API const UnicodeString * getDayOfMonthCardinalNames(int32_t &count, DtContextType context, DtWidthType width) const
Gets day-of-month cardinal name strings by width and context.
U_I18N_API bool operator!=(const DateFormatSymbols &other) const
Return true if another object is semantically unequal to this one.
Definition dtfmtsym.h:183
U_I18N_API void setQuarters(const UnicodeString *quarters, int32_t count, DtContextType context, DtWidthType width)
Sets quarter strings by width and context.
DtContextType
Selector for date formatting context.
Definition dtfmtsym.h:274
U_I18N_API const UnicodeString * getLeapMonthPatterns(int32_t &count) const
Somewhat temporary function for getting complete set of leap month patterns for all contexts & widths...
U_I18N_API void setNarrowEras(const UnicodeString *narrowEras, int32_t count)
Sets narrow era strings.
ECapitalizationContextUsageType
Constants for capitalization context usage types.
Definition dtfmtsym.h:686
static U_I18N_API DateFormatSymbols * createForLocale(const Locale &locale, UErrorCode &status)
Gets a DateFormatSymbols by locale.
U_I18N_API void setWeekdays(const UnicodeString *weekdays, int32_t count)
Sets wide weekday strings.
U_I18N_API const UnicodeString * getYearNames(int32_t &count, DtContextType context, DtWidthType width) const
Gets cyclic year name strings if the calendar has them, by width and context.
EMonthPatternType
Somewhat temporary constants for leap month pattern types, adequate for supporting just leap month pa...
Definition dtfmtsym.h:592
U_I18N_API DateFormatSymbols(const char *type, UErrorCode &status)
Construct a DateFormatSymbols object by loading format data from resources for the default locale,...
U_I18N_API void setZodiacNames(const UnicodeString *zodiacNames, int32_t count, DtContextType context, DtWidthType width)
Sets calendar zodiac name strings by width and context.
"Smart pointer" base class; do not use directly: use LocalPointer etc.
A Locale object represents a specific geographical, political, or cultural region.
Definition locid.h:198
SimpleDateFormat is a concrete class for formatting and parsing dates in a language-independent manne...
Definition smpdtfmt.h:386
UObject is the common ICU "boilerplate" class.
Definition uobject.h:222
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition unistr.h:303
C++ API: Locale ID object.
U_COMMON_API UBool operator==(const StringPiece &x, const StringPiece &y)
Global operator == for StringPiece.
C++ API: String Enumeration.
C API: DateFormat.
UDateFormatField
FieldPosition and UFieldPosition selectors for format fields defined by DateFormat and UDateFormat.
Definition udat.h:515
ULocDataLocaleType
Constants for *_getLocale() Allow user to select whether she wants information on requested,...
Definition uloc.h:338
int8_t UBool
The ICU boolean type, a signed-byte integer.
Definition umachine.h:269
C++ API: Common ICU base class UObject.
void * UClassID
UClassID is used to identify classes without using the compiler's RTTI.
Definition uobject.h:96
C API: Resource Bundle.
Basic definitions for ICU, for both C and C++ APIs.
UErrorCode
Standard ICU4C error code type, a substitute for exceptions.
Definition utypes.h:509
#define U_I18N_API_CLASS
Set to export library symbols from inside the i18n library, and to import them from outside,...
Definition utypes.h:457
#define U_I18N_API
Set to export library symbols from inside the i18n library, and to import them from outside.
Definition utypes.h:316