ICU 50.2 50.2
dtfmtsym.h
Go to the documentation of this file.
1/*
2********************************************************************************
3* Copyright (C) 1997-2012, 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
35
37
38/* forward declaration */
40class Hashtable;
41
80public:
95
107 UErrorCode& status);
108
109#ifndef U_HIDE_INTERNAL_API
126 DateFormatSymbols(const char *type, UErrorCode& status);
127
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
283 ABBREVIATED,
284 WIDE,
285 NARROW,
286 DT_WIDTH_COUNT
287 };
288
297 const UnicodeString* getMonths(int32_t& count, DtContextType context, DtWidthType width) const;
298
308 void setMonths(const UnicodeString* months, int32_t count, DtContextType context, DtWidthType width);
309
316 const UnicodeString* getWeekdays(int32_t& count) const;
317
318
325 void setWeekdays(const UnicodeString* weekdays, int32_t count);
326
333 const UnicodeString* getShortWeekdays(int32_t& count) const;
334
341 void setShortWeekdays(const UnicodeString* shortWeekdays, int32_t count);
342
351 const UnicodeString* getWeekdays(int32_t& count, DtContextType context, DtWidthType width) const;
352
361 void setWeekdays(const UnicodeString* weekdays, int32_t count, DtContextType context, DtWidthType width);
362
372 const UnicodeString* getQuarters(int32_t& count, DtContextType context, DtWidthType width) const;
373
384 void setQuarters(const UnicodeString* quarters, int32_t count, DtContextType context, DtWidthType width);
385
392 const UnicodeString* getAmPmStrings(int32_t& count) const;
393
400 void setAmPmStrings(const UnicodeString* ampms, int32_t count);
401
402#ifndef U_HIDE_INTERNAL_API
412 {
413 kLeapMonthPatternFormatWide,
414 kLeapMonthPatternFormatAbbrev,
415 kLeapMonthPatternFormatNarrow,
416 kLeapMonthPatternStandaloneWide,
417 kLeapMonthPatternStandaloneAbbrev,
418 kLeapMonthPatternStandaloneNarrow,
419 kLeapMonthPatternNumeric,
420 kMonthPatternsCount
421 };
422
435 const UnicodeString* getLeapMonthPatterns(int32_t& count) const;
436
437#endif /* U_HIDE_INTERNAL_API */
438
439#ifndef U_HIDE_DEPRECATED_API
447 const UnicodeString** getZoneStrings(int32_t& rowCount, int32_t& columnCount) const;
448#endif /* U_HIDE_DEPRECATED_API */
449
461 void setZoneStrings(const UnicodeString* const* strings, int32_t rowCount, int32_t columnCount);
462
468 static const UChar * U_EXPORT2 getPatternUChars(void);
469
481
488 void setLocalPatternChars(const UnicodeString& newLocalPatternChars);
489
496
497#ifndef U_HIDE_INTERNAL_API
503 {
504 kCapContextUsageOther,
505 kCapContextUsageMonthFormat, /* except narrow */
506 kCapContextUsageMonthStandalone, /* except narrow */
507 kCapContextUsageMonthNarrow,
508 kCapContextUsageDayFormat, /* except narrow */
509 kCapContextUsageDayStandalone, /* except narrow */
510 kCapContextUsageDayNarrow,
511 kCapContextUsageEraWide,
512 kCapContextUsageEraAbbrev,
513 kCapContextUsageEraNarrow,
514 kCapContextUsageZoneLong,
515 kCapContextUsageZoneShort,
516 kCapContextUsageMetazoneLong,
517 kCapContextUsageMetazoneShort,
518 kCapContextUsageTypeCount
519 };
520#endif /* U_HIDE_INTERNAL_API */
521
528
534 static UClassID U_EXPORT2 getStaticClassID();
535
536private:
537
538 friend class SimpleDateFormat;
539 friend class DateFormatSymbolsSingleSetter; // see udat.cpp
540
544 UnicodeString* fEras;
545 int32_t fErasCount;
546
550 UnicodeString* fEraNames;
551 int32_t fEraNamesCount;
552
556 UnicodeString* fNarrowEras;
557 int32_t fNarrowErasCount;
558
562 UnicodeString* fMonths;
563 int32_t fMonthsCount;
564
568 UnicodeString* fShortMonths;
569 int32_t fShortMonthsCount;
570
574 UnicodeString* fNarrowMonths;
575 int32_t fNarrowMonthsCount;
576
580 UnicodeString* fStandaloneMonths;
581 int32_t fStandaloneMonthsCount;
582
586 UnicodeString* fStandaloneShortMonths;
587 int32_t fStandaloneShortMonthsCount;
588
592 UnicodeString* fStandaloneNarrowMonths;
593 int32_t fStandaloneNarrowMonthsCount;
594
598 UnicodeString* fWeekdays;
599 int32_t fWeekdaysCount;
600
604 UnicodeString* fShortWeekdays;
605 int32_t fShortWeekdaysCount;
606
610 UnicodeString* fNarrowWeekdays;
611 int32_t fNarrowWeekdaysCount;
612
616 UnicodeString* fStandaloneWeekdays;
617 int32_t fStandaloneWeekdaysCount;
618
622 UnicodeString* fStandaloneShortWeekdays;
623 int32_t fStandaloneShortWeekdaysCount;
624
628 UnicodeString* fStandaloneNarrowWeekdays;
629 int32_t fStandaloneNarrowWeekdaysCount;
630
634 UnicodeString* fAmPms;
635 int32_t fAmPmsCount;
636
640 UnicodeString *fQuarters;
641 int32_t fQuartersCount;
642
646 UnicodeString *fShortQuarters;
647 int32_t fShortQuartersCount;
648
652 UnicodeString *fStandaloneQuarters;
653 int32_t fStandaloneQuartersCount;
654
658 UnicodeString *fStandaloneShortQuarters;
659 int32_t fStandaloneShortQuartersCount;
660
664 UnicodeString *fLeapMonthPatterns;
665 int32_t fLeapMonthPatternsCount;
666
670 UnicodeString* fShortYearNames;
671 int32_t fShortYearNamesCount;
672
710 UnicodeString **fZoneStrings; // Zone string array set by setZoneStrings
711 UnicodeString **fLocaleZoneStrings; // Zone string array created by the locale
712 int32_t fZoneStringsRowCount;
713 int32_t fZoneStringsColCount;
714
715 Locale fZSFLocale; // Locale used for getting ZoneStringFormat
716
720 UnicodeString fLocalPatternChars;
721
722#ifndef U_HIDE_INTERNAL_API
728 UBool fCapitalization[kCapContextUsageTypeCount][2];
729#endif
730
731
732private:
736 char validLocale[ULOC_FULLNAME_CAPACITY];
737 char actualLocale[ULOC_FULLNAME_CAPACITY];
738
739 DateFormatSymbols(); // default constructor not implemented
740
750 void initializeData(const Locale& locale, const char *type, UErrorCode& status, UBool useLastResortData = FALSE);
751
760 static void assignArray(UnicodeString*& dstArray,
761 int32_t& dstCount,
762 const UnicodeString* srcArray,
763 int32_t srcCount);
764
775 static UBool arrayCompare(const UnicodeString* array1,
776 const UnicodeString* array2,
777 int32_t count);
778
784 void createZoneStrings(const UnicodeString *const * otherStrings);
785
789 void dispose(void);
790
795 void copyData(const DateFormatSymbols& other);
796
800 void initZoneStringsArray(void);
801
805 void disposeZoneStrings(void);
806
811 static UDateFormatField U_EXPORT2 getPatternCharIndex(UChar c);
812
816 static UBool U_EXPORT2 isNumericField(UDateFormatField f, int32_t count);
817
821 static UBool U_EXPORT2 isNumericPatternChar(UChar c, int32_t count);
822};
823
825
826#endif /* #if !UCONFIG_NO_FORMATTING */
827
828#endif // _DTFMTSYM
829//eof
C++ API: Calendar object.
DateFormatSymbols(const Locale &locale, UErrorCode &status)
Construct a DateFormatSymbols object by loading format data from resources for the given locale,...
const UnicodeString * getAmPmStrings(int32_t &count) const
Gets AM/PM strings.
DateFormatSymbols(const DateFormatSymbols &)
Copy constructor.
const UnicodeString * getShortMonths(int32_t &count) const
Gets short month strings.
const UnicodeString * getQuarters(int32_t &count, DtContextType context, DtWidthType width) const
Gets quarter strings by width and context.
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,...
static const UChar * getPatternUChars(void)
Get the non-localized date-time pattern characters.
void setWeekdays(const UnicodeString *weekdays, int32_t count)
Sets weekday strings.
const UnicodeString * getLeapMonthPatterns(int32_t &count) const
Somewhat temporary function for getting complete set of leap month patterns for all contexts & widths...
const UnicodeString * getWeekdays(int32_t &count, DtContextType context, DtWidthType width) const
Gets weekday strings by width and context.
void setZoneStrings(const UnicodeString *const *strings, int32_t rowCount, int32_t columnCount)
Sets timezone strings.
UnicodeString & getLocalPatternChars(UnicodeString &result) const
Gets localized date-time pattern characters.
ECapitalizationContextUsageType
Constants for capitalization context usage types.
Definition dtfmtsym.h:503
const UnicodeString * getShortWeekdays(int32_t &count) const
Gets short weekday strings.
DateFormatSymbols(const Locale &locale, const char *type, UErrorCode &status)
Construct a DateFormatSymbols object by loading format data from resources for the given locale,...
const UnicodeString * getMonths(int32_t &count, DtContextType context, DtWidthType width) const
Gets month strings by width and context.
UBool operator==(const DateFormatSymbols &other) const
Return true if another object is semantically equal to this one.
const UnicodeString * getEras(int32_t &count) const
Gets abbreviated era strings.
const UnicodeString * getMonths(int32_t &count) const
Gets month strings.
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:412
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 * getNarrowEras(int32_t &count) const
Gets narrow era strings.
Locale getLocale(ULocDataLocaleType type, UErrorCode &status) const
Returns the locale for this object.
const UnicodeString * getEraNames(int32_t &count) const
Gets era name 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.
const UnicodeString * getWeekdays(int32_t &count) const
Gets weekday strings.
void setLocalPatternChars(const UnicodeString &newLocalPatternChars)
Sets localized date-time pattern characters.
void setEraNames(const UnicodeString *eraNames, int32_t count)
Sets era name strings.
const UnicodeString ** getZoneStrings(int32_t &rowCount, int32_t &columnCount) const
Gets timezone strings.
DtWidthType
Selector for date formatting width.
Definition dtfmtsym.h:282
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 setShortWeekdays(const UnicodeString *shortWeekdays, int32_t count)
Sets short weekday strings.
void setEras(const UnicodeString *eras, int32_t count)
Sets abbreviated era strings.
virtual UClassID getDynamicClassID() const
ICU "poor man's RTTI", returns a UClassID for the actual class.
DateFormatSymbols & operator=(const DateFormatSymbols &)
Assignment operator.
A Locale object represents a specific geographical, political, or cultural region.
Definition locid.h:182
SimpleDateFormat is a concrete class for formatting and parsing dates in a language-independent manne...
Definition smpdtfmt.h:227
UObject is the common ICU "boilerplate" class.
Definition uobject.h:229
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition unistr.h:247
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:473
#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:200
#define FALSE
The FALSE value of a UBool.
Definition umachine.h:208
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:278
C++ API: Common ICU base class UObject.
void * UClassID
UClassID is used to identify classes without using the compiler's RTTI.
Definition uobject.h:96
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