ICU 55.1 55.1

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

- File List
- Globals

All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
dtptngen.h
Go to the documentation of this file.
1 /*
2 *******************************************************************************
3 * Copyright (C) 2007-2015, 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
20 U_NAMESPACE_BEGIN
21
28 class Hashtable;
29 class FormatParser;
30 class DateTimeMatcher;
31 class DistanceInfo;
32 class PatternMap;
33 class PtnSkeleton;
34 class SharedDateTimePatternGenerator;
35
50 class U_I18N_API DateTimePatternGenerator : public UObject {
51 public:
58 static DateTimePatternGenerator* U_EXPORT2 createInstance(UErrorCode& status);
59
67 static DateTimePatternGenerator* U_EXPORT2 createInstance(const Locale& uLocale, UErrorCode& status);
68
69 #ifndef U_HIDE_INTERNAL_API
70
76 static DateTimePatternGenerator* U_EXPORT2 internalMakeInstance(const Locale& uLocale, UErrorCode& status);
77
78 #endif /* U_HIDE_INTERNAL_API */
79
86 static DateTimePatternGenerator* U_EXPORT2 createEmptyInstance(UErrorCode& status);
87
92 virtual ~DateTimePatternGenerator();
93
99 DateTimePatternGenerator* clone() const;
100
108 UBool operator==(const DateTimePatternGenerator& other) const;
109
117 UBool operator!=(const DateTimePatternGenerator& other) const;
118
129 UnicodeString getSkeleton(const UnicodeString& pattern, UErrorCode& status);
130
144 UnicodeString getBaseSkeleton(const UnicodeString& pattern, UErrorCode& status);
145
171 UDateTimePatternConflict addPattern(const UnicodeString& pattern,
172 UBool override,
173 UnicodeString& conflictingPattern,
174 UErrorCode& status);
175
194 void setAppendItemFormat(UDateTimePatternField field, const UnicodeString& value);
195
204 const UnicodeString& getAppendItemFormat(UDateTimePatternField field) const;
205
217 void setAppendItemName(UDateTimePatternField field, const UnicodeString& value);
218
227 const UnicodeString& getAppendItemName(UDateTimePatternField field) const;
228
250 void setDateTimeFormat(const UnicodeString& dateTimeFormat);
251
257 const UnicodeString& getDateTimeFormat() const;
258
277 UnicodeString getBestPattern(const UnicodeString& skeleton, UErrorCode& status);
278
279
299 UnicodeString getBestPattern(const UnicodeString& skeleton,
300 UDateTimePatternMatchOptions options,
301 UErrorCode& status);
302
303
325 UnicodeString replaceFieldTypes(const UnicodeString& pattern,
326 const UnicodeString& skeleton,
327 UErrorCode& status);
328
351 UnicodeString replaceFieldTypes(const UnicodeString& pattern,
352 const UnicodeString& skeleton,
353 UDateTimePatternMatchOptions options,
354 UErrorCode& status);
355
367 StringEnumeration* getSkeletons(UErrorCode& status) const;
368
375 const UnicodeString& getPatternForSkeleton(const UnicodeString& skeleton) const;
376
386 StringEnumeration* getBaseSkeletons(UErrorCode& status) const;
387
388 #ifndef U_HIDE_INTERNAL_API
389
401 StringEnumeration* getRedundants(UErrorCode& status);
402 #endif /* U_HIDE_INTERNAL_API */
403
415 void setDecimal(const UnicodeString& decimal);
416
422 const UnicodeString& getDecimal() const;
423
429 virtual UClassID getDynamicClassID() const;
430
436 static UClassID U_EXPORT2 getStaticClassID(void);
437
438 private:
443 DateTimePatternGenerator(UErrorCode & status);
444
449 DateTimePatternGenerator(const Locale& locale, UErrorCode & status);
450
456 DateTimePatternGenerator(const DateTimePatternGenerator& other);
457
463 DateTimePatternGenerator& operator=(const DateTimePatternGenerator& other);
464
465 Locale pLocale; // pattern locale
466 FormatParser *fp;
467 DateTimeMatcher* dtMatcher;
468 DistanceInfo *distanceInfo;
469 PatternMap *patternMap;
470 UnicodeString appendItemFormats[UDATPG_FIELD_COUNT];
471 UnicodeString appendItemNames[UDATPG_FIELD_COUNT];
472 UnicodeString dateTimeFormat;
473 UnicodeString decimal;
474 DateTimeMatcher *skipMatcher;
475 Hashtable *fAvailableFormatKeyHash;
476 UnicodeString hackPattern;
477 UnicodeString emptyString;
478 UChar fDefaultHourFormatChar;
479
480 /* internal flags masks for adjustFieldTypes etc. */
481 enum {
482 kDTPGNoFlags = 0,
483 kDTPGFixFractionalSeconds = 1,
484 kDTPGSkeletonUsesCapJ = 2
485 };
486
487 void initData(const Locale &locale, UErrorCode &status);
488 void addCanonicalItems();
489 void addICUPatterns(const Locale& locale, UErrorCode& status);
490 void hackTimes(const UnicodeString& hackPattern, UErrorCode& status);
491 void addCLDRData(const Locale& locale, UErrorCode& status);
492 UDateTimePatternConflict addPatternWithSkeleton(const UnicodeString& pattern, const UnicodeString * skeletonToUse, UBool override, UnicodeString& conflictingPattern, UErrorCode& status);
493 void initHashtable(UErrorCode& status);
494 void setDateTimeFromCalendar(const Locale& locale, UErrorCode& status);
495 void setDecimalSymbols(const Locale& locale, UErrorCode& status);
496 UDateTimePatternField getAppendFormatNumber(const char* field) const;
497 UDateTimePatternField getAppendNameNumber(const char* field) const;
498 void getAppendName(UDateTimePatternField field, UnicodeString& value);
499 int32_t getCanonicalIndex(const UnicodeString& field);
500 const UnicodeString* getBestRaw(DateTimeMatcher& source, int32_t includeMask, DistanceInfo* missingFields, const PtnSkeleton** specifiedSkeletonPtr = 0);
501 UnicodeString adjustFieldTypes(const UnicodeString& pattern, const PtnSkeleton* specifiedSkeleton, int32_t flags, UDateTimePatternMatchOptions options = UDATPG_MATCH_NO_OPTIONS);
502 UnicodeString getBestAppending(int32_t missingFields, int32_t flags, UDateTimePatternMatchOptions options = UDATPG_MATCH_NO_OPTIONS);
503 int32_t getTopBitNumber(int32_t foundMask);
504 void setAvailableFormat(const UnicodeString &key, UErrorCode& status);
505 UBool isAvailableFormatSet(const UnicodeString &key) const;
506 void copyHashtable(Hashtable *other, UErrorCode &status);
507 UBool isCanonicalItem(const UnicodeString& item) const;
508 } ;// end class DateTimePatternGenerator
509
510 U_NAMESPACE_END
511
512 #endif