ICU 73.2  73.2
dtitvinf.h
Go to the documentation of this file.
00001 // © 2016 and later: Unicode, Inc. and others.
00002 // License & terms of use: http://www.unicode.org/copyright.html
00003 /*
00004  *******************************************************************************
00005  * Copyright (C) 2008-2016, International Business Machines Corporation and
00006  * others. All Rights Reserved.
00007  *******************************************************************************
00008  *
00009  * File DTITVINF.H
00010  *
00011  *******************************************************************************
00012  */
00013 
00014 #ifndef __DTITVINF_H__
00015 #define __DTITVINF_H__
00016 
00017 #include "unicode/utypes.h"
00018 
00019 #if U_SHOW_CPLUSPLUS_API
00020 
00026 #if !UCONFIG_NO_FORMATTING
00027 
00028 #include "unicode/udat.h"
00029 #include "unicode/locid.h"
00030 #include "unicode/ucal.h"
00031 #include "unicode/dtptngen.h"
00032 
00033 U_NAMESPACE_BEGIN
00034 
00154 class U_I18N_API DateIntervalInfo final : public UObject {
00155 public:
00169     DateIntervalInfo(UErrorCode& status);
00170 
00171 
00179     DateIntervalInfo(const Locale& locale, UErrorCode& status);
00180 
00181 
00186     DateIntervalInfo(const DateIntervalInfo&);
00187 
00192     DateIntervalInfo& operator=(const DateIntervalInfo&);
00193 
00200     virtual DateIntervalInfo* clone() const;
00201 
00207     virtual ~DateIntervalInfo();
00208 
00209 
00217     virtual bool operator==(const DateIntervalInfo& other) const;
00218 
00226     bool operator!=(const DateIntervalInfo& other) const;
00227 
00228 
00229 
00262     void setIntervalPattern(const UnicodeString& skeleton,
00263                             UCalendarDateFields lrgDiffCalUnit,
00264                             const UnicodeString& intervalPattern,
00265                             UErrorCode& status);
00266 
00277     UnicodeString& getIntervalPattern(const UnicodeString& skeleton,
00278                                       UCalendarDateFields field,
00279                                       UnicodeString& result,
00280                                       UErrorCode& status) const;
00281 
00288     UnicodeString& getFallbackIntervalPattern(UnicodeString& result) const;
00289 
00290 
00304     void setFallbackIntervalPattern(const UnicodeString& fallbackPattern,
00305                                     UErrorCode& status);
00306 
00307 
00314     UBool getDefaultOrder() const;
00315 
00316 
00322     virtual UClassID getDynamicClassID() const override;
00323 
00329     static UClassID U_EXPORT2 getStaticClassID();
00330 
00331 
00332 private:
00341     friend class DateIntervalFormat;
00342 
00346     struct U_HIDDEN DateIntervalSink;
00347 
00353     enum IntervalPatternIndex
00354     {
00355         kIPI_ERA,
00356         kIPI_YEAR,
00357         kIPI_MONTH,
00358         kIPI_DATE,
00359         kIPI_AM_PM,
00360         kIPI_HOUR,
00361         kIPI_MINUTE,
00362         kIPI_SECOND,
00363         kIPI_MILLISECOND,
00364         kIPI_MAX_INDEX
00365     };
00366 public:
00367 #ifndef U_HIDE_INTERNAL_API
00368 
00372      enum {
00373          kMaxIntervalPatternIndex = kIPI_MAX_INDEX
00374      };
00375 #endif  /* U_HIDE_INTERNAL_API */
00376 private:
00377 
00378 
00384     void initializeData(const Locale& locale, UErrorCode& status);
00385 
00386 
00387     /* Set Interval pattern.
00388      *
00389      * It sets interval pattern into the hash map.
00390      *
00391      * @param skeleton         skeleton on which the interval pattern based
00392      * @param lrgDiffCalUnit   the largest different calendar unit.
00393      * @param intervalPattern  the interval pattern on the largest different
00394      *                         calendar unit.
00395      * @param status           output param set to success/failure code on exit
00396      */
00397     void setIntervalPatternInternally(const UnicodeString& skeleton,
00398                                       UCalendarDateFields lrgDiffCalUnit,
00399                                       const UnicodeString& intervalPattern,
00400                                       UErrorCode& status);
00401 
00402 
00421     const UnicodeString* getBestSkeleton(const UnicodeString& skeleton,
00422                                          int8_t& bestMatchDistanceInfo) const;
00423 
00424 
00432     static void U_EXPORT2 parseSkeleton(const UnicodeString& skeleton,
00433                                         int32_t* skeletonFieldWidth);
00434 
00435 
00447     static UBool U_EXPORT2 stringNumeric(int32_t fieldWidth,
00448                                          int32_t anotherFieldWidth,
00449                                          char patternLetter);
00450 
00451 
00465     static IntervalPatternIndex U_EXPORT2 calendarFieldToIntervalIndex(
00466                                                       UCalendarDateFields field,
00467                                                       UErrorCode& status);
00468 
00469 
00475     void deleteHash(Hashtable* hTable);
00476 
00477 
00484     Hashtable* initHash(UErrorCode& status);
00485 
00486 
00487 
00495     void copyHash(const Hashtable* source, Hashtable* target, UErrorCode& status);
00496 
00497 
00498     // data members
00499     // fallback interval pattern
00500     UnicodeString fFallbackIntervalPattern;
00501     // default order
00502     UBool fFirstDateInPtnIsLaterDate;
00503 
00504     // HashMap<UnicodeString, UnicodeString[kIPI_MAX_INDEX]>
00505     // HashMap( skeleton, pattern[largest_different_field] )
00506     Hashtable* fIntervalPatterns;
00507 
00508 };// end class DateIntervalInfo
00509 
00510 
00511 inline bool
00512 DateIntervalInfo::operator!=(const DateIntervalInfo& other) const {
00513     return !operator==(other);
00514 }
00515 
00516 
00517 U_NAMESPACE_END
00518 
00519 #endif
00520 
00521 #endif /* U_SHOW_CPLUSPLUS_API */
00522 
00523 #endif
00524