ICU 71.1 71.1

tznames.h
Go to the documentation of this file.
1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
3 /*
4 *******************************************************************************
5 * Copyright (C) 2011-2016, International Business Machines Corporation and
6 * others. All Rights Reserved.
7 *******************************************************************************
8 */
9 #ifndef __TZNAMES_H
10 #define __TZNAMES_H
11
16 #include "unicode/utypes.h"
17
18 #if U_SHOW_CPLUSPLUS_API
19
20 #if !UCONFIG_NO_FORMATTING
21
22 #include "unicode/uloc.h"
23 #include "unicode/unistr.h"
24
25 U_CDECL_BEGIN
26
31 typedef enum UTimeZoneNameType {
36 UTZNM_UNKNOWN = 0x00,
41 UTZNM_LONG_GENERIC = 0x01,
46 UTZNM_LONG_STANDARD = 0x02,
51 UTZNM_LONG_DAYLIGHT = 0x04,
56 UTZNM_SHORT_GENERIC = 0x08,
61 UTZNM_SHORT_STANDARD = 0x10,
66 UTZNM_SHORT_DAYLIGHT = 0x20,
71 UTZNM_EXEMPLAR_LOCATION = 0x40
72 } UTimeZoneNameType;
73
74 U_CDECL_END
75
76 U_NAMESPACE_BEGIN
77
78 class UVector;
79 struct MatchInfo;
80
131 class U_I18N_API TimeZoneNames : public UObject {
132 public:
137 virtual ~TimeZoneNames();
138
145 virtual bool operator==(const TimeZoneNames& other) const = 0;
146
154 bool operator!=(const TimeZoneNames& other) const { return !operator==(other); }
155
162 virtual TimeZoneNames* clone() const = 0;
163
172 static TimeZoneNames* U_EXPORT2 createInstance(const Locale& locale, UErrorCode& status);
173
184 static TimeZoneNames* U_EXPORT2 createTZDBInstance(const Locale& locale, UErrorCode& status);
185
192 virtual StringEnumeration* getAvailableMetaZoneIDs(UErrorCode& status) const = 0;
193
201 virtual StringEnumeration* getAvailableMetaZoneIDs(const UnicodeString& tzID, UErrorCode& status) const = 0;
202
213 virtual UnicodeString& getMetaZoneID(const UnicodeString& tzID, UDate date, UnicodeString& mzID) const = 0;
214
231 virtual UnicodeString& getReferenceZoneID(const UnicodeString& mzID, const char* region, UnicodeString& tzID) const = 0;
232
243 virtual UnicodeString& getMetaZoneDisplayName(const UnicodeString& mzID, UTimeZoneNameType type, UnicodeString& name) const = 0;
244
255 virtual UnicodeString& getTimeZoneDisplayName(const UnicodeString& tzID, UTimeZoneNameType type, UnicodeString& name) const = 0;
256
276 virtual UnicodeString& getExemplarLocationName(const UnicodeString& tzID, UnicodeString& name) const;
277
293 virtual UnicodeString& getDisplayName(const UnicodeString& tzID, UTimeZoneNameType type, UDate date, UnicodeString& name) const;
294
298 virtual void loadAllDisplayNames(UErrorCode& status);
299
303 virtual void getDisplayNames(const UnicodeString& tzID, const UTimeZoneNameType types[], int32_t numTypes, UDate date, UnicodeString dest[], UErrorCode& status) const;
304
310 class U_I18N_API MatchInfoCollection : public UMemory {
311 public:
316 MatchInfoCollection();
321 virtual ~MatchInfoCollection();
322
323 #ifndef U_HIDE_INTERNAL_API
324
332 void addZone(UTimeZoneNameType nameType, int32_t matchLength,
333 const UnicodeString& tzID, UErrorCode& status);
334
343 void addMetaZone(UTimeZoneNameType nameType, int32_t matchLength,
344 const UnicodeString& mzID, UErrorCode& status);
345
351 int32_t size() const;
352
361 UTimeZoneNameType getNameTypeAt(int32_t idx) const;
362
370 int32_t getMatchLengthAt(int32_t idx) const;
371
379 UBool getTimeZoneIDAt(int32_t idx, UnicodeString& tzID) const;
380
388 UBool getMetaZoneIDAt(int32_t idx, UnicodeString& mzID) const;
389 #endif /* U_HIDE_INTERNAL_API */
390
391 private:
392 UVector* fMatches; // vector of MatchEntry
393
394 UVector* matches(UErrorCode& status);
395 };
396
410 virtual MatchInfoCollection* find(const UnicodeString& text, int32_t start, uint32_t types, UErrorCode& status) const = 0;
411 };
412
413 U_NAMESPACE_END
414
415 #endif
416
417 #endif /* U_SHOW_CPLUSPLUS_API */
418
419 #endif
UTZNM_LONG_STANDARD
@ UTZNM_LONG_STANDARD
Long display name for standard time, such as "Eastern Standard Time".
Definition: tznames.h:46
UTZNM_EXEMPLAR_LOCATION
@ UTZNM_EXEMPLAR_LOCATION
Exemplar location name, such as "Los Angeles".
Definition: tznames.h:71
utypes.h
Basic definitions for ICU, for both C and C++ APIs.
U_I18N_API
#define U_I18N_API
Definition: utypes.h:301
UBool
int8_t UBool
The ICU boolean type, a signed-byte integer.
Definition: umachine.h:269
icu::operator==
U_EXPORT UBool operator==(const StringPiece &x, const StringPiece &y)
Global operator == for StringPiece.
UTZNM_UNKNOWN
@ UTZNM_UNKNOWN
Unknown display name type.
Definition: tznames.h:36
icu::UnicodeString
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition: unistr.h:295
uloc.h
C API: Locale.
icu::UObject
UObject is the common ICU "boilerplate" class.
Definition: uobject.h:223
UErrorCode
UErrorCode
Standard ICU4C error code type, a substitute for exceptions.
Definition: utypes.h:415
icu::StringEnumeration
Base class for 'pure' C++ implementations of uenum api.
Definition: strenum.h:61
icu::TimeZoneNames::operator!=
bool operator!=(const TimeZoneNames &other) const
Return true if the given TimeZoneNames objects are not semantically equal.
Definition: tznames.h:154
UTZNM_SHORT_DAYLIGHT
@ UTZNM_SHORT_DAYLIGHT
Short display name for daylight saving time, such as "EDT".
Definition: tznames.h:66
icu::UMemory
UMemory is the common ICU base class.
Definition: uobject.h:115
U_CDECL_END
#define U_CDECL_END
Definition: umachine.h:86
U_CDECL_BEGIN
#define U_CDECL_BEGIN
Definition: umachine.h:85
UTZNM_LONG_DAYLIGHT
@ UTZNM_LONG_DAYLIGHT
Long display name for daylight saving time, such as "Eastern Daylight Time".
Definition: tznames.h:51
UTZNM_SHORT_GENERIC
@ UTZNM_SHORT_GENERIC
Short display name, such as "ET".
Definition: tznames.h:56
icu::TimeZoneNames
TimeZoneNames is an abstract class representing the time zone display name data model defined by UTS#...
Definition: tznames.h:131
UDate
double UDate
Date and Time data type.
Definition: utypes.h:203
UTZNM_SHORT_STANDARD
@ UTZNM_SHORT_STANDARD
Short display name for standard time, such as "EST".
Definition: tznames.h:61
UTimeZoneNameType
UTimeZoneNameType
Constants for time zone display name types.
Definition: tznames.h:31
UTZNM_LONG_GENERIC
@ UTZNM_LONG_GENERIC
Long display name, such as "Eastern Time".
Definition: tznames.h:41
icu::TimeZoneNames::MatchInfoCollection
MatchInfoCollection represents a collection of time zone name matches used by TimeZoneNames#find.
Definition: tznames.h:310
icu::Locale
A Locale object represents a specific geographical, political, or cultural region.
Definition: locid.h:195
unistr.h
C++ API: Unicode String.