dtfmtsym.h
Go to the documentation of this file.
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
********************************************************************************
* Copyright (C) 1997-2016, International Business Machines
* Corporation and others. All Rights Reserved.
********************************************************************************
*
* File DTFMTSYM.H
*
* Modification History:
*
* Date Name Description
* 02/19/97 aliu Converted from java.
* 07/21/98 stephen Added getZoneIndex()
* Changed to match C++ conventions
********************************************************************************
*/
#ifndef DTFMTSYM_H
#define DTFMTSYM_H
#include "unicode/utypes.h"
#if U_SHOW_CPLUSPLUS_API
#if !UCONFIG_NO_FORMATTING
#include "unicode/calendar.h"
#include "unicode/strenum.h"
#include "unicode/uobject.h"
#include "unicode/locid.h"
#include "unicode/udat.h"
#include "unicode/ures.h"
U_NAMESPACE_BEGIN
/* forward declaration */
class SimpleDateFormat;
class Hashtable;
class U_I18N_API DateFormatSymbols final : public UObject {
public:
DateFormatSymbols(UErrorCode& status);
DateFormatSymbols(const Locale& locale,
UErrorCode& status);
#ifndef U_HIDE_INTERNAL_API
DateFormatSymbols(const char *type, UErrorCode& status);
DateFormatSymbols(const Locale& locale,
const char *type,
UErrorCode& status);
#endif /* U_HIDE_INTERNAL_API */
DateFormatSymbols(const DateFormatSymbols&);
DateFormatSymbols& operator=(const DateFormatSymbols&);
virtual ~DateFormatSymbols();
bool operator==(const DateFormatSymbols& other) const;
bool operator!=(const DateFormatSymbols& other) const { return !operator==(other); }
const UnicodeString* getEras(int32_t& count) const;
void setEras(const UnicodeString* eras, int32_t count);
const UnicodeString* getEraNames(int32_t& count) const;
void setEraNames(const UnicodeString* eraNames, int32_t count);
const UnicodeString* getNarrowEras(int32_t& count) const;
void setNarrowEras(const UnicodeString* narrowEras, int32_t count);
const UnicodeString* getMonths(int32_t& count) const;
void setMonths(const UnicodeString* months, int32_t count);
const UnicodeString* getShortMonths(int32_t& count) const;
void setShortMonths(const UnicodeString* shortMonths, int32_t count);
enum DtContextType {
FORMAT,
STANDALONE,
#ifndef U_HIDE_DEPRECATED_API
DT_CONTEXT_COUNT
#endif // U_HIDE_DEPRECATED_API
};
enum DtWidthType {
ABBREVIATED,
WIDE,
NARROW,
SHORT,
#ifndef U_HIDE_DEPRECATED_API
DT_WIDTH_COUNT = 4
#endif // U_HIDE_DEPRECATED_API
};
const UnicodeString* getMonths(int32_t& count, DtContextType context, DtWidthType width) const;
void setMonths(const UnicodeString* months, int32_t count, DtContextType context, DtWidthType width);
const UnicodeString* getWeekdays(int32_t& count) const;
void setWeekdays(const UnicodeString* weekdays, int32_t count);
const UnicodeString* getShortWeekdays(int32_t& count) const;
void setShortWeekdays(const UnicodeString* abbrevWeekdays, int32_t count);
const UnicodeString* getWeekdays(int32_t& count, DtContextType context, DtWidthType width) const;
void setWeekdays(const UnicodeString* weekdays, int32_t count, DtContextType context, DtWidthType width);
const UnicodeString* getQuarters(int32_t& count, DtContextType context, DtWidthType width) const;
void setQuarters(const UnicodeString* quarters, int32_t count, DtContextType context, DtWidthType width);
const UnicodeString* getAmPmStrings(int32_t& count) const;
void setAmPmStrings(const UnicodeString* ampms, int32_t count);
#ifndef U_HIDE_INTERNAL_API
static const char16_t DEFAULT_TIME_SEPARATOR = 0x003a; // ':'
static const char16_t ALTERNATE_TIME_SEPARATOR = 0x002e; // '.'
UnicodeString& getTimeSeparatorString(UnicodeString& result) const;
void setTimeSeparatorString(const UnicodeString& newTimeSeparator);
#endif /* U_HIDE_INTERNAL_API */
const UnicodeString* getYearNames(int32_t& count,
DtContextType context, DtWidthType width) const;
void setYearNames(const UnicodeString* yearNames, int32_t count,
DtContextType context, DtWidthType width);
const UnicodeString* getZodiacNames(int32_t& count,
DtContextType context, DtWidthType width) const;
void setZodiacNames(const UnicodeString* zodiacNames, int32_t count,
DtContextType context, DtWidthType width);
#ifndef U_HIDE_INTERNAL_API
enum EMonthPatternType
{
kLeapMonthPatternFormatWide,
kLeapMonthPatternFormatAbbrev,
kLeapMonthPatternFormatNarrow,
kLeapMonthPatternStandaloneWide,
kLeapMonthPatternStandaloneAbbrev,
kLeapMonthPatternStandaloneNarrow,
kLeapMonthPatternNumeric,
kMonthPatternsCount
};
const UnicodeString* getLeapMonthPatterns(int32_t& count) const;
#endif /* U_HIDE_INTERNAL_API */
#ifndef U_HIDE_DEPRECATED_API
const UnicodeString** getZoneStrings(int32_t& rowCount, int32_t& columnCount) const;
#endif /* U_HIDE_DEPRECATED_API */
void setZoneStrings(const UnicodeString* const* strings, int32_t rowCount, int32_t columnCount);
static const char16_t * U_EXPORT2 getPatternUChars(void);
UnicodeString& getLocalPatternChars(UnicodeString& result) const;
void setLocalPatternChars(const UnicodeString& newLocalPatternChars);
Locale getLocale(ULocDataLocaleType type, UErrorCode& status) const;
/* The following type and kCapContextUsageTypeCount cannot be #ifndef U_HIDE_INTERNAL_API,
they are needed for .h file declarations. */
enum ECapitalizationContextUsageType
{
#ifndef U_HIDE_INTERNAL_API
kCapContextUsageOther = 0,
kCapContextUsageMonthFormat, /* except narrow */
kCapContextUsageMonthStandalone, /* except narrow */
kCapContextUsageMonthNarrow,
kCapContextUsageDayFormat, /* except narrow */
kCapContextUsageDayStandalone, /* except narrow */
kCapContextUsageDayNarrow,
kCapContextUsageEraWide,
kCapContextUsageEraAbbrev,
kCapContextUsageEraNarrow,
kCapContextUsageZoneLong,
kCapContextUsageZoneShort,
kCapContextUsageMetazoneLong,
kCapContextUsageMetazoneShort,
#endif /* U_HIDE_INTERNAL_API */
kCapContextUsageTypeCount = 14
};
virtual UClassID getDynamicClassID() const override;
static UClassID U_EXPORT2 getStaticClassID();
private:
friend class SimpleDateFormat;
friend class DateFormatSymbolsSingleSetter; // see udat.cpp
UnicodeString* fEras;
int32_t fErasCount;
UnicodeString* fEraNames;
int32_t fEraNamesCount;
UnicodeString* fNarrowEras;
int32_t fNarrowErasCount;
UnicodeString* fMonths;
int32_t fMonthsCount;
UnicodeString* fShortMonths;
int32_t fShortMonthsCount;
UnicodeString* fNarrowMonths;
int32_t fNarrowMonthsCount;
UnicodeString* fStandaloneMonths;
int32_t fStandaloneMonthsCount;
UnicodeString* fStandaloneShortMonths;
int32_t fStandaloneShortMonthsCount;
UnicodeString* fStandaloneNarrowMonths;
int32_t fStandaloneNarrowMonthsCount;
UnicodeString* fWeekdays;
int32_t fWeekdaysCount;
UnicodeString* fShortWeekdays;
int32_t fShortWeekdaysCount;
UnicodeString* fShorterWeekdays;
int32_t fShorterWeekdaysCount;
UnicodeString* fNarrowWeekdays;
int32_t fNarrowWeekdaysCount;
UnicodeString* fStandaloneWeekdays;
int32_t fStandaloneWeekdaysCount;
UnicodeString* fStandaloneShortWeekdays;
int32_t fStandaloneShortWeekdaysCount;
UnicodeString* fStandaloneShorterWeekdays;
int32_t fStandaloneShorterWeekdaysCount;
UnicodeString* fStandaloneNarrowWeekdays;
int32_t fStandaloneNarrowWeekdaysCount;
UnicodeString* fAmPms;
int32_t fAmPmsCount;
UnicodeString* fNarrowAmPms;
int32_t fNarrowAmPmsCount;
UnicodeString fTimeSeparator;
UnicodeString *fQuarters;
int32_t fQuartersCount;
UnicodeString *fShortQuarters;
int32_t fShortQuartersCount;
UnicodeString *fNarrowQuarters;
int32_t fNarrowQuartersCount;
UnicodeString *fStandaloneQuarters;
int32_t fStandaloneQuartersCount;
UnicodeString *fStandaloneShortQuarters;
int32_t fStandaloneShortQuartersCount;
UnicodeString *fStandaloneNarrowQuarters;
int32_t fStandaloneNarrowQuartersCount;
UnicodeString *fLeapMonthPatterns;
int32_t fLeapMonthPatternsCount;
UnicodeString *fShortYearNames;
int32_t fShortYearNamesCount;
UnicodeString *fShortZodiacNames;
int32_t fShortZodiacNamesCount;
UnicodeString **fZoneStrings; // Zone string array set by setZoneStrings
UnicodeString **fLocaleZoneStrings; // Zone string array created by the locale
int32_t fZoneStringsRowCount;
int32_t fZoneStringsColCount;
Locale fZSFLocale; // Locale used for getting ZoneStringFormat
UnicodeString fLocalPatternChars;
UBool fCapitalization[kCapContextUsageTypeCount][2];
UnicodeString *fAbbreviatedDayPeriods;
int32_t fAbbreviatedDayPeriodsCount;
UnicodeString *fWideDayPeriods;
int32_t fWideDayPeriodsCount;
UnicodeString *fNarrowDayPeriods;
int32_t fNarrowDayPeriodsCount;
UnicodeString *fStandaloneAbbreviatedDayPeriods;
int32_t fStandaloneAbbreviatedDayPeriodsCount;
UnicodeString *fStandaloneWideDayPeriods;
int32_t fStandaloneWideDayPeriodsCount;
UnicodeString *fStandaloneNarrowDayPeriods;
int32_t fStandaloneNarrowDayPeriodsCount;
private:
char validLocale[ULOC_FULLNAME_CAPACITY];
char actualLocale[ULOC_FULLNAME_CAPACITY];
DateFormatSymbols() = delete; // default constructor not implemented
void initializeData(const Locale& locale, const char *type,
UErrorCode& status, UBool useLastResortData = false);
static void assignArray(UnicodeString*& dstArray,
int32_t& dstCount,
const UnicodeString* srcArray,
int32_t srcCount);
static UBool arrayCompare(const UnicodeString* array1,
const UnicodeString* array2,
int32_t count);
void createZoneStrings(const UnicodeString *const * otherStrings);
void dispose(void);
void copyData(const DateFormatSymbols& other);
void initZoneStringsArray(void);
void disposeZoneStrings(void);
static UDateFormatField U_EXPORT2 getPatternCharIndex(char16_t c);
static UBool U_EXPORT2 isNumericField(UDateFormatField f, int32_t count);
static UBool U_EXPORT2 isNumericPatternChar(char16_t c, int32_t count);
public:
#ifndef U_HIDE_INTERNAL_API
static DateFormatSymbols * U_EXPORT2 createForLocale(
const Locale &locale, UErrorCode &status);
#endif /* U_HIDE_INTERNAL_API */
};
U_NAMESPACE_END
#endif /* #if !UCONFIG_NO_FORMATTING */
#endif /* U_SHOW_CPLUSPLUS_API */
#endif // _DTFMTSYM
//eof
calendar.h
C++ API: Calendar object.
icu::DateFormatSymbols
DateFormatSymbols is a public class for encapsulating localizable date-time formatting data – includi...
Definition: dtfmtsym.h:84
icu::DateFormatSymbols::getAmPmStrings
const UnicodeString * getAmPmStrings(int32_t &count) const
Gets AM/PM strings.
icu::DateFormatSymbols::setYearNames
void setYearNames(const UnicodeString *yearNames, int32_t count, DtContextType context, DtWidthType width)
Sets cyclic year name strings by width and context.
icu::DateFormatSymbols::setWeekdays
void setWeekdays(const UnicodeString *weekdays, int32_t count)
Sets wide weekday strings.
icu::DateFormatSymbols::getQuarters
const UnicodeString * getQuarters(int32_t &count, DtContextType context, DtWidthType width) const
Gets quarter strings by width and context.
icu::DateFormatSymbols::setShortMonths
void setShortMonths(const UnicodeString *shortMonths, int32_t count)
Sets short month strings.
icu::DateFormatSymbols::setLocalPatternChars
void setLocalPatternChars(const UnicodeString &newLocalPatternChars)
Sets localized date-time pattern characters.
icu::DateFormatSymbols::DateFormatSymbols
DateFormatSymbols(const char *type, UErrorCode &status)
Construct a DateFormatSymbols object by loading format data from resources for the default locale,...
icu::DateFormatSymbols::createForLocale
static DateFormatSymbols * createForLocale(const Locale &locale, UErrorCode &status)
Gets a DateFormatSymbols by locale.
icu::DateFormatSymbols::getLocalPatternChars
UnicodeString & getLocalPatternChars(UnicodeString &result) const
Gets localized date-time pattern characters.
icu::DateFormatSymbols::getEras
const UnicodeString * getEras(int32_t &count) const
Gets abbreviated era strings.
icu::DateFormatSymbols::getLocale
Locale getLocale(ULocDataLocaleType type, UErrorCode &status) const
Returns the locale for this object.
icu::DateFormatSymbols::getWeekdays
const UnicodeString * getWeekdays(int32_t &count, DtContextType context, DtWidthType width) const
Gets weekday strings by width and context.
icu::DateFormatSymbols::setEras
void setEras(const UnicodeString *eras, int32_t count)
Sets abbreviated era strings.
icu::DateFormatSymbols::setQuarters
void setQuarters(const UnicodeString *quarters, int32_t count, DtContextType context, DtWidthType width)
Sets quarter strings by width and context.
icu::DateFormatSymbols::getEraNames
const UnicodeString * getEraNames(int32_t &count) const
Gets era name strings.
icu::DateFormatSymbols::operator!=
bool operator!=(const DateFormatSymbols &other) const
Return true if another object is semantically unequal to this one.
Definition: dtfmtsym.h:186
icu::DateFormatSymbols::DateFormatSymbols
DateFormatSymbols(UErrorCode &status)
Construct a DateFormatSymbols object by loading format data from resources for the default locale,...
icu::DateFormatSymbols::setAmPmStrings
void setAmPmStrings(const UnicodeString *ampms, int32_t count)
Sets ampm strings.
icu::DateFormatSymbols::DtWidthType
DtWidthType
Selector for date formatting width.
Definition: dtfmtsym.h:293
icu::DateFormatSymbols::SHORT
@ SHORT
Short width is currently only supported for weekday names.
Definition: dtfmtsym.h:301
icu::DateFormatSymbols::operator=
DateFormatSymbols & operator=(const DateFormatSymbols &)
Assignment operator.
icu::DateFormatSymbols::getNarrowEras
const UnicodeString * getNarrowEras(int32_t &count) const
Gets narrow era strings.
icu::DateFormatSymbols::getShortWeekdays
const UnicodeString * getShortWeekdays(int32_t &count) const
Gets abbreviated weekday strings.
icu::DateFormatSymbols::setShortWeekdays
void setShortWeekdays(const UnicodeString *abbrevWeekdays, int32_t count)
Sets abbreviated weekday strings.
icu::DateFormatSymbols::getYearNames
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.
icu::DateFormatSymbols::getWeekdays
const UnicodeString * getWeekdays(int32_t &count) const
Gets wide weekday strings.
icu::DateFormatSymbols::getMonths
const UnicodeString * getMonths(int32_t &count) const
Gets month strings.
icu::DateFormatSymbols::getMonths
const UnicodeString * getMonths(int32_t &count, DtContextType context, DtWidthType width) const
Gets month strings by width and context.
icu::DateFormatSymbols::DateFormatSymbols
DateFormatSymbols(const Locale &locale, const char *type, UErrorCode &status)
Construct a DateFormatSymbols object by loading format data from resources for the given locale,...
icu::DateFormatSymbols::getZodiacNames
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.
icu::DateFormatSymbols::setZoneStrings
void setZoneStrings(const UnicodeString *const *strings, int32_t rowCount, int32_t columnCount)
Sets timezone strings.
icu::DateFormatSymbols::setNarrowEras
void setNarrowEras(const UnicodeString *narrowEras, int32_t count)
Sets narrow era strings.
icu::DateFormatSymbols::getPatternUChars
static const char16_t * getPatternUChars(void)
Get the non-localized date-time pattern characters.
icu::DateFormatSymbols::operator==
bool operator==(const DateFormatSymbols &other) const
Return true if another object is semantically equal to this one.
icu::DateFormatSymbols::getLeapMonthPatterns
const UnicodeString * getLeapMonthPatterns(int32_t &count) const
Somewhat temporary function for getting complete set of leap month patterns for all contexts & widths...
icu::DateFormatSymbols::DateFormatSymbols
DateFormatSymbols(const DateFormatSymbols &)
Copy constructor.
icu::DateFormatSymbols::getDynamicClassID
virtual UClassID getDynamicClassID() const override
ICU "poor man's RTTI", returns a UClassID for the actual class.
icu::DateFormatSymbols::setEraNames
void setEraNames(const UnicodeString *eraNames, int32_t count)
Sets era name strings.
icu::DateFormatSymbols::setMonths
void setMonths(const UnicodeString *months, int32_t count, DtContextType context, DtWidthType width)
Sets month strings by width and context.
icu::DateFormatSymbols::setTimeSeparatorString
void setTimeSeparatorString(const UnicodeString &newTimeSeparator)
Sets the time separator string.
icu::DateFormatSymbols::setZodiacNames
void setZodiacNames(const UnicodeString *zodiacNames, int32_t count, DtContextType context, DtWidthType width)
Sets calendar zodiac name strings by width and context.
icu::DateFormatSymbols::~DateFormatSymbols
virtual ~DateFormatSymbols()
Destructor.
icu::DateFormatSymbols::getStaticClassID
static UClassID getStaticClassID()
ICU "poor man's RTTI", returns a UClassID for this class.
icu::DateFormatSymbols::getTimeSeparatorString
UnicodeString & getTimeSeparatorString(UnicodeString &result) const
Gets the time separator string.
icu::DateFormatSymbols::setMonths
void setMonths(const UnicodeString *months, int32_t count)
Sets month strings.
icu::DateFormatSymbols::setWeekdays
void setWeekdays(const UnicodeString *weekdays, int32_t count, DtContextType context, DtWidthType width)
Sets weekday strings by width and context.
icu::DateFormatSymbols::DtContextType
DtContextType
Selector for date formatting context.
Definition: dtfmtsym.h:277
icu::DateFormatSymbols::ECapitalizationContextUsageType
ECapitalizationContextUsageType
Constants for capitalization context usage types.
Definition: dtfmtsym.h:606
icu::DateFormatSymbols::DateFormatSymbols
DateFormatSymbols(const Locale &locale, UErrorCode &status)
Construct a DateFormatSymbols object by loading format data from resources for the given locale,...
icu::DateFormatSymbols::EMonthPatternType
EMonthPatternType
Somewhat temporary constants for leap month pattern types, adequate for supporting just leap month pa...
Definition: dtfmtsym.h:514
icu::DateFormatSymbols::getShortMonths
const UnicodeString * getShortMonths(int32_t &count) const
Gets short month strings.
icu::DateFormatSymbols::getZoneStrings
const UnicodeString ** getZoneStrings(int32_t &rowCount, int32_t &columnCount) const
Gets timezone strings.
icu::Locale
A Locale object represents a specific geographical, political, or cultural region.
Definition: locid.h:195
icu::SimpleDateFormat
SimpleDateFormat is a concrete class for formatting and parsing dates in a language-independent manne...
Definition: smpdtfmt.h:727
icu::UObject
UObject is the common ICU "boilerplate" class.
Definition: uobject.h:223
icu::UnicodeString
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition: unistr.h:296
locid.h
C++ API: Locale ID object.
icu::operator==
U_EXPORT UBool operator==(const StringPiece &x, const StringPiece &y)
Global operator == for StringPiece.
strenum.h
C++ API: String Enumeration.
udat.h
C API: DateFormat.
UDateFormatField
UDateFormatField
FieldPosition and UFieldPosition selectors for format fields defined by DateFormat and UDateFormat.
Definition: udat.h:515
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
ULocDataLocaleType
ULocDataLocaleType
Constants for *_getLocale() Allow user to select whether she wants information on requested,...
Definition: uloc.h:338
UBool
int8_t UBool
The ICU boolean type, a signed-byte integer.
Definition: umachine.h:247
uobject.h
C++ API: Common ICU base class UObject.
UClassID
void * UClassID
UClassID is used to identify classes without using the compiler's RTTI.
Definition: uobject.h:96
ures.h
C API: Resource Bundle.
utypes.h
Basic definitions for ICU, for both C and C++ APIs.
UErrorCode
UErrorCode
Standard ICU4C error code type, a substitute for exceptions.
Definition: utypes.h:415
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:301