ICU 57.1  57.1
dtfmtsym.h
Go to the documentation of this file.
1 /*
2 ********************************************************************************
3 * Copyright (C) 1997-2016, International Business Machines
4 * Corporation and others. All Rights Reserved.
5 ********************************************************************************
6 *
7 * File DTFMTSYM.H
8 *
9 * Modification History:
10 *
11 * Date Name Description
12 * 02/19/97 aliu Converted from java.
13 * 07/21/98 stephen Added getZoneIndex()
14 * Changed to match C++ conventions
15 ********************************************************************************
16 */
17 
18 #ifndef DTFMTSYM_H
19 #define DTFMTSYM_H
20 
21 #include "unicode/utypes.h"
22 
23 #if !UCONFIG_NO_FORMATTING
24 
25 #include "unicode/calendar.h"
26 #include "unicode/uobject.h"
27 #include "unicode/locid.h"
28 #include "unicode/udat.h"
29 #include "unicode/ures.h"
30 
37 
38 /* forward declaration */
39 class SimpleDateFormat;
40 class Hashtable;
41 
79 class U_I18N_API DateFormatSymbols U_FINAL : public UObject {
80 public:
95 
106  DateFormatSymbols(const Locale& locale,
107  UErrorCode& status);
108 
109 #ifndef U_HIDE_INTERNAL_API
126  DateFormatSymbols(const char *type, UErrorCode& status);
127 
141  DateFormatSymbols(const Locale& locale,
142  const char *type,
143  UErrorCode& status);
144 #endif /* U_HIDE_INTERNAL_API */
145 
151 
157 
164 
172  UBool operator==(const DateFormatSymbols& other) const;
173 
181  UBool operator!=(const DateFormatSymbols& other) const { return !operator==(other); }
182 
190  const UnicodeString* getEras(int32_t& count) const;
191 
198  void setEras(const UnicodeString* eras, int32_t count);
199 
207  const UnicodeString* getEraNames(int32_t& count) const;
208 
215  void setEraNames(const UnicodeString* eraNames, int32_t count);
216 
224  const UnicodeString* getNarrowEras(int32_t& count) const;
225 
232  void setNarrowEras(const UnicodeString* narrowEras, int32_t count);
233 
240  const UnicodeString* getMonths(int32_t& count) const;
241 
249  void setMonths(const UnicodeString* months, int32_t count);
250 
258  const UnicodeString* getShortMonths(int32_t& count) const;
259 
266  void setShortMonths(const UnicodeString* shortMonths, int32_t count);
267 
273  FORMAT,
274  STANDALONE,
275  DT_CONTEXT_COUNT
276  };
277 
282  enum DtWidthType {
283  ABBREVIATED,
284  WIDE,
285  NARROW,
293  DT_WIDTH_COUNT = 4
294  };
295 
304  const UnicodeString* getMonths(int32_t& count, DtContextType context, DtWidthType width) const;
305 
315  void setMonths(const UnicodeString* months, int32_t count, DtContextType context, DtWidthType width);
316 
323  const UnicodeString* getWeekdays(int32_t& count) const;
324 
325 
332  void setWeekdays(const UnicodeString* weekdays, int32_t count);
333 
341  const UnicodeString* getShortWeekdays(int32_t& count) const;
342 
350  void setShortWeekdays(const UnicodeString* abbrevWeekdays, int32_t count);
351 
360  const UnicodeString* getWeekdays(int32_t& count, DtContextType context, DtWidthType width) const;
361 
370  void setWeekdays(const UnicodeString* weekdays, int32_t count, DtContextType context, DtWidthType width);
371 
381  const UnicodeString* getQuarters(int32_t& count, DtContextType context, DtWidthType width) const;
382 
393  void setQuarters(const UnicodeString* quarters, int32_t count, DtContextType context, DtWidthType width);
394 
401  const UnicodeString* getAmPmStrings(int32_t& count) const;
402 
409  void setAmPmStrings(const UnicodeString* ampms, int32_t count);
410 
411 #ifndef U_HIDE_INTERNAL_API
417  static const UChar DEFAULT_TIME_SEPARATOR = 0x003a; // ':'
418 
423  static const UChar ALTERNATE_TIME_SEPARATOR = 0x002e; // '.'
424 
432 
438  void setTimeSeparatorString(const UnicodeString& newTimeSeparator);
439 #endif /* U_HIDE_INTERNAL_API */
440 
451  const UnicodeString* getYearNames(int32_t& count,
452  DtContextType context, DtWidthType width) const;
453 
463  void setYearNames(const UnicodeString* yearNames, int32_t count,
464  DtContextType context, DtWidthType width);
465 
476  const UnicodeString* getZodiacNames(int32_t& count,
477  DtContextType context, DtWidthType width) const;
478 
488  void setZodiacNames(const UnicodeString* zodiacNames, int32_t count,
489  DtContextType context, DtWidthType width);
490 
491 #ifndef U_HIDE_INTERNAL_API
501  {
502  kLeapMonthPatternFormatWide,
503  kLeapMonthPatternFormatAbbrev,
504  kLeapMonthPatternFormatNarrow,
505  kLeapMonthPatternStandaloneWide,
506  kLeapMonthPatternStandaloneAbbrev,
507  kLeapMonthPatternStandaloneNarrow,
508  kLeapMonthPatternNumeric,
509  kMonthPatternsCount
510  };
511 
524  const UnicodeString* getLeapMonthPatterns(int32_t& count) const;
525 
526 #endif /* U_HIDE_INTERNAL_API */
527 
528 #ifndef U_HIDE_DEPRECATED_API
536  const UnicodeString** getZoneStrings(int32_t& rowCount, int32_t& columnCount) const;
537 #endif /* U_HIDE_DEPRECATED_API */
538 
550  void setZoneStrings(const UnicodeString* const* strings, int32_t rowCount, int32_t columnCount);
551 
557  static const UChar * U_EXPORT2 getPatternUChars(void);
558 
570 
577  void setLocalPatternChars(const UnicodeString& newLocalPatternChars);
578 
585 
586  /* The following type and kCapContextUsageTypeCount cannot be #ifndef U_HIDE_INTERNAL_API,
587  they are needed for .h file declarations. */
593  {
594 #ifndef U_HIDE_INTERNAL_API
595  kCapContextUsageOther = 0,
596  kCapContextUsageMonthFormat, /* except narrow */
597  kCapContextUsageMonthStandalone, /* except narrow */
598  kCapContextUsageMonthNarrow,
599  kCapContextUsageDayFormat, /* except narrow */
600  kCapContextUsageDayStandalone, /* except narrow */
601  kCapContextUsageDayNarrow,
602  kCapContextUsageEraWide,
603  kCapContextUsageEraAbbrev,
604  kCapContextUsageEraNarrow,
605  kCapContextUsageZoneLong,
606  kCapContextUsageZoneShort,
607  kCapContextUsageMetazoneLong,
608  kCapContextUsageMetazoneShort,
609 #endif /* U_HIDE_INTERNAL_API */
610  kCapContextUsageTypeCount = 14
611  };
612 
618  virtual UClassID getDynamicClassID() const;
619 
625  static UClassID U_EXPORT2 getStaticClassID();
626 
627 private:
628 
629  friend class SimpleDateFormat;
630  friend class DateFormatSymbolsSingleSetter; // see udat.cpp
631 
635  UnicodeString* fEras;
636  int32_t fErasCount;
637 
641  UnicodeString* fEraNames;
642  int32_t fEraNamesCount;
643 
647  UnicodeString* fNarrowEras;
648  int32_t fNarrowErasCount;
649 
653  UnicodeString* fMonths;
654  int32_t fMonthsCount;
655 
659  UnicodeString* fShortMonths;
660  int32_t fShortMonthsCount;
661 
665  UnicodeString* fNarrowMonths;
666  int32_t fNarrowMonthsCount;
667 
671  UnicodeString* fStandaloneMonths;
672  int32_t fStandaloneMonthsCount;
673 
677  UnicodeString* fStandaloneShortMonths;
678  int32_t fStandaloneShortMonthsCount;
679 
683  UnicodeString* fStandaloneNarrowMonths;
684  int32_t fStandaloneNarrowMonthsCount;
685 
689  UnicodeString* fWeekdays;
690  int32_t fWeekdaysCount;
691 
695  UnicodeString* fShortWeekdays;
696  int32_t fShortWeekdaysCount;
697 
701  UnicodeString* fShorterWeekdays;
702  int32_t fShorterWeekdaysCount;
703 
707  UnicodeString* fNarrowWeekdays;
708  int32_t fNarrowWeekdaysCount;
709 
713  UnicodeString* fStandaloneWeekdays;
714  int32_t fStandaloneWeekdaysCount;
715 
719  UnicodeString* fStandaloneShortWeekdays;
720  int32_t fStandaloneShortWeekdaysCount;
721 
725  UnicodeString* fStandaloneShorterWeekdays;
726  int32_t fStandaloneShorterWeekdaysCount;
727 
731  UnicodeString* fStandaloneNarrowWeekdays;
732  int32_t fStandaloneNarrowWeekdaysCount;
733 
737  UnicodeString* fAmPms;
738  int32_t fAmPmsCount;
739 
743  UnicodeString* fNarrowAmPms;
744  int32_t fNarrowAmPmsCount;
745 
749  UnicodeString fTimeSeparator;
750 
754  UnicodeString *fQuarters;
755  int32_t fQuartersCount;
756 
760  UnicodeString *fShortQuarters;
761  int32_t fShortQuartersCount;
762 
766  UnicodeString *fStandaloneQuarters;
767  int32_t fStandaloneQuartersCount;
768 
772  UnicodeString *fStandaloneShortQuarters;
773  int32_t fStandaloneShortQuartersCount;
774 
778  UnicodeString *fLeapMonthPatterns;
779  int32_t fLeapMonthPatternsCount;
780 
786  UnicodeString *fShortYearNames;
787  int32_t fShortYearNamesCount;
788 
794  UnicodeString *fShortZodiacNames;
795  int32_t fShortZodiacNamesCount;
796 
834  UnicodeString **fZoneStrings; // Zone string array set by setZoneStrings
835  UnicodeString **fLocaleZoneStrings; // Zone string array created by the locale
836  int32_t fZoneStringsRowCount;
837  int32_t fZoneStringsColCount;
838 
839  Locale fZSFLocale; // Locale used for getting ZoneStringFormat
840 
844  UnicodeString fLocalPatternChars;
845 
851  UBool fCapitalization[kCapContextUsageTypeCount][2];
852 
856  UnicodeString *fAbbreviatedDayPeriods;
857  int32_t fAbbreviatedDayPeriodsCount;
858 
862  UnicodeString *fWideDayPeriods;
863  int32_t fWideDayPeriodsCount;
864 
868  UnicodeString *fNarrowDayPeriods;
869  int32_t fNarrowDayPeriodsCount;
870 
874  UnicodeString *fStandaloneAbbreviatedDayPeriods;
875  int32_t fStandaloneAbbreviatedDayPeriodsCount;
876 
880  UnicodeString *fStandaloneWideDayPeriods;
881  int32_t fStandaloneWideDayPeriodsCount;
882 
886  UnicodeString *fStandaloneNarrowDayPeriods;
887  int32_t fStandaloneNarrowDayPeriodsCount;
888 
889 private:
893  char validLocale[ULOC_FULLNAME_CAPACITY];
894  char actualLocale[ULOC_FULLNAME_CAPACITY];
895 
896  DateFormatSymbols(); // default constructor not implemented
897 
907  void initializeData(const Locale& locale, const char *type, UErrorCode& status, UBool useLastResortData = FALSE);
908 
917  static void assignArray(UnicodeString*& dstArray,
918  int32_t& dstCount,
919  const UnicodeString* srcArray,
920  int32_t srcCount);
921 
932  static UBool arrayCompare(const UnicodeString* array1,
933  const UnicodeString* array2,
934  int32_t count);
935 
941  void createZoneStrings(const UnicodeString *const * otherStrings);
942 
946  void dispose(void);
947 
952  void copyData(const DateFormatSymbols& other);
953 
957  void initZoneStringsArray(void);
958 
962  void disposeZoneStrings(void);
963 
968  static UDateFormatField U_EXPORT2 getPatternCharIndex(UChar c);
969 
973  static UBool U_EXPORT2 isNumericField(UDateFormatField f, int32_t count);
974 
978  static UBool U_EXPORT2 isNumericPatternChar(UChar c, int32_t count);
979 public:
980 #ifndef U_HIDE_INTERNAL_API
992  static DateFormatSymbols * U_EXPORT2 createForLocale(
993  const Locale &locale, UErrorCode &status);
994 #endif /* U_HIDE_INTERNAL_API */
995 };
996 
998 
999 #endif /* #if !UCONFIG_NO_FORMATTING */
1000 
1001 #endif // _DTFMTSYM
1002 //eof
C++ API: Calendar object.
DateFormatSymbols is a public class for encapsulating localizable date-time formatting data – includi...
Definition: dtfmtsym.h:79
DateFormatSymbols(const Locale &locale, UErrorCode &status)
Construct a DateFormatSymbols object by loading format data from resources for the given locale,...
DateFormatSymbols(const DateFormatSymbols &)
Copy constructor.
void setQuarters(const UnicodeString *quarters, int32_t count, DtContextType context, DtWidthType width)
Sets quarter strings by width and context.
void setNarrowEras(const UnicodeString *narrowEras, int32_t count)
Sets narrow era strings.
virtual ~DateFormatSymbols()
Destructor.
DateFormatSymbols(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.
void setWeekdays(const UnicodeString *weekdays, int32_t count)
Sets wide weekday strings.
const UnicodeString * getEraNames(int32_t &count) const
Gets era name strings.
void setShortWeekdays(const UnicodeString *abbrevWeekdays, int32_t count)
Sets abbreviated weekday strings.
UnicodeString & getLocalPatternChars(UnicodeString &result) const
Gets localized date-time pattern characters.
const UnicodeString * getEras(int32_t &count) const
Gets abbreviated era strings.
static const UChar * getPatternUChars(void)
Get the non-localized date-time pattern characters.
const UnicodeString * getWeekdays(int32_t &count) const
Gets wide weekday strings.
static DateFormatSymbols * createForLocale(const Locale &locale, UErrorCode &status)
Gets a DateFormatSymbols by locale.
const UnicodeString * getAmPmStrings(int32_t &count) const
Gets AM/PM strings.
void setZoneStrings(const UnicodeString *const *strings, int32_t rowCount, int32_t columnCount)
Sets timezone strings.
ECapitalizationContextUsageType
Constants for capitalization context usage types.
Definition: dtfmtsym.h:593
const UnicodeString ** getZoneStrings(int32_t &rowCount, int32_t &columnCount) const
Gets timezone strings.
DateFormatSymbols(const Locale &locale, const char *type, UErrorCode &status)
Construct a DateFormatSymbols object by loading format data from resources for the given locale,...
UnicodeString & getTimeSeparatorString(UnicodeString &result) const
Gets the time separator string.
const UnicodeString * getQuarters(int32_t &count, DtContextType context, DtWidthType width) const
Gets quarter strings by width and context.
const UnicodeString * getShortMonths(int32_t &count) const
Gets short month strings.
UBool operator==(const DateFormatSymbols &other) const
Return true if another object is semantically equal to this one.
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.
void setMonths(const UnicodeString *months, int32_t count, DtContextType context, DtWidthType width)
Sets month strings by width and context.
EMonthPatternType
Somewhat temporary constants for leap month pattern types, adequate for supporting just leap month pa...
Definition: dtfmtsym.h:501
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.
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.
Locale getLocale(ULocDataLocaleType type, UErrorCode &status) const
Returns the locale for this object.
const UnicodeString * getMonths(int32_t &count) const
Gets month strings.
const UnicodeString * getNarrowEras(int32_t &count) const
Gets narrow era strings.
void setShortMonths(const UnicodeString *shortMonths, int32_t count)
Sets short month strings.
void setWeekdays(const UnicodeString *weekdays, int32_t count, DtContextType context, DtWidthType width)
Sets weekday strings by width and context.
void setAmPmStrings(const UnicodeString *ampms, int32_t count)
Sets ampm strings.
void setLocalPatternChars(const UnicodeString &newLocalPatternChars)
Sets localized date-time pattern characters.
void setEraNames(const UnicodeString *eraNames, int32_t count)
Sets era name strings.
DateFormatSymbols & operator=(const DateFormatSymbols &)
Assignment operator.
void setTimeSeparatorString(const UnicodeString &newTimeSeparator)
Sets the time separator string.
DtWidthType
Selector for date formatting width.
Definition: dtfmtsym.h:282
@ SHORT
Short width is currently only supported for weekday names.
Definition: dtfmtsym.h:290
UBool operator!=(const DateFormatSymbols &other) const
Return true if another object is semantically unequal to this one.
Definition: dtfmtsym.h:181
DateFormatSymbols(const char *type, UErrorCode &status)
Construct a DateFormatSymbols object by loading format data from resources for the default locale,...
DtContextType
Selector for date formatting context.
Definition: dtfmtsym.h:272
void setZodiacNames(const UnicodeString *zodiacNames, int32_t count, DtContextType context, DtWidthType width)
Sets calendar zodiac name strings by width and context.
void setEras(const UnicodeString *eras, int32_t count)
Sets abbreviated era strings.
const UnicodeString * getMonths(int32_t &count, DtContextType context, DtWidthType width) const
Gets month strings by width and context.
const UnicodeString * getShortWeekdays(int32_t &count) const
Gets abbreviated weekday strings.
void setYearNames(const UnicodeString *yearNames, int32_t count, DtContextType context, DtWidthType width)
Sets cyclic year name strings by width and context.
virtual UClassID getDynamicClassID() const
ICU "poor man's RTTI", returns a UClassID for the actual class.
const UnicodeString * getLeapMonthPatterns(int32_t &count) const
Somewhat temporary function for getting complete set of leap month patterns for all contexts & widths...
A Locale object represents a specific geographical, political, or cultural region.
Definition: locid.h:185
SimpleDateFormat is a concrete class for formatting and parsing dates in a language-independent manne...
Definition: smpdtfmt.h:717
UObject is the common ICU "boilerplate" class.
Definition: uobject.h:221
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition: unistr.h:294
C++ API: Locale ID object.
U_EXPORT UBool operator==(const StringPiece &x, const StringPiece &y)
Global operator == for StringPiece.
C API: DateFormat.
UDateFormatField
FieldPosition and UFieldPosition selectors for format fields defined by DateFormat and UDateFormat.
Definition: udat.h:488
#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:262
ULocDataLocaleType
Constants for *_getLocale() Allow user to select whether she wants information on requested,...
Definition: uloc.h:336
int8_t UBool
The ICU boolean type.
Definition: umachine.h:234
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:312
#define FALSE
The FALSE value of a UBool.
Definition: umachine.h:242
C++ API: Common ICU base class UObject.
void * UClassID
UClassID is used to identify classes without using the compiler's RTTI.
Definition: uobject.h:91
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:476
#define U_I18N_API
Set to export library symbols from inside the i18n library, and to import them from outside.
Definition: utypes.h:358
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
Definition: uversion.h:130
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition: uversion.h:129