ICU 58.2 58.2

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

- File List
- Globals

dtptngen.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) 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
22 U_NAMESPACE_BEGIN
23
30 class Hashtable;
31 class FormatParser;
32 class DateTimeMatcher;
33 class DistanceInfo;
34 class PatternMap;
35 class PtnSkeleton;
36 class SharedDateTimePatternGenerator;
37
52 class U_I18N_API DateTimePatternGenerator : public UObject {
53 public:
60 static DateTimePatternGenerator* U_EXPORT2 createInstance(UErrorCode& status);
61
69 static DateTimePatternGenerator* U_EXPORT2 createInstance(const Locale& uLocale, UErrorCode& status);
70
71 #ifndef U_HIDE_INTERNAL_API
72
78 static DateTimePatternGenerator* U_EXPORT2 internalMakeInstance(const Locale& uLocale, UErrorCode& status);
79
80 #endif /* U_HIDE_INTERNAL_API */
81
88 static DateTimePatternGenerator* U_EXPORT2 createEmptyInstance(UErrorCode& status);
89
94 virtual ~DateTimePatternGenerator();
95
101 DateTimePatternGenerator* clone() const;
102
110 UBool operator==(const DateTimePatternGenerator& other) const;
111
119 UBool operator!=(const DateTimePatternGenerator& other) const;
120
131 static UnicodeString staticGetSkeleton(const UnicodeString& pattern, UErrorCode& status);
132
145 UnicodeString getSkeleton(const UnicodeString& pattern, UErrorCode& status); /* {
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
165 static UnicodeString staticGetBaseSkeleton(const UnicodeString& pattern, UErrorCode& status);
166
182 UnicodeString getBaseSkeleton(const UnicodeString& pattern, UErrorCode& status); /* {
183 The function is commented out because it is a stable API calling a draft API.
184 After staticGetBaseSkeleton becomes stable, staticGetBaseSkeleton can be used and
185 these comments and the definition of getBaseSkeleton in dtptngen.cpp should be removed.
186 return staticGetBaseSkeleton(pattern, status);
187 }*/
188
214 UDateTimePatternConflict addPattern(const UnicodeString& pattern,
215 UBool override,
216 UnicodeString& conflictingPattern,
217 UErrorCode& status);
218
237 void setAppendItemFormat(UDateTimePatternField field, const UnicodeString& value);
238
247 const UnicodeString& getAppendItemFormat(UDateTimePatternField field) const;
248
260 void setAppendItemName(UDateTimePatternField field, const UnicodeString& value);
261
270 const UnicodeString& getAppendItemName(UDateTimePatternField field) const;
271
293 void setDateTimeFormat(const UnicodeString& dateTimeFormat);
294
300 const UnicodeString& getDateTimeFormat() const;
301
320 UnicodeString getBestPattern(const UnicodeString& skeleton, UErrorCode& status);
321
322
342 UnicodeString getBestPattern(const UnicodeString& skeleton,
343 UDateTimePatternMatchOptions options,
344 UErrorCode& status);
345
346
368 UnicodeString replaceFieldTypes(const UnicodeString& pattern,
369 const UnicodeString& skeleton,
370 UErrorCode& status);
371
394 UnicodeString replaceFieldTypes(const UnicodeString& pattern,
395 const UnicodeString& skeleton,
396 UDateTimePatternMatchOptions options,
397 UErrorCode& status);
398
410 StringEnumeration* getSkeletons(UErrorCode& status) const;
411
418 const UnicodeString& getPatternForSkeleton(const UnicodeString& skeleton) const;
419
429 StringEnumeration* getBaseSkeletons(UErrorCode& status) const;
430
431 #ifndef U_HIDE_INTERNAL_API
432
444 StringEnumeration* getRedundants(UErrorCode& status);
445 #endif /* U_HIDE_INTERNAL_API */
446
458 void setDecimal(const UnicodeString& decimal);
459
465 const UnicodeString& getDecimal() const;
466
472 virtual UClassID getDynamicClassID() const;
473
479 static UClassID U_EXPORT2 getStaticClassID(void);
480
481 private:
486 DateTimePatternGenerator(UErrorCode & status);
487
492 DateTimePatternGenerator(const Locale& locale, UErrorCode & status);
493
499 DateTimePatternGenerator(const DateTimePatternGenerator& other);
500
506 DateTimePatternGenerator& operator=(const DateTimePatternGenerator& other);
507
508 Locale pLocale; // pattern locale
509 FormatParser *fp;
510 DateTimeMatcher* dtMatcher;
511 DistanceInfo *distanceInfo;
512 PatternMap *patternMap;
513 UnicodeString appendItemFormats[UDATPG_FIELD_COUNT];
514 UnicodeString appendItemNames[UDATPG_FIELD_COUNT];
515 UnicodeString dateTimeFormat;
516 UnicodeString decimal;
517 DateTimeMatcher *skipMatcher;
518 Hashtable *fAvailableFormatKeyHash;
519 UnicodeString emptyString;
520 UChar fDefaultHourFormatChar;
521
522 int32_t fAllowedHourFormats[7]; // Actually an array of AllowedHourFormat enum type, ending with UNKNOWN.
523
524 /* internal flags masks for adjustFieldTypes etc. */
525 enum {
526 kDTPGNoFlags = 0,
527 kDTPGFixFractionalSeconds = 1,
528 kDTPGSkeletonUsesCapJ = 2,
529 kDTPGSkeletonUsesLowB = 3,
530 kDTPGSkeletonUsesCapB = 4
531 };
532
533 void initData(const Locale &locale, UErrorCode &status);
534 void addCanonicalItems(UErrorCode &status);
535 void addICUPatterns(const Locale& locale, UErrorCode& status);
536 void hackTimes(const UnicodeString& hackPattern, UErrorCode& status);
537 void getCalendarTypeToUse(const Locale& locale, CharString& destination, UErrorCode& err);
538 void consumeShortTimePattern(const UnicodeString& shortTimePattern, UErrorCode& status);
539 void addCLDRData(const Locale& locale, UErrorCode& status);
540 UDateTimePatternConflict addPatternWithSkeleton(const UnicodeString& pattern, const UnicodeString * skeletonToUse, UBool override, UnicodeString& conflictingPattern, UErrorCode& status);
541 void initHashtable(UErrorCode& status);
542 void setDateTimeFromCalendar(const Locale& locale, UErrorCode& status);
543 void setDecimalSymbols(const Locale& locale, UErrorCode& status);
544 UDateTimePatternField getAppendFormatNumber(const char* field) const;
545 UDateTimePatternField getAppendNameNumber(const char* field) const;
546 UnicodeString& getMutableAppendItemName(UDateTimePatternField field);
547 void getAppendName(UDateTimePatternField field, UnicodeString& value);
548 int32_t getCanonicalIndex(const UnicodeString& field);
549 const UnicodeString* getBestRaw(DateTimeMatcher& source, int32_t includeMask, DistanceInfo* missingFields, const PtnSkeleton** specifiedSkeletonPtr = 0);
550 UnicodeString adjustFieldTypes(const UnicodeString& pattern, const PtnSkeleton* specifiedSkeleton, int32_t flags, UDateTimePatternMatchOptions options = UDATPG_MATCH_NO_OPTIONS);
551 UnicodeString getBestAppending(int32_t missingFields, int32_t flags, UDateTimePatternMatchOptions options = UDATPG_MATCH_NO_OPTIONS);
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 U_CALLCONV loadAllowedHourFormatsData(UErrorCode &status);
558 void getAllowedHourFormats(const Locale &locale, UErrorCode &status);
559
560 struct AppendItemFormatsSink;
561 struct AppendItemNamesSink;
562 struct AvailableFormatsSink;
563 } ;// end class DateTimePatternGenerator
564
565 U_NAMESPACE_END
566
567 #endif
icu::UObject::getDynamicClassID
virtual UClassID getDynamicClassID() const
ICU4C "poor man&#39;s RTTI", returns a UClassID for the actual ICU class.
icu::DateTimePatternGenerator
This class provides flexible generation of date format patterns, like "yy-MM-dd". ...
Definition: dtptngen.h:52
icu::operator==
U_EXPORT UBool operator==(const StringPiece &x, const StringPiece &y)
Global operator == for StringPiece.
U_CALLCONV
#define U_CALLCONV
Similar to U_CDECL_BEGIN/U_CDECL_END, this qualifier is necessary in callback function typedefs to ma...
Definition: platform.h:857
UClassID
void * UClassID
UClassID is used to identify classes without using the compiler&#39;s RTTI.
Definition: uobject.h:93
icu::StringEnumeration
Base class for &#39;pure&#39; C++ implementations of uenum api.
Definition: strenum.h:57
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
udatpg.h
C API: Wrapper for icu::DateTimePatternGenerator (unicode/dtptngen.h).
icu::operator!=
UBool operator!=(const StringPiece &x, const StringPiece &y)
Global operator != for StringPiece.
Definition: stringpiece.h:220
udat.h
C API: DateFormat.
UDATPG_MATCH_NO_OPTIONS
Definition: udatpg.h:107
UDateTimePatternConflict
UDateTimePatternConflict
Status return values from udatpg_addPattern().
Definition: udatpg.h:124
UDATPG_FIELD_COUNT
One more than the highest normal UDateTimePatternField value.
Definition: udatpg.h:95
UChar
uint16_t UChar
Define UChar to be UCHAR_TYPE, if that is #defined (for example, to char16_t), or wchar_t if that is ...
Definition: umachine.h:337
U_NAMESPACE_END
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
Definition: uversion.h:132
UDateTimePatternField
UDateTimePatternField
Field number constants for udatpg_getAppendItemFormats() and similar functions.
Definition: udatpg.h:55
UErrorCode
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers...
Definition: utypes.h:396
datefmt.h
C++ API: Abstract class for converting dates.
locid.h
C++ API: Locale ID object.
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
UDateTimePatternMatchOptions
UDateTimePatternMatchOptions
Masks to control forcing the length of specified fields in the returned pattern to match those in the...
Definition: udatpg.h:105
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