ICU 60.2  60.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 class U_I18N_API DateIntervalInfo U_FINAL : public UObject {
154 public:
168  DateIntervalInfo(UErrorCode& status);
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 
345  struct DateIntervalSink;
346 
352  enum IntervalPatternIndex
353  {
354  kIPI_ERA,
355  kIPI_YEAR,
356  kIPI_MONTH,
357  kIPI_DATE,
358  kIPI_AM_PM,
359  kIPI_HOUR,
360  kIPI_MINUTE,
361  kIPI_SECOND,
362  kIPI_MAX_INDEX
363  };
364 public:
365 #ifndef U_HIDE_INTERNAL_API
366 
370  enum {
371  kMaxIntervalPatternIndex = kIPI_MAX_INDEX
372  };
373 #endif /* U_HIDE_INTERNAL_API */
374 private:
375 
376 
382  void initializeData(const Locale& locale, UErrorCode& status);
383 
384 
385  /* Set Interval pattern.
386  *
387  * It sets interval pattern into the hash map.
388  *
389  * @param skeleton skeleton on which the interval pattern based
390  * @param lrgDiffCalUnit the largest different calendar unit.
391  * @param intervalPattern the interval pattern on the largest different
392  * calendar unit.
393  * @param status output param set to success/failure code on exit
394  */
395  void setIntervalPatternInternally(const UnicodeString& skeleton,
396  UCalendarDateFields lrgDiffCalUnit,
397  const UnicodeString& intervalPattern,
398  UErrorCode& status);
399 
400 
419  const UnicodeString* getBestSkeleton(const UnicodeString& skeleton,
420  int8_t& bestMatchDistanceInfo) const;
421 
422 
430  static void U_EXPORT2 parseSkeleton(const UnicodeString& skeleton,
431  int32_t* skeletonFieldWidth);
432 
433 
445  static UBool U_EXPORT2 stringNumeric(int32_t fieldWidth,
446  int32_t anotherFieldWidth,
447  char patternLetter);
448 
449 
463  static IntervalPatternIndex U_EXPORT2 calendarFieldToIntervalIndex(
464  UCalendarDateFields field,
465  UErrorCode& status);
466 
467 
473  void deleteHash(Hashtable* hTable);
474 
475 
482  Hashtable* initHash(UErrorCode& status);
483 
484 
485 
493  void copyHash(const Hashtable* source, Hashtable* target, UErrorCode& status);
494 
495 
496  // data members
497  // fallback interval pattern
498  UnicodeString fFallbackIntervalPattern;
499  // default order
500  UBool fFirstDateInPtnIsLaterDate;
501 
502  // HashMap<UnicodeString, UnicodeString[kIPI_MAX_INDEX]>
503  // HashMap( skeleton, pattern[largest_different_field] )
504  Hashtable* fIntervalPatterns;
505 
506 };// end class DateIntervalInfo
507 
508 
509 inline UBool
511  return !operator==(other);
512 }
513 
514 
516 
517 #endif
518 
519 #endif
520 
UCalendarDateFields
Possible fields in a UCalendar.
Definition: ucal.h:185
DateIntervalFormat is a class for formatting and parsing date intervals in a language-independent man...
Definition: dtitvfmt.h:222
C API: Calendar.
C++ API: Date/Time Pattern Generator.
DateIntervalInfo is a public class for encapsulating localizable date time interval patterns...
Definition: dtitvinf.h:153
virtual UClassID getDynamicClassID() const
ICU4C "poor man&#39;s RTTI", returns a UClassID for the actual ICU class.
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:360
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition: uversion.h:131
UBool operator!=(const StringPiece &x, const StringPiece &y)
Global operator != for StringPiece.
Definition: stringpiece.h:218
C API: DateFormat.
UBool operator!=(const DateIntervalInfo &other) const
Return true if another object is semantically unequal to this one.
Definition: dtitvinf.h:510
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
Definition: uversion.h:132
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers...
Definition: utypes.h:396
C++ API: Locale ID object.
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:286
UObject is the common ICU "boilerplate" class.
Definition: uobject.h:223
int8_t UBool
The ICU boolean type.
Definition: umachine.h:236
A Locale object represents a specific geographical, political, or cultural region.
Definition: locid.h:188