ICU 64.2  64.2
dtitvinf.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) 2008-2016, International Business Machines Corporation and
6  * others. All Rights Reserved.
7  *******************************************************************************
8  *
9  * File DTITVINF.H
10  *
11  *******************************************************************************
12  */
13 
14 #ifndef __DTITVINF_H__
15 #define __DTITVINF_H__
16 
17 #include "unicode/utypes.h"
18 
24 #if !UCONFIG_NO_FORMATTING
25 
26 #include "unicode/udat.h"
27 #include "unicode/locid.h"
28 #include "unicode/ucal.h"
29 #include "unicode/dtptngen.h"
30 
32 
153 public:
167  DateIntervalInfo(UErrorCode& status);
168 
169 
177  DateIntervalInfo(const Locale& locale, UErrorCode& status);
178 
179 
185 
190  DateIntervalInfo& operator=(const DateIntervalInfo&);
191 
198  virtual DateIntervalInfo* clone(void) const;
199 
205  virtual ~DateIntervalInfo();
206 
207 
215  virtual UBool operator==(const DateIntervalInfo& other) const;
216 
224  UBool operator!=(const DateIntervalInfo& other) const;
225 
226 
227 
260  void setIntervalPattern(const UnicodeString& skeleton,
261  UCalendarDateFields lrgDiffCalUnit,
262  const UnicodeString& intervalPattern,
263  UErrorCode& status);
264 
275  UnicodeString& getIntervalPattern(const UnicodeString& skeleton,
276  UCalendarDateFields field,
277  UnicodeString& result,
278  UErrorCode& status) const;
279 
286  UnicodeString& getFallbackIntervalPattern(UnicodeString& result) const;
287 
288 
302  void setFallbackIntervalPattern(const UnicodeString& fallbackPattern,
303  UErrorCode& status);
304 
305 
312  UBool getDefaultOrder() const;
313 
314 
320  virtual UClassID getDynamicClassID() const;
321 
327  static UClassID U_EXPORT2 getStaticClassID();
328 
329 
330 private:
339  friend class DateIntervalFormat;
340 
344  struct DateIntervalSink;
345 
351  enum IntervalPatternIndex
352  {
353  kIPI_ERA,
354  kIPI_YEAR,
355  kIPI_MONTH,
356  kIPI_DATE,
357  kIPI_AM_PM,
358  kIPI_HOUR,
359  kIPI_MINUTE,
360  kIPI_SECOND,
361  kIPI_MAX_INDEX
362  };
363 public:
364 #ifndef U_HIDE_INTERNAL_API
365 
369  enum {
370  kMaxIntervalPatternIndex = kIPI_MAX_INDEX
371  };
372 #endif /* U_HIDE_INTERNAL_API */
373 private:
374 
375 
381  void initializeData(const Locale& locale, UErrorCode& status);
382 
383 
384  /* Set Interval pattern.
385  *
386  * It sets interval pattern into the hash map.
387  *
388  * @param skeleton skeleton on which the interval pattern based
389  * @param lrgDiffCalUnit the largest different calendar unit.
390  * @param intervalPattern the interval pattern on the largest different
391  * calendar unit.
392  * @param status output param set to success/failure code on exit
393  */
394  void setIntervalPatternInternally(const UnicodeString& skeleton,
395  UCalendarDateFields lrgDiffCalUnit,
396  const UnicodeString& intervalPattern,
397  UErrorCode& status);
398 
399 
418  const UnicodeString* getBestSkeleton(const UnicodeString& skeleton,
419  int8_t& bestMatchDistanceInfo) const;
420 
421 
429  static void U_EXPORT2 parseSkeleton(const UnicodeString& skeleton,
430  int32_t* skeletonFieldWidth);
431 
432 
444  static UBool U_EXPORT2 stringNumeric(int32_t fieldWidth,
445  int32_t anotherFieldWidth,
446  char patternLetter);
447 
448 
462  static IntervalPatternIndex U_EXPORT2 calendarFieldToIntervalIndex(
463  UCalendarDateFields field,
464  UErrorCode& status);
465 
466 
472  void deleteHash(Hashtable* hTable);
473 
474 
481  Hashtable* initHash(UErrorCode& status);
482 
483 
484 
492  void copyHash(const Hashtable* source, Hashtable* target, UErrorCode& status);
493 
494 
495  // data members
496  // fallback interval pattern
497  UnicodeString fFallbackIntervalPattern;
498  // default order
499  UBool fFirstDateInPtnIsLaterDate;
500 
501  // HashMap<UnicodeString, UnicodeString[kIPI_MAX_INDEX]>
502  // HashMap( skeleton, pattern[largest_different_field] )
503  Hashtable* fIntervalPatterns;
504 
505 };// end class DateIntervalInfo
506 
507 
508 inline UBool
510  return !operator==(other);
511 }
512 
513 
515 
516 #endif
517 
518 #endif
519 
UCalendarDateFields
Possible fields in a UCalendar.
Definition: ucal.h:199
DateIntervalFormat is a class for formatting and parsing date intervals in a language-independent man...
Definition: dtitvfmt.h:298
C API: Calendar.
C++ API: Date/Time Pattern Generator.
DateIntervalInfo is a public class for encapsulating localizable date time interval patterns...
Definition: dtitvinf.h:152
U_EXPORT UBool operator==(const StringPiece &x, const StringPiece &y)
Global operator == for StringPiece.
void * UClassID
UClassID is used to identify classes without using the compiler&#39;s RTTI.
Definition: uobject.h:93
#define U_I18N_API
Set to export library symbols from inside the i18n library, and to import them from outside...
Definition: utypes.h:301
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition: uversion.h:137
UBool operator!=(const StringPiece &x, const StringPiece &y)
Global operator != for StringPiece.
Definition: stringpiece.h:218
C API: DateFormat.
virtual UClassID getDynamicClassID() const
ICU4C "poor man&#39;s RTTI", returns a UClassID for the actual ICU class.
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
Definition: uversion.h:138
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers...
Definition: utypes.h:401
UBool operator!=(const DateIntervalInfo &other) const
Return true if another object is semantically unequal to this one.
Definition: dtitvinf.h:509
C++ API: Locale ID object.
#define U_FINAL
Defined to the C++11 "final" keyword if available.
Definition: umachine.h:140
Basic definitions for ICU, for both C and C++ APIs.
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition: unistr.h:289
UObject is the common ICU "boilerplate" class.
Definition: uobject.h:223
int8_t UBool
The ICU boolean type.
Definition: umachine.h:225
A Locale object represents a specific geographical, political, or cultural region.
Definition: locid.h:192