ICU 4.8.1.1
4.8.1.1
|
00001 /* 00002 ******************************************************************************* 00003 * Copyright (C) 2008-2010, International Business Machines Corporation and 00004 * others. All Rights Reserved. 00005 ******************************************************************************* 00006 * 00007 * File DTITVINF.H 00008 * 00009 ******************************************************************************* 00010 */ 00011 00012 #ifndef __DTITVINF_H__ 00013 #define __DTITVINF_H__ 00014 00015 #include "unicode/utypes.h" 00016 00022 #if !UCONFIG_NO_FORMATTING 00023 00024 #include "unicode/udat.h" 00025 #include "unicode/locid.h" 00026 #include "unicode/ucal.h" 00027 #include "unicode/dtptngen.h" 00028 //#include "dtitv_impl.h" 00029 00034 union UHashTok; 00035 00036 00037 U_NAMESPACE_BEGIN 00038 00159 class U_I18N_API DateIntervalInfo : public UObject { 00160 public: 00174 DateIntervalInfo(UErrorCode& status); 00175 00176 00184 DateIntervalInfo(const Locale& locale, UErrorCode& status); 00185 00186 00191 DateIntervalInfo(const DateIntervalInfo&); 00192 00197 DateIntervalInfo& operator=(const DateIntervalInfo&); 00198 00205 virtual DateIntervalInfo* clone(void) const; 00206 00212 virtual ~DateIntervalInfo(); 00213 00214 00222 virtual UBool operator==(const DateIntervalInfo& other) const; 00223 00231 UBool operator!=(const DateIntervalInfo& other) const; 00232 00233 00234 00267 void setIntervalPattern(const UnicodeString& skeleton, 00268 UCalendarDateFields lrgDiffCalUnit, 00269 const UnicodeString& intervalPattern, 00270 UErrorCode& status); 00271 00282 UnicodeString& getIntervalPattern(const UnicodeString& skeleton, 00283 UCalendarDateFields field, 00284 UnicodeString& result, 00285 UErrorCode& status) const; 00286 00293 UnicodeString& getFallbackIntervalPattern(UnicodeString& result) const; 00294 00295 00309 void setFallbackIntervalPattern(const UnicodeString& fallbackPattern, 00310 UErrorCode& status); 00311 00312 00319 UBool getDefaultOrder() const; 00320 00321 00327 virtual UClassID getDynamicClassID() const; 00328 00334 static UClassID U_EXPORT2 getStaticClassID(); 00335 00336 00337 private: 00346 friend class DateIntervalFormat; 00347 00353 enum IntervalPatternIndex 00354 { 00355 kIPI_ERA, 00356 kIPI_YEAR, 00357 kIPI_MONTH, 00358 kIPI_DATE, 00359 kIPI_AM_PM, 00360 kIPI_HOUR, 00361 kIPI_MINUTE, 00362 kIPI_MAX_INDEX 00363 }; 00364 public: 00369 enum { 00370 kMaxIntervalPatternIndex = kIPI_MAX_INDEX 00371 }; 00372 private: 00373 00374 00381 void initializeData(const Locale& locale, UErrorCode& status); 00382 00383 00384 /* Set Interval pattern. 00385 * 00386 * It sets interval pattern into the hash map. 00387 * 00388 * @param skeleton skeleton on which the interval pattern based 00389 * @param lrgDiffCalUnit the largest different calendar unit. 00390 * @param intervalPattern the interval pattern on the largest different 00391 * calendar unit. 00392 * @param status output param set to success/failure code on exit 00393 * @internal ICU 4.0 00394 */ 00395 void setIntervalPatternInternally(const UnicodeString& skeleton, 00396 UCalendarDateFields lrgDiffCalUnit, 00397 const UnicodeString& intervalPattern, 00398 UErrorCode& status); 00399 00400 00420 const UnicodeString* getBestSkeleton(const UnicodeString& skeleton, 00421 int8_t& bestMatchDistanceInfo) const; 00422 00423 00432 static void U_EXPORT2 parseSkeleton(const UnicodeString& skeleton, 00433 int32_t* skeletonFieldWidth); 00434 00435 00448 static UBool U_EXPORT2 stringNumeric(int32_t fieldWidth, 00449 int32_t anotherFieldWidth, 00450 char patternLetter); 00451 00452 00467 static IntervalPatternIndex U_EXPORT2 calendarFieldToIntervalIndex( 00468 UCalendarDateFields field, 00469 UErrorCode& status); 00470 00471 00478 void deleteHash(Hashtable* hTable); 00479 00480 00488 Hashtable* initHash(UErrorCode& status); 00489 00490 00491 00500 void copyHash(const Hashtable* source, Hashtable* target, UErrorCode& status); 00501 00502 00503 // data members 00504 // fallback interval pattern 00505 UnicodeString fFallbackIntervalPattern; 00506 // default order 00507 UBool fFirstDateInPtnIsLaterDate; 00508 00509 // HashMap<UnicodeString, UnicodeString[kIPI_MAX_INDEX]> 00510 // HashMap( skeleton, pattern[largest_different_field] ) 00511 Hashtable* fIntervalPatterns; 00512 00513 };// end class DateIntervalInfo 00514 00515 00516 inline UBool 00517 DateIntervalInfo::operator!=(const DateIntervalInfo& other) const { 00518 return !operator==(other); 00519 } 00520 00521 00522 U_NAMESPACE_END 00523 00524 #endif 00525 00526 #endif 00527