ICU 4.8.1.1  4.8.1.1
 All Data Structures 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-2010, 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 //#include "dtitv_impl.h"
29 
34 union UHashTok;
35 
36 
38 
160 public:
174  DateIntervalInfo(UErrorCode& status);
175 
176 
184  DateIntervalInfo(const Locale& locale, UErrorCode& status);
185 
186 
192 
197  DateIntervalInfo& operator=(const DateIntervalInfo&);
198 
205  virtual DateIntervalInfo* clone(void) const;
206 
212  virtual ~DateIntervalInfo();
213 
214 
222  virtual UBool operator==(const DateIntervalInfo& other) const;
223 
231  UBool operator!=(const DateIntervalInfo& other) const;
232 
233 
234 
267  void setIntervalPattern(const UnicodeString& skeleton,
268  UCalendarDateFields lrgDiffCalUnit,
269  const UnicodeString& intervalPattern,
270  UErrorCode& status);
271 
282  UnicodeString& getIntervalPattern(const UnicodeString& skeleton,
283  UCalendarDateFields field,
284  UnicodeString& result,
285  UErrorCode& status) const;
286 
293  UnicodeString& getFallbackIntervalPattern(UnicodeString& result) const;
294 
295 
309  void setFallbackIntervalPattern(const UnicodeString& fallbackPattern,
310  UErrorCode& status);
311 
312 
319  UBool getDefaultOrder() const;
320 
321 
327  virtual UClassID getDynamicClassID() const;
328 
334  static UClassID U_EXPORT2 getStaticClassID();
335 
336 
337 private:
346  friend class DateIntervalFormat;
347 
353  enum IntervalPatternIndex
354  {
355  kIPI_ERA,
356  kIPI_YEAR,
357  kIPI_MONTH,
358  kIPI_DATE,
359  kIPI_AM_PM,
360  kIPI_HOUR,
361  kIPI_MINUTE,
362  kIPI_MAX_INDEX
363  };
364 public:
369  enum {
370  kMaxIntervalPatternIndex = kIPI_MAX_INDEX
371  };
372 private:
373 
374 
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  * @internal ICU 4.0
394  */
395  void setIntervalPatternInternally(const UnicodeString& skeleton,
396  UCalendarDateFields lrgDiffCalUnit,
397  const UnicodeString& intervalPattern,
398  UErrorCode& status);
399 
400 
420  const UnicodeString* getBestSkeleton(const UnicodeString& skeleton,
421  int8_t& bestMatchDistanceInfo) const;
422 
423 
432  static void U_EXPORT2 parseSkeleton(const UnicodeString& skeleton,
433  int32_t* skeletonFieldWidth);
434 
435 
448  static UBool U_EXPORT2 stringNumeric(int32_t fieldWidth,
449  int32_t anotherFieldWidth,
450  char patternLetter);
451 
452 
467  static IntervalPatternIndex U_EXPORT2 calendarFieldToIntervalIndex(
468  UCalendarDateFields field,
469  UErrorCode& status);
470 
471 
478  void deleteHash(Hashtable* hTable);
479 
480 
488  Hashtable* initHash(UErrorCode& status);
489 
490 
491 
500  void copyHash(const Hashtable* source, Hashtable* target, UErrorCode& status);
501 
502 
503  // data members
504  // fallback interval pattern
505  UnicodeString fFallbackIntervalPattern;
506  // default order
507  UBool fFirstDateInPtnIsLaterDate;
508 
509  // HashMap<UnicodeString, UnicodeString[kIPI_MAX_INDEX]>
510  // HashMap( skeleton, pattern[largest_different_field] )
511  Hashtable* fIntervalPatterns;
512 
513 };// end class DateIntervalInfo
514 
515 
516 inline UBool
518  return !operator==(other);
519 }
520 
521 
523 
524 #endif
525 
526 #endif
527 
UCalendarDateFields
Possible fields in a UCalendar.
Definition: ucal.h:183
C API: Calendar.
C++ API: Date/Time Pattern Generator.
U_EXPORT UBool operator==(const StringPiece &x, const StringPiece &y)
Global operator == for StringPiece.
#define U_I18N_API
Set to export library symbols from inside the i18n library, and to import them from outside...
Definition: utypes.h:521
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition: uversion.h:131
DateIntervalFormat is a class for formatting and parsing date intervals in a language-independent man...
Definition: dtitvfmt.h:218
C API: DateFormat.
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition: unistr.h:188
#define U_EXPORT2
Definition: platform.h:314
UBool operator!=(const StringPiece &x, const StringPiece &y)
Global operator != for StringPiece.
Definition: stringpiece.h:218
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
Definition: uversion.h:132
UObject is the common ICU &quot;boilerplate&quot; class.
Definition: uobject.h:215
UBool operator!=(const DateIntervalInfo &other) const
Return true if another object is semantically unequal to this one.
Definition: dtitvinf.h:517
DateIntervalInfo is a public class for encapsulating localizable date time interval patterns...
Definition: dtitvinf.h:159
void * UClassID
UClassID is used to identify classes without using RTTI, since RTTI is not yet supported by all C++ c...
Definition: utypes.h:385
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers...
Definition: utypes.h:639
C++ API: Locale ID object.
Basic definitions for ICU, for both C and C++ APIs.
virtual UBool operator==(const DateIntervalInfo &other) const
Return true if another object is semantically equal to this one.
A Locale object represents a specific geographical, political, or cultural region.
Definition: locid.h:181
virtual UClassID getDynamicClassID() const =0
ICU4C &quot;poor man&#39;s RTTI&quot;, returns a UClassID for the actual ICU class.
int8_t UBool
The ICU boolean type.
Definition: umachine.h:228