ICU 62.1 62.1
dtptngen.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) 2007-2016, International Business Machines Corporation and
6* others. All Rights Reserved.
7*******************************************************************************
8*
9* File DTPTNGEN.H
10*
11*******************************************************************************
12*/
13
14#ifndef __DTPTNGEN_H__
15#define __DTPTNGEN_H__
16
17#include "unicode/datefmt.h"
18#include "unicode/locid.h"
19#include "unicode/udat.h"
20#include "unicode/udatpg.h"
21#include "unicode/unistr.h"
22
24
31class CharString;
32class Hashtable;
33class FormatParser;
34class DateTimeMatcher;
35class DistanceInfo;
36class PatternMap;
37class PtnSkeleton;
38class SharedDateTimePatternGenerator;
39
55public:
63
72
73#ifndef U_HIDE_INTERNAL_API
74
81
82#endif /* U_HIDE_INTERNAL_API */
83
91
97
104
113
122
134
148 The function is commented out because it is a stable API calling a draft API.
149 After staticGetSkeleton becomes stable, staticGetSkeleton can be used and
150 these comments and the definition of getSkeleton in dtptngen.cpp should be removed.
151 return staticGetSkeleton(pattern, status);
152 }*/
153
168
185 The function is commented out because it is a stable API calling a draft API.
186 After staticGetBaseSkeleton becomes stable, staticGetBaseSkeleton can be used and
187 these comments and the definition of getBaseSkeleton in dtptngen.cpp should be removed.
188 return staticGetBaseSkeleton(pattern, status);
189 }*/
190
217 UBool override,
220
240
250
263
275
276#ifndef U_HIDE_DRAFT_API
287#endif // U_HIDE_DRAFT_API
288
310 void setDateTimeFormat(const UnicodeString& dateTimeFormat);
311
318
338
339
362
363
386 const UnicodeString& skeleton,
388
412 const UnicodeString& skeleton,
415
428
436
447
448#ifndef U_HIDE_INTERNAL_API
462#endif /* U_HIDE_INTERNAL_API */
463
475 void setDecimal(const UnicodeString& decimal);
476
482 const UnicodeString& getDecimal() const;
483
490
497
498private:
504
510
517
524
525 // TODO(ticket:13619): re-enable when UDATPG_NARROW no longer in draft mode.
526 // static const int32_t UDATPG_WIDTH_COUNT = UDATPG_NARROW + 1;
527
528 Locale pLocale; // pattern locale
529 FormatParser *fp;
530 DateTimeMatcher* dtMatcher;
531 DistanceInfo *distanceInfo;
532 PatternMap *patternMap;
533 UnicodeString appendItemFormats[UDATPG_FIELD_COUNT];
534 // TODO(ticket:13619): [3] -> UDATPG_WIDTH_COUNT
535 UnicodeString fieldDisplayNames[UDATPG_FIELD_COUNT][3];
536 UnicodeString dateTimeFormat;
537 UnicodeString decimal;
538 DateTimeMatcher *skipMatcher;
539 Hashtable *fAvailableFormatKeyHash;
540 UnicodeString emptyString;
541 char16_t fDefaultHourFormatChar;
542
543 int32_t fAllowedHourFormats[7]; // Actually an array of AllowedHourFormat enum type, ending with UNKNOWN.
544
545 /* internal flags masks for adjustFieldTypes etc. */
546 enum {
547 kDTPGNoFlags = 0,
548 kDTPGFixFractionalSeconds = 1,
549 kDTPGSkeletonUsesCapJ = 2
550 // with #13183, no longer need flags for b, B
551 };
552
553 void initData(const Locale &locale, UErrorCode &status);
554 void addCanonicalItems(UErrorCode &status);
555 void addICUPatterns(const Locale& locale, UErrorCode& status);
556 void hackTimes(const UnicodeString& hackPattern, UErrorCode& status);
557 void getCalendarTypeToUse(const Locale& locale, CharString& destination, UErrorCode& err);
558 void consumeShortTimePattern(const UnicodeString& shortTimePattern, UErrorCode& status);
559 void addCLDRData(const Locale& locale, UErrorCode& status);
561 void initHashtable(UErrorCode& status);
562 void setDateTimeFromCalendar(const Locale& locale, UErrorCode& status);
563 void setDecimalSymbols(const Locale& locale, UErrorCode& status);
564 UDateTimePatternField getAppendFormatNumber(const char* field) const;
565#ifndef U_HIDE_DRAFT_API
566 UDateTimePatternField getFieldAndWidthIndices(const char* key, UDateTimePGDisplayWidth* widthP) const;
567 void setFieldDisplayName(UDateTimePatternField field, UDateTimePGDisplayWidth width, const UnicodeString& value);
568 UnicodeString& getMutableFieldDisplayName(UDateTimePatternField field, UDateTimePGDisplayWidth width);
569#endif // U_HIDE_DRAFT_API
570 void getAppendName(UDateTimePatternField field, UnicodeString& value);
571 UnicodeString mapSkeletonMetacharacters(const UnicodeString& patternForm, int32_t* flags, UErrorCode& status);
572 int32_t getCanonicalIndex(const UnicodeString& field);
576 int32_t getTopBitNumber(int32_t foundMask);
577 void setAvailableFormat(const UnicodeString &key, UErrorCode& status);
578 UBool isAvailableFormatSet(const UnicodeString &key) const;
579 void copyHashtable(Hashtable *other, UErrorCode &status);
580 UBool isCanonicalItem(const UnicodeString& item) const;
581 static void U_CALLCONV loadAllowedHourFormatsData(UErrorCode &status);
582 void getAllowedHourFormats(const Locale &locale, UErrorCode &status);
583
585 struct AppendItemNamesSink;
587} ;// end class DateTimePatternGenerator
588
590
591#endif
This class provides flexible generation of date format patterns, like "yy-MM-dd".
Definition dtptngen.h:54
const UnicodeString & getAppendItemName(UDateTimePatternField field) const
Getter corresponding to setAppendItemNames.
UnicodeString getBestPattern(const UnicodeString &skeleton, UDateTimePatternMatchOptions options, UErrorCode &status)
Return the best pattern matching the input skeleton.
const UnicodeString & getDateTimeFormat() const
Getter corresponding to setDateTimeFormat.
void setDecimal(const UnicodeString &decimal)
The decimal value is used in formatting fractions of seconds.
static DateTimePatternGenerator * internalMakeInstance(const Locale &uLocale, UErrorCode &status)
For ICU use only.
UBool operator!=(const DateTimePatternGenerator &other) const
Return true if another object is semantically unequal to this one.
StringEnumeration * getSkeletons(UErrorCode &status) const
Return a list of all the skeletons (in canonical form) from this class.
UBool operator==(const DateTimePatternGenerator &other) const
Return true if another object is semantically equal to this one.
virtual UClassID getDynamicClassID() const
ICU "poor man's RTTI", returns a UClassID for the actual class.
static DateTimePatternGenerator * createInstance(const Locale &uLocale, UErrorCode &status)
Construct a flexible generator according to data for a given locale.
void setAppendItemFormat(UDateTimePatternField field, const UnicodeString &value)
An AppendItem format is a pattern used to append a field if there is no good match.
UnicodeString getBestPattern(const UnicodeString &skeleton, UErrorCode &status)
Return the best pattern matching the input skeleton.
UnicodeString getFieldDisplayName(UDateTimePatternField field, UDateTimePGDisplayWidth width) const
The general interface to get a display name for a particular date/time field, in one of several possi...
StringEnumeration * getRedundants(UErrorCode &status)
Return a list of redundant patterns are those which if removed, make no difference in the resulting g...
StringEnumeration * getBaseSkeletons(UErrorCode &status) const
Return a list of all the base skeletons (in canonical form) from this class.
static UClassID getStaticClassID(void)
ICU "poor man's RTTI", returns a UClassID for this class.
void setAppendItemName(UDateTimePatternField field, const UnicodeString &value)
Sets the names of field, eg "era" in English for ERA.
static UnicodeString staticGetBaseSkeleton(const UnicodeString &pattern, UErrorCode &status)
Utility to return a unique base skeleton from a given pattern.
void setDateTimeFormat(const UnicodeString &dateTimeFormat)
The DateTimeFormat is a message format pattern used to compose date and time patterns.
static DateTimePatternGenerator * createInstance(UErrorCode &status)
Construct a flexible generator according to default locale.
static DateTimePatternGenerator * createEmptyInstance(UErrorCode &status)
Create an empty generator, to be constructed with addPattern(...) etc.
UnicodeString replaceFieldTypes(const UnicodeString &pattern, const UnicodeString &skeleton, UErrorCode &status)
Adjusts the field types (width and subtype) of a pattern to match what is in a skeleton.
const UnicodeString & getAppendItemFormat(UDateTimePatternField field) const
Getter corresponding to setAppendItemFormat.
static UnicodeString staticGetSkeleton(const UnicodeString &pattern, UErrorCode &status)
Utility to return a unique skeleton from a given pattern.
const UnicodeString & getPatternForSkeleton(const UnicodeString &skeleton) const
Get the pattern corresponding to a given skeleton.
UnicodeString replaceFieldTypes(const UnicodeString &pattern, const UnicodeString &skeleton, UDateTimePatternMatchOptions options, UErrorCode &status)
Adjusts the field types (width and subtype) of a pattern to match what is in a skeleton.
const UnicodeString & getDecimal() const
Getter corresponding to setDecimal.
UnicodeString getBaseSkeleton(const UnicodeString &pattern, UErrorCode &status)
Utility to return a unique base skeleton from a given pattern.
UnicodeString getSkeleton(const UnicodeString &pattern, UErrorCode &status)
Utility to return a unique skeleton from a given pattern.
DateTimePatternGenerator * clone() const
Clone DateTimePatternGenerator object.
virtual ~DateTimePatternGenerator()
Destructor.
UDateTimePatternConflict addPattern(const UnicodeString &pattern, UBool override, UnicodeString &conflictingPattern, UErrorCode &status)
Adds a pattern to the generator.
"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
Base class for 'pure' C++ implementations of uenum api.
Definition strenum.h:57
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: Abstract class for converting dates.
C++ API: Locale ID object.
#define U_CALLCONV
Similar to U_CDECL_BEGIN/U_CDECL_END, this qualifier is necessary in callback function typedefs to ma...
Definition platform.h:835
C API: DateFormat.
C API: Wrapper for icu::DateTimePatternGenerator (unicode/dtptngen.h).
UDateTimePGDisplayWidth
Field display name width constants for udatpg_getFieldDisplayName().
Definition udatpg.h:103
UDateTimePatternConflict
Status return values from udatpg_addPattern().
Definition udatpg.h:139
UDateTimePatternMatchOptions
Masks to control forcing the length of specified fields in the returned pattern to match those in the...
Definition udatpg.h:120
@ UDATPG_MATCH_NO_OPTIONS
Definition udatpg.h:122
UDateTimePatternField
Field number constants for udatpg_getAppendItemFormats() and similar functions.
Definition udatpg.h:55
@ UDATPG_FIELD_COUNT
One more than the highest normal UDateTimePatternField value.
Definition udatpg.h:95
int8_t UBool
The ICU boolean type.
Definition umachine.h:236
C++ API: Unicode String.
void * UClassID
UClassID is used to identify classes without using the compiler's RTTI.
Definition uobject.h:93
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