ICU 76.1 76.1
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
113
114#ifndef U_HIDE_INTERNAL_API
132
147 const char *type,
149#endif /* U_HIDE_INTERNAL_API */
150
156
162
169
178
186 bool 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
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
396
407
415
423
424#ifndef U_HIDE_INTERNAL_API
430 static const char16_t DEFAULT_TIME_SEPARATOR = 0x003a; // ':'
431
436 static const char16_t ALTERNATE_TIME_SEPARATOR = 0x002e; // '.'
437
445
452#endif /* U_HIDE_INTERNAL_API */
453
465 DtContextType context, DtWidthType width) const;
466
478
490 DtContextType context, DtWidthType width) const;
491
503
504#ifndef U_HIDE_INTERNAL_API
514 {
515 kLeapMonthPatternFormatWide,
516 kLeapMonthPatternFormatAbbrev,
517 kLeapMonthPatternFormatNarrow,
518 kLeapMonthPatternStandaloneWide,
519 kLeapMonthPatternStandaloneAbbrev,
520 kLeapMonthPatternStandaloneNarrow,
521 kLeapMonthPatternNumeric,
522 kMonthPatternsCount
523 };
524
538
539#endif /* U_HIDE_INTERNAL_API */
540
541#ifndef U_HIDE_DEPRECATED_API
550#endif /* U_HIDE_DEPRECATED_API */
551
564
570 static const char16_t* U_EXPORT2 getPatternUChars();
571
583
591
598
599 /* The following type and kCapContextUsageTypeCount cannot be #ifndef U_HIDE_INTERNAL_API,
600 they are needed for .h file declarations. */
606 {
607#ifndef U_HIDE_INTERNAL_API
608 kCapContextUsageOther = 0,
609 kCapContextUsageMonthFormat, /* except narrow */
610 kCapContextUsageMonthStandalone, /* except narrow */
611 kCapContextUsageMonthNarrow,
612 kCapContextUsageDayFormat, /* except narrow */
613 kCapContextUsageDayStandalone, /* except narrow */
614 kCapContextUsageDayNarrow,
615 kCapContextUsageEraWide,
616 kCapContextUsageEraAbbrev,
617 kCapContextUsageEraNarrow,
618 kCapContextUsageZoneLong,
619 kCapContextUsageZoneShort,
620 kCapContextUsageMetazoneLong,
621 kCapContextUsageMetazoneShort,
622#endif /* U_HIDE_INTERNAL_API */
623 kCapContextUsageTypeCount = 14
624 };
625
631 virtual UClassID getDynamicClassID() const override;
632
639
640private:
641
642 friend class SimpleDateFormat;
643 friend class DateFormatSymbolsSingleSetter; // see udat.cpp
644
648 UnicodeString* fEras;
649 int32_t fErasCount;
650
654 UnicodeString* fEraNames;
655 int32_t fEraNamesCount;
656
660 UnicodeString* fNarrowEras;
661 int32_t fNarrowErasCount;
662
666 UnicodeString* fMonths;
667 int32_t fMonthsCount;
668
672 UnicodeString* fShortMonths;
673 int32_t fShortMonthsCount;
674
678 UnicodeString* fNarrowMonths;
679 int32_t fNarrowMonthsCount;
680
684 UnicodeString* fStandaloneMonths;
685 int32_t fStandaloneMonthsCount;
686
690 UnicodeString* fStandaloneShortMonths;
691 int32_t fStandaloneShortMonthsCount;
692
696 UnicodeString* fStandaloneNarrowMonths;
697 int32_t fStandaloneNarrowMonthsCount;
698
702 UnicodeString* fWeekdays;
703 int32_t fWeekdaysCount;
704
708 UnicodeString* fShortWeekdays;
709 int32_t fShortWeekdaysCount;
710
714 UnicodeString* fShorterWeekdays;
715 int32_t fShorterWeekdaysCount;
716
720 UnicodeString* fNarrowWeekdays;
721 int32_t fNarrowWeekdaysCount;
722
726 UnicodeString* fStandaloneWeekdays;
727 int32_t fStandaloneWeekdaysCount;
728
732 UnicodeString* fStandaloneShortWeekdays;
733 int32_t fStandaloneShortWeekdaysCount;
734
738 UnicodeString* fStandaloneShorterWeekdays;
739 int32_t fStandaloneShorterWeekdaysCount;
740
744 UnicodeString* fStandaloneNarrowWeekdays;
745 int32_t fStandaloneNarrowWeekdaysCount;
746
750 UnicodeString* fAmPms;
751 int32_t fAmPmsCount;
752
756 UnicodeString* fNarrowAmPms;
757 int32_t fNarrowAmPmsCount;
758
762 UnicodeString fTimeSeparator;
763
767 UnicodeString *fQuarters;
768 int32_t fQuartersCount;
769
773 UnicodeString *fShortQuarters;
774 int32_t fShortQuartersCount;
775
780 UnicodeString *fNarrowQuarters;
781 int32_t fNarrowQuartersCount;
782
786 UnicodeString *fStandaloneQuarters;
787 int32_t fStandaloneQuartersCount;
788
792 UnicodeString *fStandaloneShortQuarters;
793 int32_t fStandaloneShortQuartersCount;
794
799 UnicodeString *fStandaloneNarrowQuarters;
800 int32_t fStandaloneNarrowQuartersCount;
801
805 UnicodeString *fLeapMonthPatterns;
806 int32_t fLeapMonthPatternsCount;
807
813 UnicodeString *fShortYearNames;
814 int32_t fShortYearNamesCount;
815
821 UnicodeString *fShortZodiacNames;
822 int32_t fShortZodiacNamesCount;
823
861 UnicodeString **fZoneStrings; // Zone string array set by setZoneStrings
862 UnicodeString **fLocaleZoneStrings; // Zone string array created by the locale
863 int32_t fZoneStringsRowCount;
864 int32_t fZoneStringsColCount;
865
866 Locale fZSFLocale; // Locale used for getting ZoneStringFormat
867
871 UnicodeString fLocalPatternChars;
872
878 UBool fCapitalization[kCapContextUsageTypeCount][2];
879
883 UnicodeString *fAbbreviatedDayPeriods;
884 int32_t fAbbreviatedDayPeriodsCount;
885
889 UnicodeString *fWideDayPeriods;
890 int32_t fWideDayPeriodsCount;
891
895 UnicodeString *fNarrowDayPeriods;
896 int32_t fNarrowDayPeriodsCount;
897
901 UnicodeString *fStandaloneAbbreviatedDayPeriods;
902 int32_t fStandaloneAbbreviatedDayPeriodsCount;
903
907 UnicodeString *fStandaloneWideDayPeriods;
908 int32_t fStandaloneWideDayPeriodsCount;
909
913 UnicodeString *fStandaloneNarrowDayPeriods;
914 int32_t fStandaloneNarrowDayPeriodsCount;
915
916private:
920 char validLocale[ULOC_FULLNAME_CAPACITY];
921 char actualLocale[ULOC_FULLNAME_CAPACITY];
922
923 DateFormatSymbols() = delete; // default constructor not implemented
924
934 void initializeData(const Locale& locale, const char *type,
936
945 static void assignArray(UnicodeString*& dstArray,
947 const UnicodeString* srcArray,
949
960 static UBool arrayCompare(const UnicodeString* array1,
961 const UnicodeString* array2,
962 int32_t count);
963
969 void createZoneStrings(const UnicodeString *const * otherStrings);
970
974 void dispose();
975
980 void copyData(const DateFormatSymbols& other);
981
985 void initZoneStringsArray();
986
990 void disposeZoneStrings();
991
996 static UDateFormatField U_EXPORT2 getPatternCharIndex(char16_t c);
997
1001 static UBool U_EXPORT2 isNumericField(UDateFormatField f, int32_t count);
1002
1006 static UBool U_EXPORT2 isNumericPatternChar(char16_t c, int32_t count);
1007public:
1008#ifndef U_HIDE_INTERNAL_API
1021 const Locale &locale, UErrorCode &status);
1022#endif /* U_HIDE_INTERNAL_API */
1023};
1024
1026
1027#endif /* #if !UCONFIG_NO_FORMATTING */
1028
1029#endif /* U_SHOW_CPLUSPLUS_API */
1030
1031#endif // _DTFMTSYM
1032//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.
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.
bool operator!=(const DateFormatSymbols &other) const
Return true if another object is semantically unequal to this one.
Definition dtfmtsym.h:186
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.
void setShortWeekdays(const UnicodeString *abbrevWeekdays, int32_t count)
Sets abbreviated weekday strings.
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.
bool operator==(const DateFormatSymbols &other) const
Return true if another object is semantically equal to this one.
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.
virtual UClassID getDynamicClassID() const override
ICU "poor man's RTTI", returns a UClassID for the actual class.
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:606
static const char16_t * getPatternUChars()
Get the non-localized date-time pattern characters.
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:514
"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:385
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:247
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:430
#define U_I18N_API
Set to export library symbols from inside the i18n library, and to import them from outside.
Definition utypes.h:316