ICU 50.2 50.2
dtptngen.h
Go to the documentation of this file.
1/*
2*******************************************************************************
3* Copyright (C) 2007-2011, 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
26
27
28class Hashtable;
29class FormatParser;
30class DateTimeMatcher;
31class DistanceInfo;
32class PatternMap;
33class PtnSkeleton;
34
49class U_I18N_API DateTimePatternGenerator : public UObject {
50public:
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
81
87 DateTimePatternGenerator* clone() const;
88
96 UBool operator==(const DateTimePatternGenerator& other) const;
97
105 UBool operator!=(const DateTimePatternGenerator& other) const;
106
118
133
155 UBool override,
156 UnicodeString& conflictingPattern,
157 UErrorCode& status);
158
178
188
201
211
231 void setDateTimeFormat(const UnicodeString& dateTimeFormat);
232
239
254
255
277 UErrorCode& status);
278
279
297 const UnicodeString& skeleton,
298 UErrorCode& status);
299
323 const UnicodeString& skeleton,
325 UErrorCode& status);
326
339
346 const UnicodeString& getPatternForSkeleton(const UnicodeString& skeleton) const;
347
358
359#ifndef U_HIDE_INTERNAL_API
373#endif /* U_HIDE_INTERNAL_API */
374
386 void setDecimal(const UnicodeString& decimal);
387
393 const UnicodeString& getDecimal() const;
394
401
407 static UClassID U_EXPORT2 getStaticClassID(void);
408
409private:
414 DateTimePatternGenerator(UErrorCode & status);
415
420 DateTimePatternGenerator(const Locale& locale, UErrorCode & status);
421
427 DateTimePatternGenerator(const DateTimePatternGenerator& other);
428
434 DateTimePatternGenerator& operator=(const DateTimePatternGenerator& other);
435
436 Locale pLocale; // pattern locale
437 FormatParser *fp;
438 DateTimeMatcher* dtMatcher;
439 DistanceInfo *distanceInfo;
440 PatternMap *patternMap;
441 UnicodeString appendItemFormats[UDATPG_FIELD_COUNT];
442 UnicodeString appendItemNames[UDATPG_FIELD_COUNT];
443 UnicodeString dateTimeFormat;
444 UnicodeString decimal;
445 DateTimeMatcher *skipMatcher;
446 Hashtable *fAvailableFormatKeyHash;
447 UnicodeString hackPattern;
448 UnicodeString emptyString;
449 UChar fDefaultHourFormatChar;
450
451 void initData(const Locale &locale, UErrorCode &status);
452 void addCanonicalItems();
453 void addICUPatterns(const Locale& locale, UErrorCode& status);
454 void hackTimes(const UnicodeString& hackPattern, UErrorCode& status);
455 void addCLDRData(const Locale& locale, UErrorCode& status);
456 UDateTimePatternConflict addPatternWithSkeleton(const UnicodeString& pattern, const UnicodeString * skeletonToUse, UBool override, UnicodeString& conflictingPattern, UErrorCode& status);
457 void initHashtable(UErrorCode& status);
458 void setDateTimeFromCalendar(const Locale& locale, UErrorCode& status);
459 void setDecimalSymbols(const Locale& locale, UErrorCode& status);
460 UDateTimePatternField getAppendFormatNumber(const char* field) const;
461 UDateTimePatternField getAppendNameNumber(const char* field) const;
462 void getAppendName(UDateTimePatternField field, UnicodeString& value);
463 int32_t getCanonicalIndex(const UnicodeString& field);
464 const UnicodeString* getBestRaw(DateTimeMatcher& source, int32_t includeMask, DistanceInfo* missingFields, const PtnSkeleton** specifiedSkeletonPtr = 0);
465 UnicodeString adjustFieldTypes(const UnicodeString& pattern, const PtnSkeleton* specifiedSkeleton, UBool fixFractionalSeconds, UDateTimePatternMatchOptions options = UDATPG_MATCH_NO_OPTIONS);
466 UnicodeString getBestAppending(int32_t missingFields, UDateTimePatternMatchOptions options = UDATPG_MATCH_NO_OPTIONS);
467 int32_t getTopBitNumber(int32_t foundMask);
468 void setAvailableFormat(const UnicodeString &key, UErrorCode& status);
469 UBool isAvailableFormatSet(const UnicodeString &key) const;
470 void copyHashtable(Hashtable *other, UErrorCode &status);
471 UBool isCanonicalItem(const UnicodeString& item) const;
472} ;// end class DateTimePatternGenerator
473
475
476#endif
static DateTimePatternGenerator * createInstance(UErrorCode &status)
Construct a flexible generator according to default locale.
UnicodeString getBestPattern(const UnicodeString &skeleton, UErrorCode &status)
Return the best pattern matching the input skeleton.
void setAppendItemName(UDateTimePatternField field, const UnicodeString &value)
Sets the names of field, eg "era" in English for ERA.
void setDateTimeFormat(const UnicodeString &dateTimeFormat)
The date time format 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.
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.
A Locale object represents a specific geographical, political, or cultural region.
Definition locid.h:182
Base class for 'pure' C++ implementations of uenum api.
Definition strenum.h:55
UObject is the common ICU "boilerplate" class.
Definition uobject.h:229
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition unistr.h:247
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:200
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:278
void * UClassID
UClassID is used to identify classes without using the compiler's RTTI.
Definition uobject.h:96
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