ICU 50.1.2  50.1.2
dtitvinf.h
Go to the documentation of this file.
1 /*
2  *******************************************************************************
3  * Copyright (C) 2008-2011, 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 
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_MAX_INDEX
357  };
358 public:
359 #ifndef U_HIDE_INTERNAL_API
360 
364  enum {
365  kMaxIntervalPatternIndex = kIPI_MAX_INDEX
366  };
367 #endif /* U_HIDE_INTERNAL_API */
368 private:
369 
370 
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  * @internal ICU 4.0
390  */
391  void setIntervalPatternInternally(const UnicodeString& skeleton,
392  UCalendarDateFields lrgDiffCalUnit,
393  const UnicodeString& intervalPattern,
394  UErrorCode& status);
395 
396 
416  const UnicodeString* getBestSkeleton(const UnicodeString& skeleton,
417  int8_t& bestMatchDistanceInfo) const;
418 
419 
428  static void U_EXPORT2 parseSkeleton(const UnicodeString& skeleton,
429  int32_t* skeletonFieldWidth);
430 
431 
444  static UBool U_EXPORT2 stringNumeric(int32_t fieldWidth,
445  int32_t anotherFieldWidth,
446  char patternLetter);
447 
448 
463  static IntervalPatternIndex U_EXPORT2 calendarFieldToIntervalIndex(
464  UCalendarDateFields field,
465  UErrorCode& status);
466 
467 
474  void deleteHash(Hashtable* hTable);
475 
476 
484  Hashtable* initHash(UErrorCode& status);
485 
486 
487 
496  void copyHash(const Hashtable* source, Hashtable* target, UErrorCode& status);
497 
498 
499  // data members
500  // fallback interval pattern
501  UnicodeString fFallbackIntervalPattern;
502  // default order
503  UBool fFirstDateInPtnIsLaterDate;
504 
505  // HashMap<UnicodeString, UnicodeString[kIPI_MAX_INDEX]>
506  // HashMap( skeleton, pattern[largest_different_field] )
507  Hashtable* fIntervalPatterns;
508 
509 };// end class DateIntervalInfo
510 
511 
512 inline UBool
514  return !operator==(other);
515 }
516 
517 
519 
520 #endif
521 
522 #endif
523 
UCalendarDateFields
Possible fields in a UCalendar.
Definition: ucal.h:183
DateIntervalFormat is a class for formatting and parsing date intervals in a language-independent man...
Definition: dtitvfmt.h:218
C API: Calendar.
C++ API: Date/Time Pattern Generator.
DateIntervalInfo is a public class for encapsulating localizable date time interval patterns...
Definition: dtitvinf.h:151
virtual UClassID getDynamicClassID() const =0
ICU4C &quot;poor man&#39;s RTTI&quot;, 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:96
#define U_I18N_API
Set to export library symbols from inside the i18n library, and to import them from outside...
Definition: utypes.h:358
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition: uversion.h:129
UBool operator!=(const StringPiece &x, const StringPiece &y)
Global operator != for StringPiece.
Definition: stringpiece.h:218
C API: DateFormat.
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
Definition: uversion.h:130
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers...
Definition: utypes.h:476
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:246
UObject is the common ICU &quot;boilerplate&quot; class.
Definition: uobject.h:229
int8_t UBool
The ICU boolean type.
Definition: umachine.h:200
A Locale object represents a specific geographical, political, or cultural region.
Definition: locid.h:182