ICU 57.1 57.1
dtptngen.h
Go to the documentation of this file.
1/*
2*******************************************************************************
3* Copyright (C) 2007-2016, International Business Machines Corporation and
4* others. All Rights Reserved.
5*******************************************************************************
6*
7* File DTPTNGEN.H
8*
9*******************************************************************************
10*/
11
12#ifndef __DTPTNGEN_H__
13#define __DTPTNGEN_H__
14
15#include "unicode/datefmt.h"
16#include "unicode/locid.h"
17#include "unicode/udat.h"
18#include "unicode/udatpg.h"
19
21
28class Hashtable;
29class FormatParser;
30class DateTimeMatcher;
31class DistanceInfo;
32class PatternMap;
33class PtnSkeleton;
35
51public:
59
68
69#ifndef U_HIDE_INTERNAL_API
70
77
78#endif /* U_HIDE_INTERNAL_API */
79
87
93
100
109
118
119#ifndef U_HIDE_DRAFT_API
131#endif /* U_HIDE_DRAFT_API */
132
146 The function is commented out because it is a stable API calling a draft API.
147 After staticGetSkeleton becomes stable, staticGetSkeleton can be used and
148 these comments and the definition of getSkeleton in dtptngen.cpp should be removed.
149 return staticGetSkeleton(pattern, status);
150 }*/
151
152#ifndef U_HIDE_DRAFT_API
167#endif /* U_HIDE_DRAFT_API */
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
273
295 void setDateTimeFormat(const UnicodeString& dateTimeFormat);
296
303
323
324
347
348
371 const UnicodeString& skeleton,
373
397 const UnicodeString& skeleton,
400
413
421
432
433#ifndef U_HIDE_INTERNAL_API
447#endif /* U_HIDE_INTERNAL_API */
448
460 void setDecimal(const UnicodeString& decimal);
461
467 const UnicodeString& getDecimal() const;
468
475
482
483private:
489
495
502
509
510 Locale pLocale; // pattern locale
511 FormatParser *fp;
512 DateTimeMatcher* dtMatcher;
513 DistanceInfo *distanceInfo;
514 PatternMap *patternMap;
515 UnicodeString appendItemFormats[UDATPG_FIELD_COUNT];
516 UnicodeString appendItemNames[UDATPG_FIELD_COUNT];
517 UnicodeString dateTimeFormat;
518 UnicodeString decimal;
519 DateTimeMatcher *skipMatcher;
520 Hashtable *fAvailableFormatKeyHash;
521 UnicodeString hackPattern;
522 UnicodeString emptyString;
523 UChar fDefaultHourFormatChar;
524
525 int32_t fAllowedHourFormats[7]; // Actually an array of AllowedHourFormat enum type, ending with UNKNOWN.
526
527 /* internal flags masks for adjustFieldTypes etc. */
528 enum {
529 kDTPGNoFlags = 0,
530 kDTPGFixFractionalSeconds = 1,
531 kDTPGSkeletonUsesCapJ = 2,
532 kDTPGSkeletonUsesLowB = 3,
533 kDTPGSkeletonUsesCapB = 4
534 };
535
536 void initData(const Locale &locale, UErrorCode &status);
537 void addCanonicalItems();
538 void addICUPatterns(const Locale& locale, UErrorCode& status);
539 void hackTimes(const UnicodeString& hackPattern, UErrorCode& status);
540 void addCLDRData(const Locale& locale, UErrorCode& status);
542 void initHashtable(UErrorCode& status);
543 void setDateTimeFromCalendar(const Locale& locale, UErrorCode& status);
544 void setDecimalSymbols(const Locale& locale, UErrorCode& status);
545 UDateTimePatternField getAppendFormatNumber(const char* field) const;
546 UDateTimePatternField getAppendNameNumber(const char* field) const;
547 void getAppendName(UDateTimePatternField field, UnicodeString& value);
548 int32_t getCanonicalIndex(const UnicodeString& field);
552 int32_t getTopBitNumber(int32_t foundMask);
553 void setAvailableFormat(const UnicodeString &key, UErrorCode& status);
554 UBool isAvailableFormatSet(const UnicodeString &key) const;
555 void copyHashtable(Hashtable *other, UErrorCode &status);
556 UBool isCanonicalItem(const UnicodeString& item) const;
557 static void loadAllowedHourFormatsData(UErrorCode &status);
558 void getAllowedHourFormats(const Locale &locale, UErrorCode &status);
559} ;// end class DateTimePatternGenerator
560
562
563#endif
This class provides flexible generation of date format patterns, like "yy-MM-dd".
Definition dtptngen.h:50
static DateTimePatternGenerator * createInstance(UErrorCode &status)
Construct a flexible generator according to default locale.
static UnicodeString staticGetSkeleton(const UnicodeString &pattern, UErrorCode &status)
Utility to return a unique skeleton from a given pattern.
UnicodeString getBestPattern(const UnicodeString &skeleton, UErrorCode &status)
Return the best pattern matching the input skeleton.
static UnicodeString staticGetBaseSkeleton(const UnicodeString &pattern, UErrorCode &status)
Utility to return a unique base skeleton from a given pattern.
void setAppendItemName(UDateTimePatternField field, const UnicodeString &value)
Sets the names of field, eg "era" in English for ERA.
void setDateTimeFormat(const UnicodeString &dateTimeFormat)
The DateTimeFormat is a message format pattern used to compose date and time patterns.
const UnicodeString & getDateTimeFormat() const
Getter corresponding to setDateTimeFormat.
const UnicodeString & getAppendItemName(UDateTimePatternField field) const
Getter corresponding to setAppendItemNames.
const UnicodeString & getAppendItemFormat(UDateTimePatternField field) const
Getter corresponding to setAppendItemFormat.
UBool operator!=(const DateTimePatternGenerator &other) const
Return true if another object is semantically unequal to this one.
static UClassID getStaticClassID(void)
ICU "poor man's RTTI", returns a UClassID for this class.
void setDecimal(const UnicodeString &decimal)
The decimal value is used in formatting fractions of seconds.
const UnicodeString & getPatternForSkeleton(const UnicodeString &skeleton) const
Get the pattern corresponding to a given skeleton.
StringEnumeration * getSkeletons(UErrorCode &status) const
Return a list of all the skeletons (in canonical form) from this class.
UDateTimePatternConflict addPattern(const UnicodeString &pattern, UBool override, UnicodeString &conflictingPattern, UErrorCode &status)
Adds a pattern to the generator.
UBool operator==(const DateTimePatternGenerator &other) const
Return true if another object is semantically equal to this one.
DateTimePatternGenerator * clone() const
Clone DateTimePatternGenerator object.
virtual UClassID getDynamicClassID() const
ICU "poor man's RTTI", returns a UClassID for the actual class.
StringEnumeration * getRedundants(UErrorCode &status)
Return a list of redundant patterns are those which if removed, make no difference in the resulting g...
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.
static DateTimePatternGenerator * createEmptyInstance(UErrorCode &status)
Create an empty generator, to be constructed with addPattern(...) etc.
UnicodeString getSkeleton(const UnicodeString &pattern, UErrorCode &status)
Utility to return a unique skeleton from a given pattern.
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.
UnicodeString getBestPattern(const UnicodeString &skeleton, UDateTimePatternMatchOptions options, UErrorCode &status)
Return the best pattern matching the input skeleton.
void setAppendItemFormat(UDateTimePatternField field, const UnicodeString &value)
An AppendItem format is a pattern used to append a field if there is no good match.
StringEnumeration * getBaseSkeletons(UErrorCode &status) const
Return a list of all the base skeletons (in canonical form) from this class.
virtual ~DateTimePatternGenerator()
Destructor.
static DateTimePatternGenerator * createInstance(const Locale &uLocale, UErrorCode &status)
Construct a flexible generator according to data for a given locale.
static DateTimePatternGenerator * internalMakeInstance(const Locale &uLocale, UErrorCode &status)
For ICU use only.
UnicodeString getBaseSkeleton(const UnicodeString &pattern, UErrorCode &status)
Utility to return a unique base skeleton from a given pattern.
const UnicodeString & getDecimal() const
Getter corresponding to setDecimal.
"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:185
Base class for 'pure' C++ implementations of uenum api.
Definition strenum.h:55
UObject is the common ICU "boilerplate" class.
Definition uobject.h:221
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition unistr.h:294
C++ API: Abstract class for converting dates.
C++ API: Locale ID object.
C API: DateFormat.
C API: Wrapper for icu::DateTimePatternGenerator (unicode/dtptngen.h).
UDateTimePatternConflict
Status return values from udatpg_addPattern().
Definition udatpg.h:116
UDateTimePatternMatchOptions
Masks to control forcing the length of specified fields in the returned pattern to match those in the...
Definition udatpg.h:97
@ UDATPG_MATCH_NO_OPTIONS
Definition udatpg.h:99
UDateTimePatternField
Field number constants for udatpg_getAppendItemFormats() and similar functions.
Definition udatpg.h:53
@ UDATPG_FIELD_COUNT
Definition udatpg.h:87
int8_t UBool
The ICU boolean type.
Definition umachine.h:234
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers,...
Definition utypes.h:476
#define U_I18N_API
Set to export library symbols from inside the i18n library, and to import them from outside.
Definition utypes.h:358
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
Definition uversion.h:130
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition uversion.h:129