ICU 58.2 58.2

- Main Page
- Related Pages
- Modules
- Namespaces
- Data Structures
- Files

- File List
- Globals

dtitvinf.h
Go to the documentation of this file.
1 // Copyright (C) 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
31 U_NAMESPACE_BEGIN
32
153 class U_I18N_API DateIntervalInfo U_FINAL : public UObject {
154 public:
155 // Do not enclose the protected default constructor with #ifndef U_HIDE_INTERNAL_API
156 // or else the compiler will create a public default constructor.
170 DateIntervalInfo(UErrorCode& status);
171
172
180 DateIntervalInfo(const Locale& locale, UErrorCode& status);
181
182
187 DateIntervalInfo(const DateIntervalInfo&);
188
193 DateIntervalInfo& operator=(const DateIntervalInfo&);
194
201 virtual DateIntervalInfo* clone(void) const;
202
208 virtual ~DateIntervalInfo();
209
210
218 virtual UBool operator==(const DateIntervalInfo& other) const;
219
227 UBool operator!=(const DateIntervalInfo& other) const;
228
229
230
263 void setIntervalPattern(const UnicodeString& skeleton,
264 UCalendarDateFields lrgDiffCalUnit,
265 const UnicodeString& intervalPattern,
266 UErrorCode& status);
267
278 UnicodeString& getIntervalPattern(const UnicodeString& skeleton,
279 UCalendarDateFields field,
280 UnicodeString& result,
281 UErrorCode& status) const;
282
289 UnicodeString& getFallbackIntervalPattern(UnicodeString& result) const;
290
291
305 void setFallbackIntervalPattern(const UnicodeString& fallbackPattern,
306 UErrorCode& status);
307
308
315 UBool getDefaultOrder() const;
316
317
323 virtual UClassID getDynamicClassID() const;
324
330 static UClassID U_EXPORT2 getStaticClassID();
331
332
333 private:
342 friend class DateIntervalFormat;
343
347 struct DateIntervalSink;
348
354 enum IntervalPatternIndex
355 {
356 kIPI_ERA,
357 kIPI_YEAR,
358 kIPI_MONTH,
359 kIPI_DATE,
360 kIPI_AM_PM,
361 kIPI_HOUR,
362 kIPI_MINUTE,
363 kIPI_SECOND,
364 kIPI_MAX_INDEX
365 };
366 public:
367 #ifndef U_HIDE_INTERNAL_API
368
372 enum {
373 kMaxIntervalPatternIndex = kIPI_MAX_INDEX
374 };
375 #endif /* U_HIDE_INTERNAL_API */
376 private:
377
378
384 void initializeData(const Locale& locale, UErrorCode& status);
385
386
387 /* Set Interval pattern.
388 *
389 * It sets interval pattern into the hash map.
390 *
391 * @param skeleton skeleton on which the interval pattern based
392 * @param lrgDiffCalUnit the largest different calendar unit.
393 * @param intervalPattern the interval pattern on the largest different
394 * calendar unit.
395 * @param status output param set to success/failure code on exit
396 */
397 void setIntervalPatternInternally(const UnicodeString& skeleton,
398 UCalendarDateFields lrgDiffCalUnit,
399 const UnicodeString& intervalPattern,
400 UErrorCode& status);
401
402
421 const UnicodeString* getBestSkeleton(const UnicodeString& skeleton,
422 int8_t& bestMatchDistanceInfo) const;
423
424
432 static void U_EXPORT2 parseSkeleton(const UnicodeString& skeleton,
433 int32_t* skeletonFieldWidth);
434
435
447 static UBool U_EXPORT2 stringNumeric(int32_t fieldWidth,
448 int32_t anotherFieldWidth,
449 char patternLetter);
450
451
465 static IntervalPatternIndex U_EXPORT2 calendarFieldToIntervalIndex(
466 UCalendarDateFields field,
467 UErrorCode& status);
468
469
475 void deleteHash(Hashtable* hTable);
476
477
484 Hashtable* initHash(UErrorCode& status);
485
486
487
495 void copyHash(const Hashtable* source, Hashtable* target, UErrorCode& status);
496
497
498 // data members
499 // fallback interval pattern
500 UnicodeString fFallbackIntervalPattern;
501 // default order
502 UBool fFirstDateInPtnIsLaterDate;
503
504 // HashMap<UnicodeString, UnicodeString[kIPI_MAX_INDEX]>
505 // HashMap( skeleton, pattern[largest_different_field] )
506 Hashtable* fIntervalPatterns;
507
508 };// end class DateIntervalInfo
509
510
511 inline UBool
512 DateIntervalInfo::operator!=(const DateIntervalInfo& other) const {
513 return !operator==(other);
514 }
515
516
517 U_NAMESPACE_END
518
519 #endif
520
521 #endif
522
UCalendarDateFields
UCalendarDateFields
Possible fields in a UCalendar.
Definition: ucal.h:185
icu::DateIntervalFormat
DateIntervalFormat is a class for formatting and parsing date intervals in a language-independent man...
Definition: dtitvfmt.h:222
ucal.h
C API: Calendar.
dtptngen.h
C++ API: Date/Time Pattern Generator.
icu::DateIntervalInfo
DateIntervalInfo is a public class for encapsulating localizable date time interval patterns...
Definition: dtitvinf.h:153
icu::UObject::getDynamicClassID
virtual UClassID getDynamicClassID() const
ICU4C "poor man&#39;s RTTI", returns a UClassID for the actual ICU class.
icu::operator==
U_EXPORT UBool operator==(const StringPiece &x, const StringPiece &y)
Global operator == for StringPiece.
UClassID
void * UClassID
UClassID is used to identify classes without using the compiler&#39;s RTTI.
Definition: uobject.h:93
U_I18N_API
#define U_I18N_API
Set to export library symbols from inside the i18n library, and to import them from outside...
Definition: utypes.h:360
U_NAMESPACE_BEGIN
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition: uversion.h:131
icu::operator!=
UBool operator!=(const StringPiece &x, const StringPiece &y)
Global operator != for StringPiece.
Definition: stringpiece.h:220
udat.h
C API: DateFormat.
icu::DateIntervalInfo::operator!=
UBool operator!=(const DateIntervalInfo &other) const
Return true if another object is semantically unequal to this one.
Definition: dtitvinf.h:512
U_NAMESPACE_END
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
Definition: uversion.h:132
UErrorCode
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers...
Definition: utypes.h:396
locid.h
C++ API: Locale ID object.
utypes.h
Basic definitions for ICU, for both C and C++ APIs.
icu::UnicodeString
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition: unistr.h:295
icu::UObject
UObject is the common ICU "boilerplate" class.
Definition: uobject.h:223
UBool
int8_t UBool
The ICU boolean type.
Definition: umachine.h:259
icu::Locale
A Locale object represents a specific geographical, political, or cultural region.
Definition: locid.h:187