ICU 4.2.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-2009, 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 
40 
44 UBool U_CALLCONV dtitvinfHashTableValueComparator(UHashTok val1, UHashTok val2) ;
45 
47 
48 
169 public:
183  DateIntervalInfo(UErrorCode& status);
184 
185 
193  DateIntervalInfo(const Locale& locale, UErrorCode& status);
194 
195 
201 
206  DateIntervalInfo& operator=(const DateIntervalInfo&);
207 
214  virtual DateIntervalInfo* clone(void) const;
215 
221  virtual ~DateIntervalInfo();
222 
223 
231  virtual UBool operator==(const DateIntervalInfo& other) const;
232 
240  UBool operator!=(const DateIntervalInfo& other) const;
241 
242 
243 
276  void setIntervalPattern(const UnicodeString& skeleton,
277  UCalendarDateFields lrgDiffCalUnit,
278  const UnicodeString& intervalPattern,
279  UErrorCode& status);
280 
291  UnicodeString& getIntervalPattern(const UnicodeString& skeleton,
292  UCalendarDateFields field,
293  UnicodeString& result,
294  UErrorCode& status) const;
295 
302  UnicodeString& getFallbackIntervalPattern(UnicodeString& result) const;
303 
304 
318  void setFallbackIntervalPattern(const UnicodeString& fallbackPattern,
319  UErrorCode& status);
320 
321 
328  UBool getDefaultOrder() const;
329 
330 
336  virtual UClassID getDynamicClassID() const;
337 
343  static UClassID U_EXPORT2 getStaticClassID();
344 
345 
346 private:
355  friend class DateIntervalFormat;
356 
357  friend UBool U_CALLCONV dtitvinfHashTableValueComparator(UHashTok val1, UHashTok val2) ;
358 
364  enum IntervalPatternIndex
365  {
366  kIPI_ERA,
367  kIPI_YEAR,
368  kIPI_MONTH,
369  kIPI_DATE,
370  kIPI_AM_PM,
371  kIPI_HOUR,
372  kIPI_MINUTE,
373  kIPI_MAX_INDEX
374  };
375 
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  * @internal ICU 4.0
395  */
396  void setIntervalPatternInternally(const UnicodeString& skeleton,
397  UCalendarDateFields lrgDiffCalUnit,
398  const UnicodeString& intervalPattern,
399  UErrorCode& status);
400 
401 
421  const UnicodeString* getBestSkeleton(const UnicodeString& skeleton,
422  int8_t& bestMatchDistanceInfo) const;
423 
424 
433  static void U_EXPORT2 parseSkeleton(const UnicodeString& skeleton,
434  int32_t* skeletonFieldWidth);
435 
436 
449  static UBool U_EXPORT2 stringNumeric(int32_t fieldWidth,
450  int32_t anotherFieldWidth,
451  char patternLetter);
452 
453 
468  static IntervalPatternIndex U_EXPORT2 calendarFieldToIntervalIndex(
469  UCalendarDateFields field,
470  UErrorCode& status);
471 
472 
479  void deleteHash(Hashtable* hTable);
480 
481 
489  Hashtable* initHash(UErrorCode& status);
490 
491 
492 
501  void copyHash(const Hashtable* source, Hashtable* target, UErrorCode& status);
502 
503 
504  // data members
505  // fallback interval pattern
506  UnicodeString fFallbackIntervalPattern;
507  // default order
508  UBool fFirstDateInPtnIsLaterDate;
509 
510  // HashMap<UnicodeString, UnicodeString[kIPI_MAX_INDEX]>
511  // HashMap( skeleton, pattern[largest_different_field] )
512  Hashtable* fIntervalPatterns;
513 
514 };// end class DateIntervalInfo
515 
516 
517 inline UBool
519  return !operator==(other);
520 }
521 
522 
524 
525 #endif
526 
527 #endif
528 
UCalendarDateFields
Possible fields in a UCalendar.
Definition: ucal.h:176
C API: Calendar.
C++ API: Date/Time Pattern Generator.
#define U_CALLCONV
Similar to U_CDECL_BEGIN/U_CDECL_END, this qualifier is necessary in callback function typedefs to ma...
Definition: utypes.h:254
#define U_CDECL_BEGIN
This is used to begin a declaration of a library private ICU C API.
Definition: umachine.h:101
#define U_I18N_API
Set to export library symbols from inside the i18n library, and to import them from outside...
Definition: utypes.h:475
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition: uversion.h:183
DateIntervalFormat is a class for formatting and parsing date intervals in a language-independent man...
Definition: dtitvfmt.h:218
UBool dtitvinfHashTableValueComparator(UHashTok val1, UHashTok val2)
C API: DateFormat.
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition: unistr.h:187
#define U_EXPORT2
Definition: platform.h:338
#define U_CDECL_END
This is used to end a declaration of a library private ICU C API.
Definition: umachine.h:102
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API If the compiler doesn&#39;t support namespaces...
Definition: uversion.h:184
UObject is the common ICU &quot;boilerplate&quot; class.
Definition: uobject.h:212
signed char int8_t
Define 64 bit limits.
Definition: pwin32.h:127
UBool operator!=(const DateIntervalInfo &other) const
Return true if another object is semantically unequal to this one.
Definition: dtitvinf.h:518
DateIntervalInfo is a public class for encapsulating localizable date time interval patterns...
Definition: dtitvinf.h:168
void * UClassID
UClassID is used to identify classes without using RTTI, since RTTI is not yet supported by all C++ c...
Definition: utypes.h:339
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers...
Definition: utypes.h:593
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.
signed int int32_t
Define 64 bit limits.
Definition: pwin32.h:143
int8_t UBool
The ICU boolean type.
Definition: umachine.h:208