ICU 58.2 58.2

- Main Page
- Related Pages
- Modules
- Namespaces
- Data Structures
- Files

- File List
- Globals

dtfmtsym.h
Go to the documentation of this file.
1 // Copyright (C) 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/uobject.h"
29 #include "unicode/locid.h"
30 #include "unicode/udat.h"
31 #include "unicode/ures.h"
32
38 U_NAMESPACE_BEGIN
39
40 /* forward declaration */
41 class SimpleDateFormat;
42 class Hashtable;
43
81 class U_I18N_API DateFormatSymbols U_FINAL : public UObject {
82 public:
96 DateFormatSymbols(UErrorCode& status);
97
108 DateFormatSymbols(const Locale& locale,
109 UErrorCode& status);
110
111 #ifndef U_HIDE_INTERNAL_API
112
128 DateFormatSymbols(const char *type, UErrorCode& status);
129
143 DateFormatSymbols(const Locale& locale,
144 const char *type,
145 UErrorCode& status);
146 #endif /* U_HIDE_INTERNAL_API */
147
152 DateFormatSymbols(const DateFormatSymbols&);
153
158 DateFormatSymbols& operator=(const DateFormatSymbols&);
159
165 virtual ~DateFormatSymbols();
166
174 UBool operator==(const DateFormatSymbols& other) const;
175
183 UBool operator!=(const DateFormatSymbols& other) const { return !operator==(other); }
184
192 const UnicodeString* getEras(int32_t& count) const;
193
200 void setEras(const UnicodeString* eras, int32_t count);
201
209 const UnicodeString* getEraNames(int32_t& count) const;
210
217 void setEraNames(const UnicodeString* eraNames, int32_t count);
218
226 const UnicodeString* getNarrowEras(int32_t& count) const;
227
234 void setNarrowEras(const UnicodeString* narrowEras, int32_t count);
235
242 const UnicodeString* getMonths(int32_t& count) const;
243
251 void setMonths(const UnicodeString* months, int32_t count);
252
260 const UnicodeString* getShortMonths(int32_t& count) const;
261
268 void setShortMonths(const UnicodeString* shortMonths, int32_t count);
269
274 enum DtContextType {
275 FORMAT,
276 STANDALONE,
277 #ifndef U_HIDE_DEPRECATED_API
278
282 DT_CONTEXT_COUNT
283 #endif // U_HIDE_DEPRECATED_API
284 };
285
290 enum DtWidthType {
291 ABBREVIATED,
292 WIDE,
293 NARROW,
298 SHORT,
299 #ifndef U_HIDE_DEPRECATED_API
300
304 DT_WIDTH_COUNT = 4
305 #endif // U_HIDE_DEPRECATED_API
306 };
307
316 const UnicodeString* getMonths(int32_t& count, DtContextType context, DtWidthType width) const;
317
327 void setMonths(const UnicodeString* months, int32_t count, DtContextType context, DtWidthType width);
328
335 const UnicodeString* getWeekdays(int32_t& count) const;
336
337
344 void setWeekdays(const UnicodeString* weekdays, int32_t count);
345
353 const UnicodeString* getShortWeekdays(int32_t& count) const;
354
362 void setShortWeekdays(const UnicodeString* abbrevWeekdays, int32_t count);
363
372 const UnicodeString* getWeekdays(int32_t& count, DtContextType context, DtWidthType width) const;
373
382 void setWeekdays(const UnicodeString* weekdays, int32_t count, DtContextType context, DtWidthType width);
383
393 const UnicodeString* getQuarters(int32_t& count, DtContextType context, DtWidthType width) const;
394
405 void setQuarters(const UnicodeString* quarters, int32_t count, DtContextType context, DtWidthType width);
406
413 const UnicodeString* getAmPmStrings(int32_t& count) const;
414
421 void setAmPmStrings(const UnicodeString* ampms, int32_t count);
422
423 #ifndef U_HIDE_INTERNAL_API
424
429 static const UChar DEFAULT_TIME_SEPARATOR = 0x003a; // ':'
430
435 static const UChar ALTERNATE_TIME_SEPARATOR = 0x002e; // '.'
436
443 UnicodeString& getTimeSeparatorString(UnicodeString& result) const;
444
450 void setTimeSeparatorString(const UnicodeString& newTimeSeparator);
451 #endif /* U_HIDE_INTERNAL_API */
452
463 const UnicodeString* getYearNames(int32_t& count,
464 DtContextType context, DtWidthType width) const;
465
475 void setYearNames(const UnicodeString* yearNames, int32_t count,
476 DtContextType context, DtWidthType width);
477
488 const UnicodeString* getZodiacNames(int32_t& count,
489 DtContextType context, DtWidthType width) const;
490
500 void setZodiacNames(const UnicodeString* zodiacNames, int32_t count,
501 DtContextType context, DtWidthType width);
502
503 #ifndef U_HIDE_INTERNAL_API
504
512 enum EMonthPatternType
513 {
514 kLeapMonthPatternFormatWide,
515 kLeapMonthPatternFormatAbbrev,
516 kLeapMonthPatternFormatNarrow,
517 kLeapMonthPatternStandaloneWide,
518 kLeapMonthPatternStandaloneAbbrev,
519 kLeapMonthPatternStandaloneNarrow,
520 kLeapMonthPatternNumeric,
521 kMonthPatternsCount
522 };
523
536 const UnicodeString* getLeapMonthPatterns(int32_t& count) const;
537
538 #endif /* U_HIDE_INTERNAL_API */
539
540 #ifndef U_HIDE_DEPRECATED_API
541
548 const UnicodeString** getZoneStrings(int32_t& rowCount, int32_t& columnCount) const;
549 #endif /* U_HIDE_DEPRECATED_API */
550
562 void setZoneStrings(const UnicodeString* const* strings, int32_t rowCount, int32_t columnCount);
563
569 static const UChar * U_EXPORT2 getPatternUChars(void);
570
581 UnicodeString& getLocalPatternChars(UnicodeString& result) const;
582
589 void setLocalPatternChars(const UnicodeString& newLocalPatternChars);
590
596 Locale getLocale(ULocDataLocaleType type, UErrorCode& status) const;
597
598 /* The following type and kCapContextUsageTypeCount cannot be #ifndef U_HIDE_INTERNAL_API,
599 they are needed for .h file declarations. */
604 enum ECapitalizationContextUsageType
605 {
606 #ifndef U_HIDE_INTERNAL_API
607 kCapContextUsageOther = 0,
608 kCapContextUsageMonthFormat, /* except narrow */
609 kCapContextUsageMonthStandalone, /* except narrow */
610 kCapContextUsageMonthNarrow,
611 kCapContextUsageDayFormat, /* except narrow */
612 kCapContextUsageDayStandalone, /* except narrow */
613 kCapContextUsageDayNarrow,
614 kCapContextUsageEraWide,
615 kCapContextUsageEraAbbrev,
616 kCapContextUsageEraNarrow,
617 kCapContextUsageZoneLong,
618 kCapContextUsageZoneShort,
619 kCapContextUsageMetazoneLong,
620 kCapContextUsageMetazoneShort,
621 #endif /* U_HIDE_INTERNAL_API */
622 kCapContextUsageTypeCount = 14
623 };
624
630 virtual UClassID getDynamicClassID() const;
631
637 static UClassID U_EXPORT2 getStaticClassID();
638
639 private:
640
641 friend class SimpleDateFormat;
642 friend class DateFormatSymbolsSingleSetter; // see udat.cpp
643
647 UnicodeString* fEras;
648 int32_t fErasCount;
649
653 UnicodeString* fEraNames;
654 int32_t fEraNamesCount;
655
659 UnicodeString* fNarrowEras;
660 int32_t fNarrowErasCount;
661
665 UnicodeString* fMonths;
666 int32_t fMonthsCount;
667
671 UnicodeString* fShortMonths;
672 int32_t fShortMonthsCount;
673
677 UnicodeString* fNarrowMonths;
678 int32_t fNarrowMonthsCount;
679
683 UnicodeString* fStandaloneMonths;
684 int32_t fStandaloneMonthsCount;
685
689 UnicodeString* fStandaloneShortMonths;
690 int32_t fStandaloneShortMonthsCount;
691
695 UnicodeString* fStandaloneNarrowMonths;
696 int32_t fStandaloneNarrowMonthsCount;
697
701 UnicodeString* fWeekdays;
702 int32_t fWeekdaysCount;
703
707 UnicodeString* fShortWeekdays;
708 int32_t fShortWeekdaysCount;
709
713 UnicodeString* fShorterWeekdays;
714 int32_t fShorterWeekdaysCount;
715
719 UnicodeString* fNarrowWeekdays;
720 int32_t fNarrowWeekdaysCount;
721
725 UnicodeString* fStandaloneWeekdays;
726 int32_t fStandaloneWeekdaysCount;
727
731 UnicodeString* fStandaloneShortWeekdays;
732 int32_t fStandaloneShortWeekdaysCount;
733
737 UnicodeString* fStandaloneShorterWeekdays;
738 int32_t fStandaloneShorterWeekdaysCount;
739
743 UnicodeString* fStandaloneNarrowWeekdays;
744 int32_t fStandaloneNarrowWeekdaysCount;
745
749 UnicodeString* fAmPms;
750 int32_t fAmPmsCount;
751
755 UnicodeString* fNarrowAmPms;
756 int32_t fNarrowAmPmsCount;
757
761 UnicodeString fTimeSeparator;
762
766 UnicodeString *fQuarters;
767 int32_t fQuartersCount;
768
772 UnicodeString *fShortQuarters;
773 int32_t fShortQuartersCount;
774
778 UnicodeString *fStandaloneQuarters;
779 int32_t fStandaloneQuartersCount;
780
784 UnicodeString *fStandaloneShortQuarters;
785 int32_t fStandaloneShortQuartersCount;
786
790 UnicodeString *fLeapMonthPatterns;
791 int32_t fLeapMonthPatternsCount;
792
798 UnicodeString *fShortYearNames;
799 int32_t fShortYearNamesCount;
800
806 UnicodeString *fShortZodiacNames;
807 int32_t fShortZodiacNamesCount;
808
846 UnicodeString **fZoneStrings; // Zone string array set by setZoneStrings
847 UnicodeString **fLocaleZoneStrings; // Zone string array created by the locale
848 int32_t fZoneStringsRowCount;
849 int32_t fZoneStringsColCount;
850
851 Locale fZSFLocale; // Locale used for getting ZoneStringFormat
852
856 UnicodeString fLocalPatternChars;
857
863 UBool fCapitalization[kCapContextUsageTypeCount][2];
864
868 UnicodeString *fAbbreviatedDayPeriods;
869 int32_t fAbbreviatedDayPeriodsCount;
870
874 UnicodeString *fWideDayPeriods;
875 int32_t fWideDayPeriodsCount;
876
880 UnicodeString *fNarrowDayPeriods;
881 int32_t fNarrowDayPeriodsCount;
882
886 UnicodeString *fStandaloneAbbreviatedDayPeriods;
887 int32_t fStandaloneAbbreviatedDayPeriodsCount;
888
892 UnicodeString *fStandaloneWideDayPeriods;
893 int32_t fStandaloneWideDayPeriodsCount;
894
898 UnicodeString *fStandaloneNarrowDayPeriods;
899 int32_t fStandaloneNarrowDayPeriodsCount;
900
901 private:
905 char validLocale[ULOC_FULLNAME_CAPACITY];
906 char actualLocale[ULOC_FULLNAME_CAPACITY];
907
908 DateFormatSymbols(); // default constructor not implemented
909
919 void initializeData(const Locale& locale, const char *type, UErrorCode& status, UBool useLastResortData = FALSE);
920
929 static void assignArray(UnicodeString*& dstArray,
930 int32_t& dstCount,
931 const UnicodeString* srcArray,
932 int32_t srcCount);
933
944 static UBool arrayCompare(const UnicodeString* array1,
945 const UnicodeString* array2,
946 int32_t count);
947
953 void createZoneStrings(const UnicodeString *const * otherStrings);
954
958 void dispose(void);
959
964 void copyData(const DateFormatSymbols& other);
965
969 void initZoneStringsArray(void);
970
974 void disposeZoneStrings(void);
975
980 static UDateFormatField U_EXPORT2 getPatternCharIndex(UChar c);
981
985 static UBool U_EXPORT2 isNumericField(UDateFormatField f, int32_t count);
986
990 static UBool U_EXPORT2 isNumericPatternChar(UChar c, int32_t count);
991 public:
992 #ifndef U_HIDE_INTERNAL_API
993
1004 static DateFormatSymbols * U_EXPORT2 createForLocale(
1005 const Locale &locale, UErrorCode &status);
1006 #endif /* U_HIDE_INTERNAL_API */
1007 };
1008
1009 U_NAMESPACE_END
1010
1011 #endif /* #if !UCONFIG_NO_FORMATTING */
1012
1013 #endif // _DTFMTSYM
1014 //eof
icu::UObject::getDynamicClassID
virtual UClassID getDynamicClassID() const
ICU4C "poor man&#39;s RTTI", returns a UClassID for the actual ICU class.
icu::DateFormatSymbols
DateFormatSymbols is a public class for encapsulating localizable date-time formatting data – includ...
Definition: dtfmtsym.h:81
icu::DateFormatSymbols::SHORT
Short width is currently only supported for weekday names.
Definition: dtfmtsym.h:298
icu::DateFormatSymbols::EMonthPatternType
EMonthPatternType
Somewhat temporary constants for leap month pattern types, adequate for supporting just leap month pa...
Definition: dtfmtsym.h:512
icu::operator==
U_EXPORT UBool operator==(const StringPiece &x, const StringPiece &y)
Global operator == for StringPiece.
UClassID
void * UClassID
UClassID is used to identify classes without using the compiler&#39;s RTTI.
Definition: uobject.h:93
ULOC_FULLNAME_CAPACITY
#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
icu::DateFormatSymbols::DtContextType
DtContextType
Selector for date formatting context.
Definition: dtfmtsym.h:274
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:360
U_NAMESPACE_BEGIN
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition: uversion.h:131
calendar.h
C++ API: Calendar object.
udat.h
C API: DateFormat.
uobject.h
C++ API: Common ICU base class UObject.
UChar
uint16_t UChar
Define UChar to be UCHAR_TYPE, if that is #defined (for example, to char16_t), or wchar_t if that is ...
Definition: umachine.h:337
U_NAMESPACE_END
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
Definition: uversion.h:132
UDateFormatField
UDateFormatField
FieldPosition and UFieldPosition selectors for format fields defined by DateFormat and UDateFormat...
Definition: udat.h:490
icu::DateFormatSymbols::DtWidthType
DtWidthType
Selector for date formatting width.
Definition: dtfmtsym.h:290
UErrorCode
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers...
Definition: utypes.h:396
icu::SimpleDateFormat
SimpleDateFormat is a concrete class for formatting and parsing dates in a language-independent manne...
Definition: smpdtfmt.h:719
ULocDataLocaleType
ULocDataLocaleType
Constants for *_getLocale() Allow user to select whether she wants information on requested...
Definition: uloc.h:338
locid.h
C++ API: Locale ID object.
utypes.h
Basic definitions for ICU, for both C and C++ APIs.
icu::DateFormatSymbols::operator!=
UBool operator!=(const DateFormatSymbols &other) const
Return true if another object is semantically unequal to this one.
Definition: dtfmtsym.h:183
FALSE
#define FALSE
The FALSE value of a UBool.
Definition: umachine.h:267
icu::UnicodeString
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition: unistr.h:295
icu::DateFormatSymbols::ECapitalizationContextUsageType
ECapitalizationContextUsageType
Constants for capitalization context usage types.
Definition: dtfmtsym.h:604
icu::UObject
UObject is the common ICU "boilerplate" class.
Definition: uobject.h:223
ures.h
C API: Resource Bundle.
UBool
int8_t UBool
The ICU boolean type.
Definition: umachine.h:259
icu::Locale
A Locale object represents a specific geographical, political, or cultural region.
Definition: locid.h:187