ICU 56.1: dtptngen.h Source File

ICU 56.1 56.1

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

- File List
- Globals

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
119 #ifndef U_HIDE_DRAFT_API
120
130 static UnicodeString staticGetSkeleton(const UnicodeString& pattern, UErrorCode& status);
131 #endif /* U_HIDE_DRAFT_API */
132
145 UnicodeString getSkeleton(const UnicodeString& pattern, UErrorCode& status) {
146 return staticGetSkeleton(pattern, status);
147 }
148
149 #ifndef U_HIDE_DRAFT_API
150
163 static UnicodeString staticGetBaseSkeleton(const UnicodeString& pattern, UErrorCode& status);
164 #endif /* U_HIDE_DRAFT_API */
165
181 UnicodeString getBaseSkeleton(const UnicodeString& pattern, UErrorCode& status) {
182 return staticGetBaseSkeleton(pattern, status);
183 }
184
210 UDateTimePatternConflict addPattern(const UnicodeString& pattern,
211 UBool override,
212 UnicodeString& conflictingPattern,
213 UErrorCode& status);
214
233 void setAppendItemFormat(UDateTimePatternField field, const UnicodeString& value);
234
243 const UnicodeString& getAppendItemFormat(UDateTimePatternField field) const;
244
256 void setAppendItemName(UDateTimePatternField field, const UnicodeString& value);
257
266 const UnicodeString& getAppendItemName(UDateTimePatternField field) const;
267
289 void setDateTimeFormat(const UnicodeString& dateTimeFormat);
290
296 const UnicodeString& getDateTimeFormat() const;
297
316 UnicodeString getBestPattern(const UnicodeString& skeleton, UErrorCode& status);
317
318
338 UnicodeString getBestPattern(const UnicodeString& skeleton,
339 UDateTimePatternMatchOptions options,
340 UErrorCode& status);
341
342
364 UnicodeString replaceFieldTypes(const UnicodeString& pattern,
365 const UnicodeString& skeleton,
366 UErrorCode& status);
367
390 UnicodeString replaceFieldTypes(const UnicodeString& pattern,
391 const UnicodeString& skeleton,
392 UDateTimePatternMatchOptions options,
393 UErrorCode& status);
394
406 StringEnumeration* getSkeletons(UErrorCode& status) const;
407
414 const UnicodeString& getPatternForSkeleton(const UnicodeString& skeleton) const;
415
425 StringEnumeration* getBaseSkeletons(UErrorCode& status) const;
426
427 #ifndef U_HIDE_INTERNAL_API
428
440 StringEnumeration* getRedundants(UErrorCode& status);
441 #endif /* U_HIDE_INTERNAL_API */
442
454 void setDecimal(const UnicodeString& decimal);
455
461 const UnicodeString& getDecimal() const;
462
468 virtual UClassID getDynamicClassID() const;
469
475 static UClassID U_EXPORT2 getStaticClassID(void);
476
477 private:
482 DateTimePatternGenerator(UErrorCode & status);
483
488 DateTimePatternGenerator(const Locale& locale, UErrorCode & status);
489
495 DateTimePatternGenerator(const DateTimePatternGenerator& other);
496
502 DateTimePatternGenerator& operator=(const DateTimePatternGenerator& other);
503
504 Locale pLocale; // pattern locale
505 FormatParser *fp;
506 DateTimeMatcher* dtMatcher;
507 DistanceInfo *distanceInfo;
508 PatternMap *patternMap;
509 UnicodeString appendItemFormats[UDATPG_FIELD_COUNT];
510 UnicodeString appendItemNames[UDATPG_FIELD_COUNT];
511 UnicodeString dateTimeFormat;
512 UnicodeString decimal;
513 DateTimeMatcher *skipMatcher;
514 Hashtable *fAvailableFormatKeyHash;
515 UnicodeString hackPattern;
516 UnicodeString emptyString;
517 UChar fDefaultHourFormatChar;
518
519 /* internal flags masks for adjustFieldTypes etc. */
520 enum {
521 kDTPGNoFlags = 0,
522 kDTPGFixFractionalSeconds = 1,
523 kDTPGSkeletonUsesCapJ = 2
524 };
525
526 void initData(const Locale &locale, UErrorCode &status);
527 void addCanonicalItems();
528 void addICUPatterns(const Locale& locale, UErrorCode& status);
529 void hackTimes(const UnicodeString& hackPattern, UErrorCode& status);
530 void addCLDRData(const Locale& locale, UErrorCode& status);
531 UDateTimePatternConflict addPatternWithSkeleton(const UnicodeString& pattern, const UnicodeString * skeletonToUse, UBool override, UnicodeString& conflictingPattern, UErrorCode& status);
532 void initHashtable(UErrorCode& status);
533 void setDateTimeFromCalendar(const Locale& locale, UErrorCode& status);
534 void setDecimalSymbols(const Locale& locale, UErrorCode& status);
535 UDateTimePatternField getAppendFormatNumber(const char* field) const;
536 UDateTimePatternField getAppendNameNumber(const char* field) const;
537 void getAppendName(UDateTimePatternField field, UnicodeString& value);
538 int32_t getCanonicalIndex(const UnicodeString& field);
539 const UnicodeString* getBestRaw(DateTimeMatcher& source, int32_t includeMask, DistanceInfo* missingFields, const PtnSkeleton** specifiedSkeletonPtr = 0);
540 UnicodeString adjustFieldTypes(const UnicodeString& pattern, const PtnSkeleton* specifiedSkeleton, int32_t flags, UDateTimePatternMatchOptions options = UDATPG_MATCH_NO_OPTIONS);
541 UnicodeString getBestAppending(int32_t missingFields, int32_t flags, UDateTimePatternMatchOptions options = UDATPG_MATCH_NO_OPTIONS);
542 int32_t getTopBitNumber(int32_t foundMask);
543 void setAvailableFormat(const UnicodeString &key, UErrorCode& status);
544 UBool isAvailableFormatSet(const UnicodeString &key) const;
545 void copyHashtable(Hashtable *other, UErrorCode &status);
546 UBool isCanonicalItem(const UnicodeString& item) const;
547 } ;// end class DateTimePatternGenerator
548
549 U_NAMESPACE_END
550
551 #endif
icu::UObject::getDynamicClassID
virtual UClassID getDynamicClassID() const
ICU4C "poor man'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:50
icu::operator==
U_EXPORT UBool operator==(const StringPiece &x, const StringPiece &y)
Global operator == for StringPiece.
UClassID
void * UClassID
UClassID is used to identify classes without using the compiler's RTTI.
Definition: uobject.h:91
icu::StringEnumeration
Base class for 'pure' C++ implementations of uenum api.
Definition: strenum.h:55
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:358
U_NAMESPACE_BEGIN
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition: uversion.h:129
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:218
udat.h
C API: DateFormat.
UDATPG_MATCH_NO_OPTIONS
Definition: udatpg.h:99
UDateTimePatternConflict
UDateTimePatternConflict
Status return values from udatpg_addPattern().
Definition: udatpg.h:116
icu::DateTimePatternGenerator::getSkeleton
UnicodeString getSkeleton(const UnicodeString &pattern, UErrorCode &status)
Utility to return a unique skeleton from a given pattern.
Definition: dtptngen.h:145
UDATPG_FIELD_COUNT
Definition: udatpg.h:87
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:312
U_NAMESPACE_END
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
Definition: uversion.h:130
UDateTimePatternField
UDateTimePatternField
Field number constants for udatpg_getAppendItemFormats() and similar functions.
Definition: udatpg.h:53
UErrorCode
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers...
Definition: utypes.h:476
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:293
icu::UObject
UObject is the common ICU "boilerplate" class.
Definition: uobject.h:221
UDateTimePatternMatchOptions
UDateTimePatternMatchOptions
Masks to control forcing the length of specified fields in the returned pattern to match those in the...
Definition: udatpg.h:97
UBool
int8_t UBool
The ICU boolean type.
Definition: umachine.h:234
icu::DateTimePatternGenerator::getBaseSkeleton
UnicodeString getBaseSkeleton(const UnicodeString &pattern, UErrorCode &status)
Utility to return a unique base skeleton from a given pattern.
Definition: dtptngen.h:181
icu::Locale
A Locale object represents a specific geographical, political, or cultural region.
Definition: locid.h:185