ICU 55.1  55.1
tznames.h
Go to the documentation of this file.
1 /*
2 *******************************************************************************
3 * Copyright (C) 2011-2014, International Business Machines Corporation and
4 * others. All Rights Reserved.
5 *******************************************************************************
6 */
7 #ifndef __TZNAMES_H
8 #define __TZNAMES_H
9 
14 #include "unicode/utypes.h"
15 
16 #if !UCONFIG_NO_FORMATTING
17 
18 #include "unicode/uloc.h"
19 #include "unicode/unistr.h"
20 
22 
27 typedef enum UTimeZoneNameType {
32  UTZNM_UNKNOWN = 0x00,
69 
71 
73 
74 class UVector;
75 struct MatchInfo;
76 
128 public:
133  virtual ~TimeZoneNames();
134 
141  virtual UBool operator==(const TimeZoneNames& other) const = 0;
142 
150  UBool operator!=(const TimeZoneNames& other) const { return !operator==(other); }
151 
158  virtual TimeZoneNames* clone() const = 0;
159 
168  static TimeZoneNames* U_EXPORT2 createInstance(const Locale& locale, UErrorCode& status);
169 
170 #ifndef U_HIDE_DRAFT_API
171 
181  static TimeZoneNames* U_EXPORT2 createTZDBInstance(const Locale& locale, UErrorCode& status);
182 #endif /* U_HIDE_DRAFT_API */
183 
191 
199  virtual StringEnumeration* getAvailableMetaZoneIDs(const UnicodeString& tzID, UErrorCode& status) const = 0;
200 
211  virtual UnicodeString& getMetaZoneID(const UnicodeString& tzID, UDate date, UnicodeString& mzID) const = 0;
212 
229  virtual UnicodeString& getReferenceZoneID(const UnicodeString& mzID, const char* region, UnicodeString& tzID) const = 0;
230 
242 
254 
275 
291  virtual UnicodeString& getDisplayName(const UnicodeString& tzID, UTimeZoneNameType type, UDate date, UnicodeString& name) const;
292 
299  public:
310 
311 #ifndef U_HIDE_INTERNAL_API
312 
320  void addZone(UTimeZoneNameType nameType, int32_t matchLength,
321  const UnicodeString& tzID, UErrorCode& status);
322 
331  void addMetaZone(UTimeZoneNameType nameType, int32_t matchLength,
332  const UnicodeString& mzID, UErrorCode& status);
333 
339  int32_t size() const;
340 
349  UTimeZoneNameType getNameTypeAt(int32_t idx) const;
350 
358  int32_t getMatchLengthAt(int32_t idx) const;
359 
367  UBool getTimeZoneIDAt(int32_t idx, UnicodeString& tzID) const;
368 
376  UBool getMetaZoneIDAt(int32_t idx, UnicodeString& mzID) const;
377 #endif /* U_HIDE_INTERNAL_API */
378 
379  private:
380  UVector* fMatches; // vector of MatchEntry
381 
382  UVector* matches(UErrorCode& status);
383  };
384 
398  virtual MatchInfoCollection* find(const UnicodeString& text, int32_t start, uint32_t types, UErrorCode& status) const = 0;
399 };
400 
402 
403 #endif
404 #endif
UTZNM_LONG_STANDARD
@ UTZNM_LONG_STANDARD
Long display name for standard time, such as "Eastern Standard Time".
Definition: tznames.h:42
UTZNM_EXEMPLAR_LOCATION
@ UTZNM_EXEMPLAR_LOCATION
Exemplar location name, such as "Los Angeles".
Definition: tznames.h:67
icu::TimeZoneNames::getExemplarLocationName
virtual UnicodeString & getExemplarLocationName(const UnicodeString &tzID, UnicodeString &name) const
Returns the exemplar location name for the given time zone.
utypes.h
Basic definitions for ICU, for both C and C++ APIs.
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
UBool
int8_t UBool
The ICU boolean type.
Definition: umachine.h:234
icu::TimeZoneNames::getMetaZoneDisplayName
virtual UnicodeString & getMetaZoneDisplayName(const UnicodeString &mzID, UTimeZoneNameType type, UnicodeString &name) const =0
Returns the display name of the meta zone.
icu::operator==
U_EXPORT UBool operator==(const StringPiece &x, const StringPiece &y)
Global operator == for StringPiece.
icu::TimeZoneNames::operator!=
UBool operator!=(const TimeZoneNames &other) const
Return true if the given TimeZoneNames objects are not semantically equal.
Definition: tznames.h:150
icu::TimeZoneNames::MatchInfoCollection::getMetaZoneIDAt
UBool getMetaZoneIDAt(int32_t idx, UnicodeString &mzID) const
Gets the metazone ID of a match at the specified index.
icu::TimeZoneNames::MatchInfoCollection::~MatchInfoCollection
virtual ~MatchInfoCollection()
Destructor.
UTZNM_UNKNOWN
@ UTZNM_UNKNOWN
Unknown display name type.
Definition: tznames.h:32
icu::TimeZoneNames::clone
virtual TimeZoneNames * clone() const =0
Clone this object polymorphically.
icu::TimeZoneNames::find
virtual MatchInfoCollection * find(const UnicodeString &text, int32_t start, uint32_t types, UErrorCode &status) const =0
Finds time zone name prefix matches for the input text at the given offset and returns a collection o...
icu::TimeZoneNames::~TimeZoneNames
virtual ~TimeZoneNames()
Destructor.
icu::UnicodeString
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition: unistr.h:246
uloc.h
C API: Locale.
icu::TimeZoneNames::MatchInfoCollection::size
int32_t size() const
Returns the number of entries available in this object.
icu::UObject
UObject is the common ICU "boilerplate" class.
Definition: uobject.h:221
icu::TimeZoneNames::MatchInfoCollection::MatchInfoCollection
MatchInfoCollection()
Constructor.
UErrorCode
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers,...
Definition: utypes.h:476
icu::StringEnumeration
Base class for 'pure' C++ implementations of uenum api.
Definition: strenum.h:55
UTZNM_SHORT_DAYLIGHT
@ UTZNM_SHORT_DAYLIGHT
Short display name for daylight saving time, such as "EDT".
Definition: tznames.h:62
icu::UMemory
UMemory is the common ICU base class.
Definition: uobject.h:110
icu::TimeZoneNames::createInstance
static TimeZoneNames * createInstance(const Locale &locale, UErrorCode &status)
Returns an instance of TimeZoneNames for the specified locale.
icu::TimeZoneNames::createTZDBInstance
static TimeZoneNames * createTZDBInstance(const Locale &locale, UErrorCode &status)
Returns an instance of TimeZoneNames containing only short specific zone names (SHORT_STANDARD and SH...
U_CDECL_END
#define U_CDECL_END
This is used to end a declaration of a library private ICU C API.
Definition: umachine.h:83
icu::TimeZoneNames::getDisplayName
virtual UnicodeString & getDisplayName(const UnicodeString &tzID, UTimeZoneNameType type, UDate date, UnicodeString &name) const
Returns the display name of the time zone at the given date.
U_CDECL_BEGIN
#define U_CDECL_BEGIN
This is used to begin a declaration of a library private ICU C API.
Definition: umachine.h:82
UTZNM_LONG_DAYLIGHT
@ UTZNM_LONG_DAYLIGHT
Long display name for daylight saving time, such as "Eastern Daylight Time".
Definition: tznames.h:47
icu::TimeZoneNames::MatchInfoCollection::getTimeZoneIDAt
UBool getTimeZoneIDAt(int32_t idx, UnicodeString &tzID) const
Gets the zone ID of a match at the specified index.
icu::TimeZoneNames::getReferenceZoneID
virtual UnicodeString & getReferenceZoneID(const UnicodeString &mzID, const char *region, UnicodeString &tzID) const =0
Returns the reference zone ID for the given meta zone ID for the region.
icu::TimeZoneNames::getMetaZoneID
virtual UnicodeString & getMetaZoneID(const UnicodeString &tzID, UDate date, UnicodeString &mzID) const =0
Returns the meta zone ID for the given canonical time zone ID at the given date.
icu::TimeZoneNames::MatchInfoCollection::getMatchLengthAt
int32_t getMatchLengthAt(int32_t idx) const
Returns the match length of a match at the specified index.
icu::TimeZoneNames::MatchInfoCollection::addZone
void addZone(UTimeZoneNameType nameType, int32_t matchLength, const UnicodeString &tzID, UErrorCode &status)
Adds a zone match.
UTZNM_SHORT_GENERIC
@ UTZNM_SHORT_GENERIC
Short display name, such as "ET".
Definition: tznames.h:52
icu::TimeZoneNames::operator==
virtual UBool operator==(const TimeZoneNames &other) const =0
Return true if the given TimeZoneNames objects are emantically equal.
icu::TimeZoneNames
TimeZoneNames is an abstract class representing the time zone display name data model defined by UTS#...
Definition: tznames.h:127
UDate
double UDate
Date and Time data type.
Definition: utypes.h:201
UTZNM_SHORT_STANDARD
@ UTZNM_SHORT_STANDARD
Short display name for standard time, such as "EST".
Definition: tznames.h:57
UTimeZoneNameType
UTimeZoneNameType
Constants for time zone display name types.
Definition: tznames.h:27
UTZNM_LONG_GENERIC
@ UTZNM_LONG_GENERIC
Long display name, such as "Eastern Time".
Definition: tznames.h:37
icu::TimeZoneNames::MatchInfoCollection::addMetaZone
void addMetaZone(UTimeZoneNameType nameType, int32_t matchLength, const UnicodeString &mzID, UErrorCode &status)
Adds a meata zone match.
icu::TimeZoneNames::getAvailableMetaZoneIDs
virtual StringEnumeration * getAvailableMetaZoneIDs(const UnicodeString &tzID, UErrorCode &status) const =0
Returns an enumeration of all available meta zone IDs used by the given time zone.
icu::TimeZoneNames::MatchInfoCollection
MatchInfoCollection represents a collection of time zone name matches used by TimeZoneNames#find.
Definition: tznames.h:298
U_NAMESPACE_END
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
Definition: uversion.h:130
U_NAMESPACE_BEGIN
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition: uversion.h:129
icu::Locale
A Locale object represents a specific geographical, political, or cultural region.
Definition: locid.h:185
icu::TimeZoneNames::MatchInfoCollection::getNameTypeAt
UTimeZoneNameType getNameTypeAt(int32_t idx) const
Returns the time zone name type of a match at the specified index.
unistr.h
C++ API: Unicode String.
icu::TimeZoneNames::getAvailableMetaZoneIDs
virtual StringEnumeration * getAvailableMetaZoneIDs(UErrorCode &status) const =0
Returns an enumeration of all available meta zone IDs.
icu::TimeZoneNames::getTimeZoneDisplayName
virtual UnicodeString & getTimeZoneDisplayName(const UnicodeString &tzID, UTimeZoneNameType type, UnicodeString &name) const =0
Returns the display name of the time zone.