ICU 69.1 69.1

dtitvinf.h
Go to the documentation of this file.
1 // © 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
19 #if U_SHOW_CPLUSPLUS_API
20
26 #if !UCONFIG_NO_FORMATTING
27
28 #include "unicode/udat.h"
29 #include "unicode/locid.h"
30 #include "unicode/ucal.h"
31 #include "unicode/dtptngen.h"
32
33 U_NAMESPACE_BEGIN
34
154 class U_I18N_API DateIntervalInfo U_FINAL : public UObject {
155 public:
169 DateIntervalInfo(UErrorCode& status);
170
171
179 DateIntervalInfo(const Locale& locale, UErrorCode& status);
180
181
186 DateIntervalInfo(const DateIntervalInfo&);
187
192 DateIntervalInfo& operator=(const DateIntervalInfo&);
193
200 virtual DateIntervalInfo* clone() const;
201
207 virtual ~DateIntervalInfo();
208
209
217 virtual UBool operator==(const DateIntervalInfo& other) const;
218
226 UBool operator!=(const DateIntervalInfo& other) const;
227
228
229
262 void setIntervalPattern(const UnicodeString& skeleton,
263 UCalendarDateFields lrgDiffCalUnit,
264 const UnicodeString& intervalPattern,
265 UErrorCode& status);
266
277 UnicodeString& getIntervalPattern(const UnicodeString& skeleton,
278 UCalendarDateFields field,
279 UnicodeString& result,
280 UErrorCode& status) const;
281
288 UnicodeString& getFallbackIntervalPattern(UnicodeString& result) const;
289
290
304 void setFallbackIntervalPattern(const UnicodeString& fallbackPattern,
305 UErrorCode& status);
306
307
314 UBool getDefaultOrder() const;
315
316
322 virtual UClassID getDynamicClassID() const;
323
329 static UClassID U_EXPORT2 getStaticClassID();
330
331
332 private:
341 friend class DateIntervalFormat;
342
346 struct DateIntervalSink;
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_SECOND,
363 kIPI_MILLISECOND,
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 /* U_SHOW_CPLUSPLUS_API */
522
523 #endif
524
U_FINAL
#define U_FINAL
Definition: umachine.h:141
utypes.h
Basic definitions for ICU, for both C and C++ APIs.
U_I18N_API
#define U_I18N_API
Definition: utypes.h:301
UBool
int8_t UBool
The ICU boolean type, a signed-byte integer.
Definition: umachine.h:269
icu::operator==
U_EXPORT UBool operator==(const StringPiece &x, const StringPiece &y)
Global operator == for StringPiece.
icu::DateIntervalInfo
DateIntervalInfo is a public class for encapsulating localizable date time interval patterns.
Definition: dtitvinf.h:154
icu::UnicodeString
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition: unistr.h:295
dtptngen.h
C++ API: Date/Time Pattern Generator.
icu::UObject
UObject is the common ICU "boilerplate" class.
Definition: uobject.h:223
UClassID
void * UClassID
UClassID is used to identify classes without using the compiler's RTTI.
Definition: uobject.h:96
UErrorCode
UErrorCode
Standard ICU4C error code type, a substitute for exceptions.
Definition: utypes.h:415
icu::UObject::getDynamicClassID
virtual UClassID getDynamicClassID() const
ICU4C "poor man's RTTI", returns a UClassID for the actual ICU class.
ucal.h
C API: Calendar.
icu::operator!=
UBool operator!=(const StringPiece &x, const StringPiece &y)
Global operator != for StringPiece.
Definition: stringpiece.h:335
UCalendarDateFields
UCalendarDateFields
Possible fields in a UCalendar.
Definition: ucal.h:202
locid.h
C++ API: Locale ID object.
udat.h
C API: DateFormat.
icu::Locale
A Locale object represents a specific geographical, political, or cultural region.
Definition: locid.h:195
icu::DateIntervalFormat
DateIntervalFormat is a class for formatting and parsing date intervals in a language-independent man...
Definition: dtitvfmt.h:300