ICU 62.1 62.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
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
32
154public:
169
170
179
180
186
192
199 virtual DateIntervalInfo* clone(void) const;
200
207
208
216 virtual UBool operator==(const DateIntervalInfo& other) const;
217
226
227
228
265
279 UErrorCode& status) const;
280
288
289
305
306
314
315
322
329
330
331private:
340 friend class DateIntervalFormat;
341
345 struct DateIntervalSink;
346
352 enum IntervalPatternIndex
353 {
354 kIPI_ERA,
355 kIPI_YEAR,
356 kIPI_MONTH,
357 kIPI_DATE,
358 kIPI_AM_PM,
359 kIPI_HOUR,
360 kIPI_MINUTE,
361 kIPI_SECOND,
362 kIPI_MAX_INDEX
363 };
364public:
365#ifndef U_HIDE_INTERNAL_API
370 enum {
371 kMaxIntervalPatternIndex = kIPI_MAX_INDEX
372 };
373#endif /* U_HIDE_INTERNAL_API */
374private:
375
376
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 */
395 void setIntervalPatternInternally(const UnicodeString& skeleton,
396 UCalendarDateFields lrgDiffCalUnit,
397 const UnicodeString& intervalPattern,
398 UErrorCode& status);
399
400
419 const UnicodeString* getBestSkeleton(const UnicodeString& skeleton,
420 int8_t& bestMatchDistanceInfo) const;
421
422
430 static void U_EXPORT2 parseSkeleton(const UnicodeString& skeleton,
431 int32_t* skeletonFieldWidth);
432
433
445 static UBool U_EXPORT2 stringNumeric(int32_t fieldWidth,
446 int32_t anotherFieldWidth,
447 char patternLetter);
448
449
463 static IntervalPatternIndex U_EXPORT2 calendarFieldToIntervalIndex(
465 UErrorCode& status);
466
467
473 void deleteHash(Hashtable* hTable);
474
475
482 Hashtable* initHash(UErrorCode& status);
483
484
485
493 void copyHash(const Hashtable* source, Hashtable* target, UErrorCode& status);
494
495
496 // data members
497 // fallback interval pattern
498 UnicodeString fFallbackIntervalPattern;
499 // default order
500 UBool fFirstDateInPtnIsLaterDate;
501
502 // HashMap<UnicodeString, UnicodeString[kIPI_MAX_INDEX]>
503 // HashMap( skeleton, pattern[largest_different_field] )
504 Hashtable* fIntervalPatterns;
505
506};// end class DateIntervalInfo
507
508
509inline UBool
510DateIntervalInfo::operator!=(const DateIntervalInfo& other) const {
511 return !operator==(other);
512}
513
514
516
517#endif
518
519#endif
520
DateIntervalFormat is a class for formatting and parsing date intervals in a language-independent man...
Definition dtitvfmt.h:222
DateIntervalInfo is a public class for encapsulating localizable date time interval patterns.
Definition dtitvinf.h:153
void setIntervalPattern(const UnicodeString &skeleton, UCalendarDateFields lrgDiffCalUnit, const UnicodeString &intervalPattern, UErrorCode &status)
Provides a way for client to build interval patterns.
UnicodeString & getFallbackIntervalPattern(UnicodeString &result) const
Get the fallback interval pattern.
virtual UClassID getDynamicClassID() const
ICU "poor man's RTTI", returns a UClassID for the actual class.
DateIntervalInfo & operator=(const DateIntervalInfo &)
Assignment operator.
virtual UBool operator==(const DateIntervalInfo &other) const
Return true if another object is semantically equal to this one.
UBool getDefaultOrder() const
Get default order – whether the first date in pattern is later date or not.
virtual ~DateIntervalInfo()
Destructor.
void setFallbackIntervalPattern(const UnicodeString &fallbackPattern, UErrorCode &status)
Re-set the fallback interval pattern.
DateIntervalInfo(const DateIntervalInfo &)
Copy constructor.
UnicodeString & getIntervalPattern(const UnicodeString &skeleton, UCalendarDateFields field, UnicodeString &result, UErrorCode &status) const
Get the interval pattern given skeleton and the largest different calendar field.
DateIntervalInfo(const Locale &locale, UErrorCode &status)
Construct DateIntervalInfo for the given locale,.
static UClassID getStaticClassID()
ICU "poor man's RTTI", returns a UClassID for this class.
virtual DateIntervalInfo * clone(void) const
Clone this object polymorphically.
DateIntervalInfo(UErrorCode &status)
Default constructor.
"Smart pointer" base class; do not use directly: use LocalPointer etc.
A Locale object represents a specific geographical, political, or cultural region.
Definition locid.h:188
UObject is the common ICU "boilerplate" class.
Definition uobject.h:223
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition unistr.h:287
C++ API: Date/Time Pattern Generator.
C++ API: Locale ID object.
U_EXPORT UBool operator==(const StringPiece &x, const StringPiece &y)
Global operator == for StringPiece.
UBool operator!=(const StringPiece &x, const StringPiece &y)
Global operator != for StringPiece.
C API: Calendar.
UCalendarDateFields
Possible fields in a UCalendar.
Definition ucal.h:185
C API: DateFormat.
int8_t UBool
The ICU boolean type.
Definition umachine.h:236
void * UClassID
UClassID is used to identify classes without using the compiler's RTTI.
Definition uobject.h:93
Basic definitions for ICU, for both C and C++ APIs.
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers,...
Definition utypes.h:396
#define U_I18N_API
Set to export library symbols from inside the i18n library, and to import them from outside.
Definition utypes.h:360
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
Definition uversion.h:138
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition uversion.h:137