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
41U_NAMESPACE_BEGIN
42
43/* forward declaration */
44class SimpleDateFormat;
45class Hashtable;
46
85public:
100
113
114#ifndef U_HIDE_INTERNAL_API
132
147 const char *type,
149#endif /* U_HIDE_INTERNAL_API */
150
156
162
169
178
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
221
229 const UnicodeString* getNarrowEras(int32_t& count) const;
230
238
245 const UnicodeString* getMonths(int32_t& count) const;
246
255
264
272
278 FORMAT,
279 STANDALONE,
280#ifndef U_HIDE_DEPRECATED_API
285 DT_CONTEXT_COUNT
286#endif // U_HIDE_DEPRECATED_API
287 };
288
294 ABBREVIATED,
295 WIDE,
296 NARROW,
302#ifndef U_HIDE_DEPRECATED_API
307 DT_WIDTH_COUNT = 4
308#endif // U_HIDE_DEPRECATED_API
309 };
310
320
331
338 const UnicodeString* getWeekdays(int32_t& count) const;
339
340
348
357
366
376
386
397
409
417
425
426#ifndef U_HIDE_INTERNAL_API
432 static const char16_t DEFAULT_TIME_SEPARATOR = 0x003a; // ':'
433
438 static const char16_t ALTERNATE_TIME_SEPARATOR = 0x002e; // '.'
439
447
454#endif /* U_HIDE_INTERNAL_API */
455
467 DtContextType context, DtWidthType width) const;
468
480
492 DtContextType context, DtWidthType width) const;
493
505
506#ifndef U_HIDE_INTERNAL_API
516 {
517 kLeapMonthPatternFormatWide,
518 kLeapMonthPatternFormatAbbrev,
519 kLeapMonthPatternFormatNarrow,
520 kLeapMonthPatternStandaloneWide,
521 kLeapMonthPatternStandaloneAbbrev,
522 kLeapMonthPatternStandaloneNarrow,
523 kLeapMonthPatternNumeric,
524 kMonthPatternsCount
525 };
526
540
541#endif /* U_HIDE_INTERNAL_API */
542
543#ifndef U_HIDE_DEPRECATED_API
552#endif /* U_HIDE_DEPRECATED_API */
553
566
572 static const char16_t * U_EXPORT2 getPatternUChars(void);
573
585
593
600
601 /* The following type and kCapContextUsageTypeCount cannot be #ifndef U_HIDE_INTERNAL_API,
602 they are needed for .h file declarations. */
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
634
641
642private:
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
904private:
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,
924
933 static void assignArray(UnicodeString*& dstArray,
935 const UnicodeString* srcArray,
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);
995public:
996#ifndef U_HIDE_INTERNAL_API
1009 const Locale &locale, UErrorCode &status);
1010#endif /* U_HIDE_INTERNAL_API */
1011};
1012
1014
1015#endif /* #if !UCONFIG_NO_FORMATTING */
1016
1017#endif /* U_SHOW_CPLUSPLUS_API */
1018
1019#endif // _DTFMTSYM
1020//eof
C++ API: Calendar object.
DateFormatSymbols is a public class for encapsulating localizable date-time formatting data – includi...
Definition dtfmtsym.h:84
UnicodeString & getTimeSeparatorString(UnicodeString &result) const
Gets the time separator string.
void setYearNames(const UnicodeString *yearNames, int32_t count, DtContextType context, DtWidthType width)
Sets cyclic year name strings by width and context.
void setWeekdays(const UnicodeString *weekdays, int32_t count)
Sets wide weekday strings.
const UnicodeString * getAmPmStrings(int32_t &count) const
Gets AM/PM strings.
void setShortMonths(const UnicodeString *shortMonths, int32_t count)
Sets short month strings.
void setLocalPatternChars(const UnicodeString &newLocalPatternChars)
Sets localized date-time pattern characters.
const UnicodeString ** getZoneStrings(int32_t &rowCount, int32_t &columnCount) const
Gets timezone strings.
static const char16_t * getPatternUChars(void)
Get the non-localized date-time pattern characters.
DateFormatSymbols(const char *type, UErrorCode &status)
Construct a DateFormatSymbols object by loading format data from resources for the default locale,...
const UnicodeString * getWeekdays(int32_t &count, DtContextType context, DtWidthType width) const
Gets weekday strings by width and context.
const UnicodeString * getShortMonths(int32_t &count) const
Gets short month strings.
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.
const UnicodeString * getShortWeekdays(int32_t &count) const
Gets abbreviated weekday strings.
Locale getLocale(ULocDataLocaleType type, UErrorCode &status) const
Returns the locale for this object.
static DateFormatSymbols * createForLocale(const Locale &locale, UErrorCode &status)
Gets a DateFormatSymbols by locale.
void setEras(const UnicodeString *eras, int32_t count)
Sets abbreviated era strings.
const UnicodeString * getEraNames(int32_t &count) const
Gets era name strings.
void setQuarters(const UnicodeString *quarters, int32_t count, DtContextType context, DtWidthType width)
Sets quarter strings by width and context.
virtual UClassID getDynamicClassID() const
ICU "poor man's RTTI", returns a UClassID for the actual class.
DateFormatSymbols(UErrorCode &status)
Construct a DateFormatSymbols object by loading format data from resources for the default locale,...
void setAmPmStrings(const UnicodeString *ampms, int32_t count)
Sets ampm strings.
DtWidthType
Selector for date formatting width.
Definition dtfmtsym.h:293
@ SHORT
Short width is currently only supported for weekday names.
Definition dtfmtsym.h:301
DateFormatSymbols & operator=(const DateFormatSymbols &)
Assignment operator.
const UnicodeString * getMonths(int32_t &count) const
Gets month strings.
UBool operator==(const DateFormatSymbols &other) const
Return true if another object is semantically equal to this one.
void setShortWeekdays(const UnicodeString *abbrevWeekdays, int32_t count)
Sets abbreviated weekday strings.
UBool operator!=(const DateFormatSymbols &other) const
Return true if another object is semantically unequal to this one.
Definition dtfmtsym.h:186
const UnicodeString * getMonths(int32_t &count, DtContextType context, DtWidthType width) const
Gets month strings by width and context.
const UnicodeString * getQuarters(int32_t &count, DtContextType context, DtWidthType width) const
Gets quarter strings by width and context.
const UnicodeString * getNarrowEras(int32_t &count) const
Gets narrow era strings.
DateFormatSymbols(const Locale &locale, const char *type, UErrorCode &status)
Construct a DateFormatSymbols object by loading format data from resources for the given locale,...
void setZoneStrings(const UnicodeString *const *strings, int32_t rowCount, int32_t columnCount)
Sets timezone strings.
void setNarrowEras(const UnicodeString *narrowEras, int32_t count)
Sets narrow era strings.
const UnicodeString * getLeapMonthPatterns(int32_t &count) const
Somewhat temporary function for getting complete set of leap month patterns for all contexts & widths...
DateFormatSymbols(const DateFormatSymbols &)
Copy constructor.
void setEraNames(const UnicodeString *eraNames, int32_t count)
Sets era name strings.
void setMonths(const UnicodeString *months, int32_t count, DtContextType context, DtWidthType width)
Sets month strings by width and context.
void setTimeSeparatorString(const UnicodeString &newTimeSeparator)
Sets the time separator string.
void setZodiacNames(const UnicodeString *zodiacNames, int32_t count, DtContextType context, DtWidthType width)
Sets calendar zodiac name strings by width and context.
virtual ~DateFormatSymbols()
Destructor.
static UClassID getStaticClassID()
ICU "poor man's RTTI", returns a UClassID for this class.
void setMonths(const UnicodeString *months, int32_t count)
Sets month strings.
void setWeekdays(const UnicodeString *weekdays, int32_t count, DtContextType context, DtWidthType width)
Sets weekday strings by width and context.
DtContextType
Selector for date formatting context.
Definition dtfmtsym.h:277
UnicodeString & getLocalPatternChars(UnicodeString &result) const
Gets localized date-time pattern characters.
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.
ECapitalizationContextUsageType
Constants for capitalization context usage types.
Definition dtfmtsym.h:608
const UnicodeString * getEras(int32_t &count) const
Gets abbreviated era strings.
const UnicodeString * getWeekdays(int32_t &count) const
Gets wide weekday strings.
DateFormatSymbols(const Locale &locale, UErrorCode &status)
Construct a DateFormatSymbols object by loading format data from resources for the given locale,...
EMonthPatternType
Somewhat temporary constants for leap month pattern types, adequate for supporting just leap month pa...
Definition dtfmtsym.h:516
"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:195
SimpleDateFormat is a concrete class for formatting and parsing dates in a language-independent manne...
Definition smpdtfmt.h:726
UObject is the common ICU "boilerplate" class.
Definition uobject.h:223
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition unistr.h:296
C++ API: Locale ID object.
U_EXPORT 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
#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
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
#define U_FINAL
Defined to the C++11 "final" keyword if available.
Definition umachine.h:141
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:415
#define U_I18N_API
Set to export library symbols from inside the i18n library, and to import them from outside.
Definition utypes.h:301