ICU 77.1: i18n/unicode/dtfmtsym.h Source File

ICU 77.1 77.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 class CharString;
47
85 class U_I18N_API DateFormatSymbols final : public UObject {
86 public:
100 DateFormatSymbols(UErrorCode& status);
101
112 DateFormatSymbols(const Locale& locale,
113 UErrorCode& status);
114
115 #ifndef U_HIDE_INTERNAL_API
132 DateFormatSymbols(const char *type, UErrorCode& status);
133
147 DateFormatSymbols(const Locale& locale,
148 const char *type,
149 UErrorCode& status);
150 #endif /* U_HIDE_INTERNAL_API */
151
156 DateFormatSymbols(const DateFormatSymbols&);
157
162 DateFormatSymbols& operator=(const DateFormatSymbols&);
163
169 virtual ~DateFormatSymbols();
170
178 bool operator==(const DateFormatSymbols& other) const;
179
187 bool operator!=(const DateFormatSymbols& other) const { return !operator==(other); }
188
196 const UnicodeString* getEras(int32_t& count) const;
197
204 void setEras(const UnicodeString* eras, int32_t count);
205
213 const UnicodeString* getEraNames(int32_t& count) const;
214
221 void setEraNames(const UnicodeString* eraNames, int32_t count);
222
230 const UnicodeString* getNarrowEras(int32_t& count) const;
231
238 void setNarrowEras(const UnicodeString* narrowEras, int32_t count);
239
246 const UnicodeString* getMonths(int32_t& count) const;
247
255 void setMonths(const UnicodeString* months, int32_t count);
256
264 const UnicodeString* getShortMonths(int32_t& count) const;
265
272 void setShortMonths(const UnicodeString* shortMonths, int32_t count);
273
278 enum DtContextType {
279 FORMAT,
280 STANDALONE,
281 #ifndef U_HIDE_DEPRECATED_API
286 DT_CONTEXT_COUNT
287 #endif // U_HIDE_DEPRECATED_API
288 };
289
294 enum DtWidthType {
295 ABBREVIATED,
296 WIDE,
297 NARROW,
302 SHORT,
303 #ifndef U_HIDE_DEPRECATED_API
308 DT_WIDTH_COUNT = 4
309 #endif // U_HIDE_DEPRECATED_API
310 };
311
320 const UnicodeString* getMonths(int32_t& count, DtContextType context, DtWidthType width) const;
321
331 void setMonths(const UnicodeString* months, int32_t count, DtContextType context, DtWidthType width);
332
339 const UnicodeString* getWeekdays(int32_t& count) const;
340
341
348 void setWeekdays(const UnicodeString* weekdays, int32_t count);
349
357 const UnicodeString* getShortWeekdays(int32_t& count) const;
358
366 void setShortWeekdays(const UnicodeString* abbrevWeekdays, int32_t count);
367
376 const UnicodeString* getWeekdays(int32_t& count, DtContextType context, DtWidthType width) const;
377
386 void setWeekdays(const UnicodeString* weekdays, int32_t count, DtContextType context, DtWidthType width);
387
396 const UnicodeString* getQuarters(int32_t& count, DtContextType context, DtWidthType width) const;
397
407 void setQuarters(const UnicodeString* quarters, int32_t count, DtContextType context, DtWidthType width);
408
415 const UnicodeString* getAmPmStrings(int32_t& count) const;
416
423 void setAmPmStrings(const UnicodeString* ampms, int32_t count);
424
425 #ifndef U_HIDE_INTERNAL_API
431 static const char16_t DEFAULT_TIME_SEPARATOR = 0x003a; // ':'
432
437 static const char16_t ALTERNATE_TIME_SEPARATOR = 0x002e; // '.'
438
445 UnicodeString& getTimeSeparatorString(UnicodeString& result) const;
446
452 void setTimeSeparatorString(const UnicodeString& newTimeSeparator);
453 #endif /* U_HIDE_INTERNAL_API */
454
465 const UnicodeString* getYearNames(int32_t& count,
466 DtContextType context, DtWidthType width) const;
467
477 void setYearNames(const UnicodeString* yearNames, int32_t count,
478 DtContextType context, DtWidthType width);
479
490 const UnicodeString* getZodiacNames(int32_t& count,
491 DtContextType context, DtWidthType width) const;
492
502 void setZodiacNames(const UnicodeString* zodiacNames, int32_t count,
503 DtContextType context, DtWidthType width);
504
505 #ifndef U_HIDE_INTERNAL_API
514 enum EMonthPatternType
515 {
516 kLeapMonthPatternFormatWide,
517 kLeapMonthPatternFormatAbbrev,
518 kLeapMonthPatternFormatNarrow,
519 kLeapMonthPatternStandaloneWide,
520 kLeapMonthPatternStandaloneAbbrev,
521 kLeapMonthPatternStandaloneNarrow,
522 kLeapMonthPatternNumeric,
523 kMonthPatternsCount
524 };
525
538 const UnicodeString* getLeapMonthPatterns(int32_t& count) const;
539
540 #endif /* U_HIDE_INTERNAL_API */
541
542 #ifndef U_HIDE_DEPRECATED_API
550 const UnicodeString** getZoneStrings(int32_t& rowCount, int32_t& columnCount) const;
551 #endif /* U_HIDE_DEPRECATED_API */
552
564 void setZoneStrings(const UnicodeString* const* strings, int32_t rowCount, int32_t columnCount);
565
571 static const char16_t* U_EXPORT2 getPatternUChars();
572
583 UnicodeString& getLocalPatternChars(UnicodeString& result) const;
584
591 void setLocalPatternChars(const UnicodeString& newLocalPatternChars);
592
598 Locale getLocale(ULocDataLocaleType type, UErrorCode& status) const;
599
600 /* The following type and kCapContextUsageTypeCount cannot be #ifndef U_HIDE_INTERNAL_API,
601 they are needed for .h file declarations. */
606 enum ECapitalizationContextUsageType
607 {
608 #ifndef U_HIDE_INTERNAL_API
609 kCapContextUsageOther = 0,
610 kCapContextUsageMonthFormat, /* except narrow */
611 kCapContextUsageMonthStandalone, /* except narrow */
612 kCapContextUsageMonthNarrow,
613 kCapContextUsageDayFormat, /* except narrow */
614 kCapContextUsageDayStandalone, /* except narrow */
615 kCapContextUsageDayNarrow,
616 kCapContextUsageEraWide,
617 kCapContextUsageEraAbbrev,
618 kCapContextUsageEraNarrow,
619 kCapContextUsageZoneLong,
620 kCapContextUsageZoneShort,
621 kCapContextUsageMetazoneLong,
622 kCapContextUsageMetazoneShort,
623 #endif /* U_HIDE_INTERNAL_API */
624 kCapContextUsageTypeCount = 14
625 };
626
632 virtual UClassID getDynamicClassID() const override;
633
639 static UClassID U_EXPORT2 getStaticClassID();
640
641 private:
642
643 friend class SimpleDateFormat;
644 friend class DateFormatSymbolsSingleSetter; // see udat.cpp
645
649 UnicodeString* fEras;
650 int32_t fErasCount;
651
655 UnicodeString* fEraNames;
656 int32_t fEraNamesCount;
657
661 UnicodeString* fNarrowEras;
662 int32_t fNarrowErasCount;
663
667 UnicodeString* fMonths;
668 int32_t fMonthsCount;
669
673 UnicodeString* fShortMonths;
674 int32_t fShortMonthsCount;
675
679 UnicodeString* fNarrowMonths;
680 int32_t fNarrowMonthsCount;
681
685 UnicodeString* fStandaloneMonths;
686 int32_t fStandaloneMonthsCount;
687
691 UnicodeString* fStandaloneShortMonths;
692 int32_t fStandaloneShortMonthsCount;
693
697 UnicodeString* fStandaloneNarrowMonths;
698 int32_t fStandaloneNarrowMonthsCount;
699
703 UnicodeString* fWeekdays;
704 int32_t fWeekdaysCount;
705
709 UnicodeString* fShortWeekdays;
710 int32_t fShortWeekdaysCount;
711
715 UnicodeString* fShorterWeekdays;
716 int32_t fShorterWeekdaysCount;
717
721 UnicodeString* fNarrowWeekdays;
722 int32_t fNarrowWeekdaysCount;
723
727 UnicodeString* fStandaloneWeekdays;
728 int32_t fStandaloneWeekdaysCount;
729
733 UnicodeString* fStandaloneShortWeekdays;
734 int32_t fStandaloneShortWeekdaysCount;
735
739 UnicodeString* fStandaloneShorterWeekdays;
740 int32_t fStandaloneShorterWeekdaysCount;
741
745 UnicodeString* fStandaloneNarrowWeekdays;
746 int32_t fStandaloneNarrowWeekdaysCount;
747
751 UnicodeString* fAmPms;
752 int32_t fAmPmsCount;
753
757 UnicodeString* fNarrowAmPms;
758 int32_t fNarrowAmPmsCount;
759
763 UnicodeString fTimeSeparator;
764
768 UnicodeString *fQuarters;
769 int32_t fQuartersCount;
770
774 UnicodeString *fShortQuarters;
775 int32_t fShortQuartersCount;
776
781 UnicodeString *fNarrowQuarters;
782 int32_t fNarrowQuartersCount;
783
787 UnicodeString *fStandaloneQuarters;
788 int32_t fStandaloneQuartersCount;
789
793 UnicodeString *fStandaloneShortQuarters;
794 int32_t fStandaloneShortQuartersCount;
795
800 UnicodeString *fStandaloneNarrowQuarters;
801 int32_t fStandaloneNarrowQuartersCount;
802
806 UnicodeString *fLeapMonthPatterns;
807 int32_t fLeapMonthPatternsCount;
808
814 UnicodeString *fShortYearNames;
815 int32_t fShortYearNamesCount;
816
822 UnicodeString *fShortZodiacNames;
823 int32_t fShortZodiacNamesCount;
824
862 UnicodeString **fZoneStrings; // Zone string array set by setZoneStrings
863 UnicodeString **fLocaleZoneStrings; // Zone string array created by the locale
864 int32_t fZoneStringsRowCount;
865 int32_t fZoneStringsColCount;
866
867 Locale fZSFLocale; // Locale used for getting ZoneStringFormat
868
872 UnicodeString fLocalPatternChars;
873
879 UBool fCapitalization[kCapContextUsageTypeCount][2];
880
884 UnicodeString *fAbbreviatedDayPeriods;
885 int32_t fAbbreviatedDayPeriodsCount;
886
890 UnicodeString *fWideDayPeriods;
891 int32_t fWideDayPeriodsCount;
892
896 UnicodeString *fNarrowDayPeriods;
897 int32_t fNarrowDayPeriodsCount;
898
902 UnicodeString *fStandaloneAbbreviatedDayPeriods;
903 int32_t fStandaloneAbbreviatedDayPeriodsCount;
904
908 UnicodeString *fStandaloneWideDayPeriods;
909 int32_t fStandaloneWideDayPeriodsCount;
910
914 UnicodeString *fStandaloneNarrowDayPeriods;
915 int32_t fStandaloneNarrowDayPeriodsCount;
916
917 private:
921 CharString* validLocale = nullptr;
922 CharString* actualLocale = nullptr;
923
924 DateFormatSymbols() = delete; // default constructor not implemented
925
935 void initializeData(const Locale& locale, const char *type,
936 UErrorCode& status, UBool useLastResortData = false);
937
946 static void assignArray(UnicodeString*& dstArray,
947 int32_t& dstCount,
948 const UnicodeString* srcArray,
949 int32_t srcCount);
950
961 static UBool arrayCompare(const UnicodeString* array1,
962 const UnicodeString* array2,
963 int32_t count);
964
970 void createZoneStrings(const UnicodeString *const * otherStrings);
971
975 void dispose();
976
981 void copyData(const DateFormatSymbols& other);
982
986 void initZoneStringsArray();
987
991 void disposeZoneStrings();
992
997 static UDateFormatField U_EXPORT2 getPatternCharIndex(char16_t c);
998
1002 static UBool U_EXPORT2 isNumericField(UDateFormatField f, int32_t count);
1003
1007 static UBool U_EXPORT2 isNumericPatternChar(char16_t c, int32_t count);
1008 public:
1009 #ifndef U_HIDE_INTERNAL_API
1021 static DateFormatSymbols * U_EXPORT2 createForLocale(
1022 const Locale &locale, UErrorCode &status);
1023 #endif /* U_HIDE_INTERNAL_API */
1024 };
1025
1026 U_NAMESPACE_END
1027
1028 #endif /* #if !UCONFIG_NO_FORMATTING */
1029
1030 #endif /* U_SHOW_CPLUSPLUS_API */
1031
1032 #endif // _DTFMTSYM
1033 //eof
calendar.h
C++ API: Calendar object.
icu::DateFormatSymbols
DateFormatSymbols is a public class for encapsulating localizable date-time formatting data – includi...
Definition: dtfmtsym.h:85
icu::DateFormatSymbols::getAmPmStrings
const UnicodeString * getAmPmStrings(int32_t &count) const
Gets AM/PM strings.
icu::DateFormatSymbols::setYearNames
void setYearNames(const UnicodeString *yearNames, int32_t count, DtContextType context, DtWidthType width)
Sets cyclic year name strings by width and context.
icu::DateFormatSymbols::setWeekdays
void setWeekdays(const UnicodeString *weekdays, int32_t count)
Sets wide weekday strings.
icu::DateFormatSymbols::getQuarters
const UnicodeString * getQuarters(int32_t &count, DtContextType context, DtWidthType width) const
Gets quarter strings by width and context.
icu::DateFormatSymbols::setShortMonths
void setShortMonths(const UnicodeString *shortMonths, int32_t count)
Sets short month strings.
icu::DateFormatSymbols::setLocalPatternChars
void setLocalPatternChars(const UnicodeString &newLocalPatternChars)
Sets localized date-time pattern characters.
icu::DateFormatSymbols::DateFormatSymbols
DateFormatSymbols(const char *type, UErrorCode &status)
Construct a DateFormatSymbols object by loading format data from resources for the default locale,...
icu::DateFormatSymbols::createForLocale
static DateFormatSymbols * createForLocale(const Locale &locale, UErrorCode &status)
Gets a DateFormatSymbols by locale.
icu::DateFormatSymbols::getLocalPatternChars
UnicodeString & getLocalPatternChars(UnicodeString &result) const
Gets localized date-time pattern characters.
icu::DateFormatSymbols::getEras
const UnicodeString * getEras(int32_t &count) const
Gets abbreviated era strings.
icu::DateFormatSymbols::getLocale
Locale getLocale(ULocDataLocaleType type, UErrorCode &status) const
Returns the locale for this object.
icu::DateFormatSymbols::getWeekdays
const UnicodeString * getWeekdays(int32_t &count, DtContextType context, DtWidthType width) const
Gets weekday strings by width and context.
icu::DateFormatSymbols::setEras
void setEras(const UnicodeString *eras, int32_t count)
Sets abbreviated era strings.
icu::DateFormatSymbols::setQuarters
void setQuarters(const UnicodeString *quarters, int32_t count, DtContextType context, DtWidthType width)
Sets quarter strings by width and context.
icu::DateFormatSymbols::getEraNames
const UnicodeString * getEraNames(int32_t &count) const
Gets era name strings.
icu::DateFormatSymbols::operator!=
bool operator!=(const DateFormatSymbols &other) const
Return true if another object is semantically unequal to this one.
Definition: dtfmtsym.h:187
icu::DateFormatSymbols::DateFormatSymbols
DateFormatSymbols(UErrorCode &status)
Construct a DateFormatSymbols object by loading format data from resources for the default locale,...
icu::DateFormatSymbols::setAmPmStrings
void setAmPmStrings(const UnicodeString *ampms, int32_t count)
Sets ampm strings.
icu::DateFormatSymbols::DtWidthType
DtWidthType
Selector for date formatting width.
Definition: dtfmtsym.h:294
icu::DateFormatSymbols::SHORT
@ SHORT
Short width is currently only supported for weekday names.
Definition: dtfmtsym.h:302
icu::DateFormatSymbols::operator=
DateFormatSymbols & operator=(const DateFormatSymbols &)
Assignment operator.
icu::DateFormatSymbols::getNarrowEras
const UnicodeString * getNarrowEras(int32_t &count) const
Gets narrow era strings.
icu::DateFormatSymbols::getShortWeekdays
const UnicodeString * getShortWeekdays(int32_t &count) const
Gets abbreviated weekday strings.
icu::DateFormatSymbols::setShortWeekdays
void setShortWeekdays(const UnicodeString *abbrevWeekdays, int32_t count)
Sets abbreviated weekday strings.
icu::DateFormatSymbols::getYearNames
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.
icu::DateFormatSymbols::getPatternUChars
static const char16_t * getPatternUChars()
Get the non-localized date-time pattern characters.
icu::DateFormatSymbols::getWeekdays
const UnicodeString * getWeekdays(int32_t &count) const
Gets wide weekday strings.
icu::DateFormatSymbols::getMonths
const UnicodeString * getMonths(int32_t &count) const
Gets month strings.
icu::DateFormatSymbols::getMonths
const UnicodeString * getMonths(int32_t &count, DtContextType context, DtWidthType width) const
Gets month strings by width and context.
icu::DateFormatSymbols::DateFormatSymbols
DateFormatSymbols(const Locale &locale, const char *type, UErrorCode &status)
Construct a DateFormatSymbols object by loading format data from resources for the given locale,...
icu::DateFormatSymbols::getZodiacNames
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.
icu::DateFormatSymbols::setZoneStrings
void setZoneStrings(const UnicodeString *const *strings, int32_t rowCount, int32_t columnCount)
Sets timezone strings.
icu::DateFormatSymbols::setNarrowEras
void setNarrowEras(const UnicodeString *narrowEras, int32_t count)
Sets narrow era strings.
icu::DateFormatSymbols::operator==
bool operator==(const DateFormatSymbols &other) const
Return true if another object is semantically equal to this one.
icu::DateFormatSymbols::getLeapMonthPatterns
const UnicodeString * getLeapMonthPatterns(int32_t &count) const
Somewhat temporary function for getting complete set of leap month patterns for all contexts & widths...
icu::DateFormatSymbols::DateFormatSymbols
DateFormatSymbols(const DateFormatSymbols &)
Copy constructor.
icu::DateFormatSymbols::getDynamicClassID
virtual UClassID getDynamicClassID() const override
ICU "poor man's RTTI", returns a UClassID for the actual class.
icu::DateFormatSymbols::setEraNames
void setEraNames(const UnicodeString *eraNames, int32_t count)
Sets era name strings.
icu::DateFormatSymbols::setMonths
void setMonths(const UnicodeString *months, int32_t count, DtContextType context, DtWidthType width)
Sets month strings by width and context.
icu::DateFormatSymbols::setTimeSeparatorString
void setTimeSeparatorString(const UnicodeString &newTimeSeparator)
Sets the time separator string.
icu::DateFormatSymbols::setZodiacNames
void setZodiacNames(const UnicodeString *zodiacNames, int32_t count, DtContextType context, DtWidthType width)
Sets calendar zodiac name strings by width and context.
icu::DateFormatSymbols::~DateFormatSymbols
virtual ~DateFormatSymbols()
Destructor.
icu::DateFormatSymbols::getStaticClassID
static UClassID getStaticClassID()
ICU "poor man's RTTI", returns a UClassID for this class.
icu::DateFormatSymbols::getTimeSeparatorString
UnicodeString & getTimeSeparatorString(UnicodeString &result) const
Gets the time separator string.
icu::DateFormatSymbols::setMonths
void setMonths(const UnicodeString *months, int32_t count)
Sets month strings.
icu::DateFormatSymbols::setWeekdays
void setWeekdays(const UnicodeString *weekdays, int32_t count, DtContextType context, DtWidthType width)
Sets weekday strings by width and context.
icu::DateFormatSymbols::DtContextType
DtContextType
Selector for date formatting context.
Definition: dtfmtsym.h:278
icu::DateFormatSymbols::ECapitalizationContextUsageType
ECapitalizationContextUsageType
Constants for capitalization context usage types.
Definition: dtfmtsym.h:607
icu::DateFormatSymbols::DateFormatSymbols
DateFormatSymbols(const Locale &locale, UErrorCode &status)
Construct a DateFormatSymbols object by loading format data from resources for the given locale,...
icu::DateFormatSymbols::EMonthPatternType
EMonthPatternType
Somewhat temporary constants for leap month pattern types, adequate for supporting just leap month pa...
Definition: dtfmtsym.h:515
icu::DateFormatSymbols::getShortMonths
const UnicodeString * getShortMonths(int32_t &count) const
Gets short month strings.
icu::DateFormatSymbols::getZoneStrings
const UnicodeString ** getZoneStrings(int32_t &rowCount, int32_t &columnCount) const
Gets timezone strings.
icu::Locale
A Locale object represents a specific geographical, political, or cultural region.
Definition: locid.h:195
icu::SimpleDateFormat
SimpleDateFormat is a concrete class for formatting and parsing dates in a language-independent manne...
Definition: smpdtfmt.h:385
icu::UObject
UObject is the common ICU "boilerplate" class.
Definition: uobject.h:223
icu::UnicodeString
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition: unistr.h:296
locid.h
C++ API: Locale ID object.
icu::operator==
U_EXPORT UBool operator==(const StringPiece &x, const StringPiece &y)
Global operator == for StringPiece.
strenum.h
C++ API: String Enumeration.
udat.h
C API: DateFormat.
UDateFormatField
UDateFormatField
FieldPosition and UFieldPosition selectors for format fields defined by DateFormat and UDateFormat.
Definition: udat.h:515
ULocDataLocaleType
ULocDataLocaleType
Constants for *_getLocale() Allow user to select whether she wants information on requested,...
Definition: uloc.h:338
UBool
int8_t UBool
The ICU boolean type, a signed-byte integer.
Definition: umachine.h:247
uobject.h
C++ API: Common ICU base class UObject.
UClassID
void * UClassID
UClassID is used to identify classes without using the compiler's RTTI.
Definition: uobject.h:96
ures.h
C API: Resource Bundle.
utypes.h
Basic definitions for ICU, for both C and C++ APIs.
UErrorCode
UErrorCode
Standard ICU4C error code type, a substitute for exceptions.
Definition: utypes.h:430
U_I18N_API
#define U_I18N_API
Set to export library symbols from inside the i18n library, and to import them from outside.
Definition: utypes.h:316