ICU 56.1: dtfmtsym.h Source File

ICU 56.1 56.1

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

- File List
- Globals

dtfmtsym.h
Go to the documentation of this file.
1 /*
2 ********************************************************************************
3 * Copyright (C) 1997-2015, 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
36 U_NAMESPACE_BEGIN
37
38 /* forward declaration */
39 class SimpleDateFormat;
40 class Hashtable;
41
79 class U_I18N_API DateFormatSymbols U_FINAL : public UObject {
80 public:
94 DateFormatSymbols(UErrorCode& status);
95
106 DateFormatSymbols(const Locale& locale,
107 UErrorCode& status);
108
109 #ifndef U_HIDE_INTERNAL_API
110
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
150 DateFormatSymbols(const DateFormatSymbols&);
151
156 DateFormatSymbols& operator=(const DateFormatSymbols&);
157
163 virtual ~DateFormatSymbols();
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
272 enum DtContextType {
273 FORMAT,
274 STANDALONE,
275 DT_CONTEXT_COUNT
276 };
277
282 enum DtWidthType {
283 ABBREVIATED,
284 WIDE,
285 NARROW,
290 SHORT,
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
412
417 static const UChar DEFAULT_TIME_SEPARATOR = 0x003a; // ':'
418
423 static const UChar ALTERNATE_TIME_SEPARATOR = 0x002e; // '.'
424 #endif /* U_HIDE_INTERNAL_API */
425
426 #ifndef U_HIDE_DRAFT_API
427
433 UnicodeString& getTimeSeparatorString(UnicodeString& result) const;
434
440 void setTimeSeparatorString(const UnicodeString& newTimeSeparator);
441 #endif /* U_HIDE_DRAFT_API */
442
453 const UnicodeString* getYearNames(int32_t& count,
454 DtContextType context, DtWidthType width) const;
455
465 void setYearNames(const UnicodeString* yearNames, int32_t count,
466 DtContextType context, DtWidthType width);
467
478 const UnicodeString* getZodiacNames(int32_t& count,
479 DtContextType context, DtWidthType width) const;
480
490 void setZodiacNames(const UnicodeString* zodiacNames, int32_t count,
491 DtContextType context, DtWidthType width);
492
493 #ifndef U_HIDE_INTERNAL_API
494
502 enum EMonthPatternType
503 {
504 kLeapMonthPatternFormatWide,
505 kLeapMonthPatternFormatAbbrev,
506 kLeapMonthPatternFormatNarrow,
507 kLeapMonthPatternStandaloneWide,
508 kLeapMonthPatternStandaloneAbbrev,
509 kLeapMonthPatternStandaloneNarrow,
510 kLeapMonthPatternNumeric,
511 kMonthPatternsCount
512 };
513
526 const UnicodeString* getLeapMonthPatterns(int32_t& count) const;
527
528 #endif /* U_HIDE_INTERNAL_API */
529
530 #ifndef U_HIDE_DEPRECATED_API
531
538 const UnicodeString** getZoneStrings(int32_t& rowCount, int32_t& columnCount) const;
539 #endif /* U_HIDE_DEPRECATED_API */
540
552 void setZoneStrings(const UnicodeString* const* strings, int32_t rowCount, int32_t columnCount);
553
559 static const UChar * U_EXPORT2 getPatternUChars(void);
560
571 UnicodeString& getLocalPatternChars(UnicodeString& result) const;
572
579 void setLocalPatternChars(const UnicodeString& newLocalPatternChars);
580
586 Locale getLocale(ULocDataLocaleType type, UErrorCode& status) const;
587
588 /* The following type and kCapContextUsageTypeCount cannot be #ifndef U_HIDE_INTERNAL_API,
589 they are needed for .h file declarations. */
594 enum ECapitalizationContextUsageType
595 {
596 #ifndef U_HIDE_INTERNAL_API
597 kCapContextUsageOther = 0,
598 kCapContextUsageMonthFormat, /* except narrow */
599 kCapContextUsageMonthStandalone, /* except narrow */
600 kCapContextUsageMonthNarrow,
601 kCapContextUsageDayFormat, /* except narrow */
602 kCapContextUsageDayStandalone, /* except narrow */
603 kCapContextUsageDayNarrow,
604 kCapContextUsageEraWide,
605 kCapContextUsageEraAbbrev,
606 kCapContextUsageEraNarrow,
607 kCapContextUsageZoneLong,
608 kCapContextUsageZoneShort,
609 kCapContextUsageMetazoneLong,
610 kCapContextUsageMetazoneShort,
611 #endif /* U_HIDE_INTERNAL_API */
612 kCapContextUsageTypeCount = 14
613 };
614
620 virtual UClassID getDynamicClassID() const;
621
627 static UClassID U_EXPORT2 getStaticClassID();
628
629 private:
630
631 friend class SimpleDateFormat;
632 friend class DateFormatSymbolsSingleSetter; // see udat.cpp
633
637 UnicodeString* fEras;
638 int32_t fErasCount;
639
643 UnicodeString* fEraNames;
644 int32_t fEraNamesCount;
645
649 UnicodeString* fNarrowEras;
650 int32_t fNarrowErasCount;
651
655 UnicodeString* fMonths;
656 int32_t fMonthsCount;
657
661 UnicodeString* fShortMonths;
662 int32_t fShortMonthsCount;
663
667 UnicodeString* fNarrowMonths;
668 int32_t fNarrowMonthsCount;
669
673 UnicodeString* fStandaloneMonths;
674 int32_t fStandaloneMonthsCount;
675
679 UnicodeString* fStandaloneShortMonths;
680 int32_t fStandaloneShortMonthsCount;
681
685 UnicodeString* fStandaloneNarrowMonths;
686 int32_t fStandaloneNarrowMonthsCount;
687
691 UnicodeString* fWeekdays;
692 int32_t fWeekdaysCount;
693
697 UnicodeString* fShortWeekdays;
698 int32_t fShortWeekdaysCount;
699
703 UnicodeString* fShorterWeekdays;
704 int32_t fShorterWeekdaysCount;
705
709 UnicodeString* fNarrowWeekdays;
710 int32_t fNarrowWeekdaysCount;
711
715 UnicodeString* fStandaloneWeekdays;
716 int32_t fStandaloneWeekdaysCount;
717
721 UnicodeString* fStandaloneShortWeekdays;
722 int32_t fStandaloneShortWeekdaysCount;
723
727 UnicodeString* fStandaloneShorterWeekdays;
728 int32_t fStandaloneShorterWeekdaysCount;
729
733 UnicodeString* fStandaloneNarrowWeekdays;
734 int32_t fStandaloneNarrowWeekdaysCount;
735
739 UnicodeString* fAmPms;
740 int32_t fAmPmsCount;
741
745 UnicodeString* fNarrowAmPms;
746 int32_t fNarrowAmPmsCount;
747
751 UnicodeString fTimeSeparator;
752
756 UnicodeString *fQuarters;
757 int32_t fQuartersCount;
758
762 UnicodeString *fShortQuarters;
763 int32_t fShortQuartersCount;
764
768 UnicodeString *fStandaloneQuarters;
769 int32_t fStandaloneQuartersCount;
770
774 UnicodeString *fStandaloneShortQuarters;
775 int32_t fStandaloneShortQuartersCount;
776
780 UnicodeString *fLeapMonthPatterns;
781 int32_t fLeapMonthPatternsCount;
782
788 UnicodeString *fShortYearNames;
789 int32_t fShortYearNamesCount;
790
796 UnicodeString *fShortZodiacNames;
797 int32_t fShortZodiacNamesCount;
798
836 UnicodeString **fZoneStrings; // Zone string array set by setZoneStrings
837 UnicodeString **fLocaleZoneStrings; // Zone string array created by the locale
838 int32_t fZoneStringsRowCount;
839 int32_t fZoneStringsColCount;
840
841 Locale fZSFLocale; // Locale used for getting ZoneStringFormat
842
846 UnicodeString fLocalPatternChars;
847
853 UBool fCapitalization[kCapContextUsageTypeCount][2];
854
855 private:
859 char validLocale[ULOC_FULLNAME_CAPACITY];
860 char actualLocale[ULOC_FULLNAME_CAPACITY];
861
862 DateFormatSymbols(); // default constructor not implemented
863
873 void initializeData(const Locale& locale, const char *type, UErrorCode& status, UBool useLastResortData = FALSE);
874
883 static void assignArray(UnicodeString*& dstArray,
884 int32_t& dstCount,
885 const UnicodeString* srcArray,
886 int32_t srcCount);
887
898 static UBool arrayCompare(const UnicodeString* array1,
899 const UnicodeString* array2,
900 int32_t count);
901
907 void createZoneStrings(const UnicodeString *const * otherStrings);
908
912 void dispose(void);
913
918 void copyData(const DateFormatSymbols& other);
919
923 void initZoneStringsArray(void);
924
928 void disposeZoneStrings(void);
929
934 static UDateFormatField U_EXPORT2 getPatternCharIndex(UChar c);
935
939 static UBool U_EXPORT2 isNumericField(UDateFormatField f, int32_t count);
940
944 static UBool U_EXPORT2 isNumericPatternChar(UChar c, int32_t count);
945 public:
946 #ifndef U_HIDE_INTERNAL_API
947
958 static DateFormatSymbols * U_EXPORT2 createForLocale(
959 const Locale &locale, UErrorCode &status);
960 #endif /* U_HIDE_INTERNAL_API */
961 };
962
963 U_NAMESPACE_END
964
965 #endif /* #if !UCONFIG_NO_FORMATTING */
966
967 #endif // _DTFMTSYM
968 //eof
icu::UObject::getDynamicClassID
virtual UClassID getDynamicClassID() const
ICU4C "poor man'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:79
icu::DateFormatSymbols::SHORT
Short width is currently only supported for weekday names.
Definition: dtfmtsym.h:290
icu::DateFormatSymbols::EMonthPatternType
EMonthPatternType
Somewhat temporary constants for leap month pattern types, adequate for supporting just leap month pa...
Definition: dtfmtsym.h:502
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's RTTI.
Definition: uobject.h:91
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:262
icu::DateFormatSymbols::DtContextType
DtContextType
Selector for date formatting context.
Definition: dtfmtsym.h:272
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:358
U_NAMESPACE_BEGIN
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition: uversion.h:129
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:312
U_NAMESPACE_END
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
Definition: uversion.h:130
UDateFormatField
UDateFormatField
FieldPosition and UFieldPosition selectors for format fields defined by DateFormat and UDateFormat...
Definition: udat.h:488
icu::DateFormatSymbols::DtWidthType
DtWidthType
Selector for date formatting width.
Definition: dtfmtsym.h:282
UErrorCode
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers...
Definition: utypes.h:476
icu::SimpleDateFormat
SimpleDateFormat is a concrete class for formatting and parsing dates in a language-independent manne...
Definition: smpdtfmt.h:717
ULocDataLocaleType
ULocDataLocaleType
Constants for *_getLocale() Allow user to select whether she wants information on requested...
Definition: uloc.h:336
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:181
FALSE
#define FALSE
The FALSE value of a UBool.
Definition: umachine.h:242
icu::UnicodeString
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition: unistr.h:293
icu::DateFormatSymbols::ECapitalizationContextUsageType
ECapitalizationContextUsageType
Constants for capitalization context usage types.
Definition: dtfmtsym.h:594
icu::UObject
UObject is the common ICU "boilerplate" class.
Definition: uobject.h:221
ures.h
C API: Resource Bundle.
UBool
int8_t UBool
The ICU boolean type.
Definition: umachine.h:234
icu::Locale
A Locale object represents a specific geographical, political, or cultural region.
Definition: locid.h:185