ICU 54.1 54.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-2013, 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
49 class U_I18N_API DateTimePatternGenerator : public UObject {
50 public:
57 static DateTimePatternGenerator* U_EXPORT2 createInstance(UErrorCode& status);
58
66 static DateTimePatternGenerator* U_EXPORT2 createInstance(const Locale& uLocale, UErrorCode& status);
67
74 static DateTimePatternGenerator* U_EXPORT2 createEmptyInstance(UErrorCode& status);
75
80 virtual ~DateTimePatternGenerator();
81
87 DateTimePatternGenerator* clone() const;
88
96 UBool operator==(const DateTimePatternGenerator& other) const;
97
105 UBool operator!=(const DateTimePatternGenerator& other) const;
106
117 UnicodeString getSkeleton(const UnicodeString& pattern, UErrorCode& status);
118
132 UnicodeString getBaseSkeleton(const UnicodeString& pattern, UErrorCode& status);
133
159 UDateTimePatternConflict addPattern(const UnicodeString& pattern,
160 UBool override,
161 UnicodeString& conflictingPattern,
162 UErrorCode& status);
163
182 void setAppendItemFormat(UDateTimePatternField field, const UnicodeString& value);
183
192 const UnicodeString& getAppendItemFormat(UDateTimePatternField field) const;
193
205 void setAppendItemName(UDateTimePatternField field, const UnicodeString& value);
206
215 const UnicodeString& getAppendItemName(UDateTimePatternField field) const;
216
236 void setDateTimeFormat(const UnicodeString& dateTimeFormat);
237
243 const UnicodeString& getDateTimeFormat() const;
244
263 UnicodeString getBestPattern(const UnicodeString& skeleton, UErrorCode& status);
264
265
285 UnicodeString getBestPattern(const UnicodeString& skeleton,
286 UDateTimePatternMatchOptions options,
287 UErrorCode& status);
288
289
311 UnicodeString replaceFieldTypes(const UnicodeString& pattern,
312 const UnicodeString& skeleton,
313 UErrorCode& status);
314
337 UnicodeString replaceFieldTypes(const UnicodeString& pattern,
338 const UnicodeString& skeleton,
339 UDateTimePatternMatchOptions options,
340 UErrorCode& status);
341
353 StringEnumeration* getSkeletons(UErrorCode& status) const;
354
361 const UnicodeString& getPatternForSkeleton(const UnicodeString& skeleton) const;
362
372 StringEnumeration* getBaseSkeletons(UErrorCode& status) const;
373
374 #ifndef U_HIDE_INTERNAL_API
375
387 StringEnumeration* getRedundants(UErrorCode& status);
388 #endif /* U_HIDE_INTERNAL_API */
389
401 void setDecimal(const UnicodeString& decimal);
402
408 const UnicodeString& getDecimal() const;
409
415 virtual UClassID getDynamicClassID() const;
416
422 static UClassID U_EXPORT2 getStaticClassID(void);
423
424 private:
429 DateTimePatternGenerator(UErrorCode & status);
430
435 DateTimePatternGenerator(const Locale& locale, UErrorCode & status);
436
442 DateTimePatternGenerator(const DateTimePatternGenerator& other);
443
449 DateTimePatternGenerator& operator=(const DateTimePatternGenerator& other);
450
451 Locale pLocale; // pattern locale
452 FormatParser *fp;
453 DateTimeMatcher* dtMatcher;
454 DistanceInfo *distanceInfo;
455 PatternMap *patternMap;
456 UnicodeString appendItemFormats[UDATPG_FIELD_COUNT];
457 UnicodeString appendItemNames[UDATPG_FIELD_COUNT];
458 UnicodeString dateTimeFormat;
459 UnicodeString decimal;
460 DateTimeMatcher *skipMatcher;
461 Hashtable *fAvailableFormatKeyHash;
462 UnicodeString hackPattern;
463 UnicodeString emptyString;
464 UChar fDefaultHourFormatChar;
465
466 /* internal flags masks for adjustFieldTypes etc. */
467 enum {
468 kDTPGNoFlags = 0,
469 kDTPGFixFractionalSeconds = 1,
470 kDTPGSkeletonUsesCapJ = 2
471 };
472
473 void initData(const Locale &locale, UErrorCode &status);
474 void addCanonicalItems();
475 void addICUPatterns(const Locale& locale, UErrorCode& status);
476 void hackTimes(const UnicodeString& hackPattern, UErrorCode& status);
477 void addCLDRData(const Locale& locale, UErrorCode& status);
478 UDateTimePatternConflict addPatternWithSkeleton(const UnicodeString& pattern, const UnicodeString * skeletonToUse, UBool override, UnicodeString& conflictingPattern, UErrorCode& status);
479 void initHashtable(UErrorCode& status);
480 void setDateTimeFromCalendar(const Locale& locale, UErrorCode& status);
481 void setDecimalSymbols(const Locale& locale, UErrorCode& status);
482 UDateTimePatternField getAppendFormatNumber(const char* field) const;
483 UDateTimePatternField getAppendNameNumber(const char* field) const;
484 void getAppendName(UDateTimePatternField field, UnicodeString& value);
485 int32_t getCanonicalIndex(const UnicodeString& field);
486 const UnicodeString* getBestRaw(DateTimeMatcher& source, int32_t includeMask, DistanceInfo* missingFields, const PtnSkeleton** specifiedSkeletonPtr = 0);
487 UnicodeString adjustFieldTypes(const UnicodeString& pattern, const PtnSkeleton* specifiedSkeleton, int32_t flags, UDateTimePatternMatchOptions options = UDATPG_MATCH_NO_OPTIONS);
488 UnicodeString getBestAppending(int32_t missingFields, int32_t flags, UDateTimePatternMatchOptions options = UDATPG_MATCH_NO_OPTIONS);
489 int32_t getTopBitNumber(int32_t foundMask);
490 void setAvailableFormat(const UnicodeString &key, UErrorCode& status);
491 UBool isAvailableFormatSet(const UnicodeString &key) const;
492 void copyHashtable(Hashtable *other, UErrorCode &status);
493 UBool isCanonicalItem(const UnicodeString& item) const;
494 } ;// end class DateTimePatternGenerator
495
496 U_NAMESPACE_END
497
498 #endif