ICU 62.1 62.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 !UCONFIG_NO_FORMATTING
26
27#include "unicode/calendar.h"
28#include "unicode/strenum.h"
29#include "unicode/uobject.h"
30#include "unicode/locid.h"
31#include "unicode/udat.h"
32#include "unicode/ures.h"
33
40
41/* forward declaration */
42class SimpleDateFormat;
43class Hashtable;
44
83public:
98
111
112#ifndef U_HIDE_INTERNAL_API
130
145 const char *type,
147#endif /* U_HIDE_INTERNAL_API */
148
154
160
167
176
185
193 const UnicodeString* getEras(int32_t& count) const;
194
201 void setEras(const UnicodeString* eras, int32_t count);
202
210 const UnicodeString* getEraNames(int32_t& count) const;
211
218 void setEraNames(const UnicodeString* eraNames, int32_t count);
219
227 const UnicodeString* getNarrowEras(int32_t& count) const;
228
235 void setNarrowEras(const UnicodeString* narrowEras, int32_t count);
236
243 const UnicodeString* getMonths(int32_t& count) const;
244
252 void setMonths(const UnicodeString* months, int32_t count);
253
261 const UnicodeString* getShortMonths(int32_t& count) const;
262
269 void setShortMonths(const UnicodeString* shortMonths, int32_t count);
270
276 FORMAT,
277 STANDALONE,
278#ifndef U_HIDE_DEPRECATED_API
283 DT_CONTEXT_COUNT
284#endif // U_HIDE_DEPRECATED_API
285 };
286
292 ABBREVIATED,
293 WIDE,
294 NARROW,
300#ifndef U_HIDE_DEPRECATED_API
305 DT_WIDTH_COUNT = 4
306#endif // U_HIDE_DEPRECATED_API
307 };
308
317 const UnicodeString* getMonths(int32_t& count, DtContextType context, DtWidthType width) const;
318
328 void setMonths(const UnicodeString* months, int32_t count, DtContextType context, DtWidthType width);
329
336 const UnicodeString* getWeekdays(int32_t& count) const;
337
338
345 void setWeekdays(const UnicodeString* weekdays, int32_t count);
346
354 const UnicodeString* getShortWeekdays(int32_t& count) const;
355
363 void setShortWeekdays(const UnicodeString* abbrevWeekdays, int32_t count);
364
373 const UnicodeString* getWeekdays(int32_t& count, DtContextType context, DtWidthType width) const;
374
383 void setWeekdays(const UnicodeString* weekdays, int32_t count, DtContextType context, DtWidthType width);
384
394 const UnicodeString* getQuarters(int32_t& count, DtContextType context, DtWidthType width) const;
395
406 void setQuarters(const UnicodeString* quarters, int32_t count, DtContextType context, DtWidthType width);
407
414 const UnicodeString* getAmPmStrings(int32_t& count) const;
415
422 void setAmPmStrings(const UnicodeString* ampms, int32_t count);
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
464 const UnicodeString* getYearNames(int32_t& count,
465 DtContextType context, DtWidthType width) const;
466
476 void setYearNames(const UnicodeString* yearNames, int32_t count,
477 DtContextType context, DtWidthType width);
478
489 const UnicodeString* getZodiacNames(int32_t& count,
490 DtContextType context, DtWidthType width) const;
491
501 void setZodiacNames(const UnicodeString* zodiacNames, int32_t count,
502 DtContextType context, DtWidthType width);
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
537 const UnicodeString* getLeapMonthPatterns(int32_t& count) const;
538
539#endif /* U_HIDE_INTERNAL_API */
540
541#ifndef U_HIDE_DEPRECATED_API
549 const UnicodeString** getZoneStrings(int32_t& rowCount, int32_t& columnCount) const;
550#endif /* U_HIDE_DEPRECATED_API */
551
563 void setZoneStrings(const UnicodeString* const* strings, int32_t rowCount, int32_t columnCount);
564
570 static const char16_t * U_EXPORT2 getPatternUChars(void);
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
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
779 UnicodeString *fStandaloneQuarters;
780 int32_t fStandaloneQuartersCount;
781
785 UnicodeString *fStandaloneShortQuarters;
786 int32_t fStandaloneShortQuartersCount;
787
791 UnicodeString *fLeapMonthPatterns;
792 int32_t fLeapMonthPatternsCount;
793
799 UnicodeString *fShortYearNames;
800 int32_t fShortYearNamesCount;
801
807 UnicodeString *fShortZodiacNames;
808 int32_t fShortZodiacNamesCount;
809
847 UnicodeString **fZoneStrings; // Zone string array set by setZoneStrings
848 UnicodeString **fLocaleZoneStrings; // Zone string array created by the locale
849 int32_t fZoneStringsRowCount;
850 int32_t fZoneStringsColCount;
851
852 Locale fZSFLocale; // Locale used for getting ZoneStringFormat
853
857 UnicodeString fLocalPatternChars;
858
864 UBool fCapitalization[kCapContextUsageTypeCount][2];
865
869 UnicodeString *fAbbreviatedDayPeriods;
870 int32_t fAbbreviatedDayPeriodsCount;
871
875 UnicodeString *fWideDayPeriods;
876 int32_t fWideDayPeriodsCount;
877
881 UnicodeString *fNarrowDayPeriods;
882 int32_t fNarrowDayPeriodsCount;
883
887 UnicodeString *fStandaloneAbbreviatedDayPeriods;
888 int32_t fStandaloneAbbreviatedDayPeriodsCount;
889
893 UnicodeString *fStandaloneWideDayPeriods;
894 int32_t fStandaloneWideDayPeriodsCount;
895
899 UnicodeString *fStandaloneNarrowDayPeriods;
900 int32_t fStandaloneNarrowDayPeriodsCount;
901
902private:
906 char validLocale[ULOC_FULLNAME_CAPACITY];
907 char actualLocale[ULOC_FULLNAME_CAPACITY];
908
909 DateFormatSymbols(); // default constructor not implemented
910
920 void initializeData(const Locale& locale, const char *type, UErrorCode& status, UBool useLastResortData = FALSE);
921
930 static void assignArray(UnicodeString*& dstArray,
931 int32_t& dstCount,
932 const UnicodeString* srcArray,
933 int32_t srcCount);
934
945 static UBool arrayCompare(const UnicodeString* array1,
946 const UnicodeString* array2,
947 int32_t count);
948
954 void createZoneStrings(const UnicodeString *const * otherStrings);
955
959 void dispose(void);
960
965 void copyData(const DateFormatSymbols& other);
966
970 void initZoneStringsArray(void);
971
975 void disposeZoneStrings(void);
976
981 static UDateFormatField U_EXPORT2 getPatternCharIndex(char16_t c);
982
986 static UBool U_EXPORT2 isNumericField(UDateFormatField f, int32_t count);
987
991 static UBool U_EXPORT2 isNumericPatternChar(char16_t c, int32_t count);
992public:
993#ifndef U_HIDE_INTERNAL_API
1006 const Locale &locale, UErrorCode &status);
1007#endif /* U_HIDE_INTERNAL_API */
1008};
1009
1011
1012#endif /* #if !UCONFIG_NO_FORMATTING */
1013
1014#endif // _DTFMTSYM
1015//eof
C++ API: Calendar object.
DateFormatSymbols is a public class for encapsulating localizable date-time formatting data – includi...
Definition dtfmtsym.h:82
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:291
@ SHORT
Short width is currently only supported for weekday names.
Definition dtfmtsym.h:299
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:184
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:275
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
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:188
SimpleDateFormat is a concrete class for formatting and parsing dates in a language-independent manne...
Definition smpdtfmt.h:723
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:287
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:490
#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.
Definition umachine.h:236
#define FALSE
The FALSE value of a UBool.
Definition umachine.h:244
C++ API: Common ICU base class UObject.
void * UClassID
UClassID is used to identify classes without using the compiler's RTTI.
Definition uobject.h:93
C API: Resource Bundle.
Basic definitions for ICU, for both C and C++ APIs.
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers,...
Definition utypes.h:396
#define U_I18N_API
Set to export library symbols from inside the i18n library, and to import them from outside.
Definition utypes.h:360
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
Definition uversion.h:138
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition uversion.h:137