ICU 56.1  56.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
dtitvinf.h
Go to the documentation of this file.
1 /*
2  *******************************************************************************
3  * Copyright (C) 2008-2015, International Business Machines Corporation and
4  * others. All Rights Reserved.
5  *******************************************************************************
6  *
7  * File DTITVINF.H
8  *
9  *******************************************************************************
10  */
11 
12 #ifndef __DTITVINF_H__
13 #define __DTITVINF_H__
14 
15 #include "unicode/utypes.h"
16 
22 #if !UCONFIG_NO_FORMATTING
23 
24 #include "unicode/udat.h"
25 #include "unicode/locid.h"
26 #include "unicode/ucal.h"
27 #include "unicode/dtptngen.h"
28 
30 
151 class U_I18N_API DateIntervalInfo U_FINAL : public UObject {
152 public:
153 #ifndef U_HIDE_INTERNAL_API
154 
167  DateIntervalInfo(UErrorCode& status);
168 #endif /* U_HIDE_INTERNAL_API */
169 
170 
178  DateIntervalInfo(const Locale& locale, UErrorCode& status);
179 
180 
186 
191  DateIntervalInfo& operator=(const DateIntervalInfo&);
192 
199  virtual DateIntervalInfo* clone(void) const;
200 
206  virtual ~DateIntervalInfo();
207 
208 
216  virtual UBool operator==(const DateIntervalInfo& other) const;
217 
225  UBool operator!=(const DateIntervalInfo& other) const;
226 
227 
228 
261  void setIntervalPattern(const UnicodeString& skeleton,
262  UCalendarDateFields lrgDiffCalUnit,
263  const UnicodeString& intervalPattern,
264  UErrorCode& status);
265 
276  UnicodeString& getIntervalPattern(const UnicodeString& skeleton,
277  UCalendarDateFields field,
278  UnicodeString& result,
279  UErrorCode& status) const;
280 
287  UnicodeString& getFallbackIntervalPattern(UnicodeString& result) const;
288 
289 
303  void setFallbackIntervalPattern(const UnicodeString& fallbackPattern,
304  UErrorCode& status);
305 
306 
313  UBool getDefaultOrder() const;
314 
315 
321  virtual UClassID getDynamicClassID() const;
322 
328  static UClassID U_EXPORT2 getStaticClassID();
329 
330 
331 private:
340  friend class DateIntervalFormat;
341 
347  enum IntervalPatternIndex
348  {
349  kIPI_ERA,
350  kIPI_YEAR,
351  kIPI_MONTH,
352  kIPI_DATE,
353  kIPI_AM_PM,
354  kIPI_HOUR,
355  kIPI_MINUTE,
356  kIPI_SECOND,
357  kIPI_MAX_INDEX
358  };
359 public:
360 #ifndef U_HIDE_INTERNAL_API
361 
365  enum {
366  kMaxIntervalPatternIndex = kIPI_MAX_INDEX
367  };
368 #endif /* U_HIDE_INTERNAL_API */
369 private:
370 
371 
377  void initializeData(const Locale& locale, UErrorCode& status);
378 
379 
380  /* Set Interval pattern.
381  *
382  * It sets interval pattern into the hash map.
383  *
384  * @param skeleton skeleton on which the interval pattern based
385  * @param lrgDiffCalUnit the largest different calendar unit.
386  * @param intervalPattern the interval pattern on the largest different
387  * calendar unit.
388  * @param status output param set to success/failure code on exit
389  */
390  void setIntervalPatternInternally(const UnicodeString& skeleton,
391  UCalendarDateFields lrgDiffCalUnit,
392  const UnicodeString& intervalPattern,
393  UErrorCode& status);
394 
395 
414  const UnicodeString* getBestSkeleton(const UnicodeString& skeleton,
415  int8_t& bestMatchDistanceInfo) const;
416 
417 
425  static void U_EXPORT2 parseSkeleton(const UnicodeString& skeleton,
426  int32_t* skeletonFieldWidth);
427 
428 
440  static UBool U_EXPORT2 stringNumeric(int32_t fieldWidth,
441  int32_t anotherFieldWidth,
442  char patternLetter);
443 
444 
458  static IntervalPatternIndex U_EXPORT2 calendarFieldToIntervalIndex(
459  UCalendarDateFields field,
460  UErrorCode& status);
461 
462 
468  void deleteHash(Hashtable* hTable);
469 
470 
477  Hashtable* initHash(UErrorCode& status);
478 
479 
480 
488  void copyHash(const Hashtable* source, Hashtable* target, UErrorCode& status);
489 
490 
491  // data members
492  // fallback interval pattern
493  UnicodeString fFallbackIntervalPattern;
494  // default order
495  UBool fFirstDateInPtnIsLaterDate;
496 
497  // HashMap<UnicodeString, UnicodeString[kIPI_MAX_INDEX]>
498  // HashMap( skeleton, pattern[largest_different_field] )
499  Hashtable* fIntervalPatterns;
500 
501 };// end class DateIntervalInfo
502 
503 
504 inline UBool
506  return !operator==(other);
507 }
508 
509 
511 
512 #endif
513 
514 #endif
515