Wed, 31 Dec 2014 07:22:50 +0100
Correct previous dual key logic pending first delivery installment.
michael@0 | 1 | /* |
michael@0 | 2 | ******************************************************************************* |
michael@0 | 3 | * Copyright (C) 2007-2013, International Business Machines Corporation and |
michael@0 | 4 | * others. All Rights Reserved. |
michael@0 | 5 | ******************************************************************************* |
michael@0 | 6 | * |
michael@0 | 7 | * File DTPTNGEN.H |
michael@0 | 8 | * |
michael@0 | 9 | ******************************************************************************* |
michael@0 | 10 | */ |
michael@0 | 11 | |
michael@0 | 12 | #ifndef __DTPTNGEN_H__ |
michael@0 | 13 | #define __DTPTNGEN_H__ |
michael@0 | 14 | |
michael@0 | 15 | #include "unicode/datefmt.h" |
michael@0 | 16 | #include "unicode/locid.h" |
michael@0 | 17 | #include "unicode/udat.h" |
michael@0 | 18 | #include "unicode/udatpg.h" |
michael@0 | 19 | |
michael@0 | 20 | U_NAMESPACE_BEGIN |
michael@0 | 21 | |
michael@0 | 22 | /** |
michael@0 | 23 | * \file |
michael@0 | 24 | * \brief C++ API: Date/Time Pattern Generator |
michael@0 | 25 | */ |
michael@0 | 26 | |
michael@0 | 27 | |
michael@0 | 28 | class Hashtable; |
michael@0 | 29 | class FormatParser; |
michael@0 | 30 | class DateTimeMatcher; |
michael@0 | 31 | class DistanceInfo; |
michael@0 | 32 | class PatternMap; |
michael@0 | 33 | class PtnSkeleton; |
michael@0 | 34 | |
michael@0 | 35 | /** |
michael@0 | 36 | * This class provides flexible generation of date format patterns, like "yy-MM-dd". |
michael@0 | 37 | * The user can build up the generator by adding successive patterns. Once that |
michael@0 | 38 | * is done, a query can be made using a "skeleton", which is a pattern which just |
michael@0 | 39 | * includes the desired fields and lengths. The generator will return the "best fit" |
michael@0 | 40 | * pattern corresponding to that skeleton. |
michael@0 | 41 | * <p>The main method people will use is getBestPattern(String skeleton), |
michael@0 | 42 | * since normally this class is pre-built with data from a particular locale. |
michael@0 | 43 | * However, generators can be built directly from other data as well. |
michael@0 | 44 | * <p><i>Issue: may be useful to also have a function that returns the list of |
michael@0 | 45 | * fields in a pattern, in order, since we have that internally. |
michael@0 | 46 | * That would be useful for getting the UI order of field elements.</i> |
michael@0 | 47 | * @stable ICU 3.8 |
michael@0 | 48 | **/ |
michael@0 | 49 | class U_I18N_API DateTimePatternGenerator : public UObject { |
michael@0 | 50 | public: |
michael@0 | 51 | /** |
michael@0 | 52 | * Construct a flexible generator according to default locale. |
michael@0 | 53 | * @param status Output param set to success/failure code on exit, |
michael@0 | 54 | * which must not indicate a failure before the function call. |
michael@0 | 55 | * @stable ICU 3.8 |
michael@0 | 56 | */ |
michael@0 | 57 | static DateTimePatternGenerator* U_EXPORT2 createInstance(UErrorCode& status); |
michael@0 | 58 | |
michael@0 | 59 | /** |
michael@0 | 60 | * Construct a flexible generator according to data for a given locale. |
michael@0 | 61 | * @param uLocale |
michael@0 | 62 | * @param status Output param set to success/failure code on exit, |
michael@0 | 63 | * which must not indicate a failure before the function call. |
michael@0 | 64 | * @stable ICU 3.8 |
michael@0 | 65 | */ |
michael@0 | 66 | static DateTimePatternGenerator* U_EXPORT2 createInstance(const Locale& uLocale, UErrorCode& status); |
michael@0 | 67 | |
michael@0 | 68 | /** |
michael@0 | 69 | * Create an empty generator, to be constructed with addPattern(...) etc. |
michael@0 | 70 | * @param status Output param set to success/failure code on exit, |
michael@0 | 71 | * which must not indicate a failure before the function call. |
michael@0 | 72 | * @stable ICU 3.8 |
michael@0 | 73 | */ |
michael@0 | 74 | static DateTimePatternGenerator* U_EXPORT2 createEmptyInstance(UErrorCode& status); |
michael@0 | 75 | |
michael@0 | 76 | /** |
michael@0 | 77 | * Destructor. |
michael@0 | 78 | * @stable ICU 3.8 |
michael@0 | 79 | */ |
michael@0 | 80 | virtual ~DateTimePatternGenerator(); |
michael@0 | 81 | |
michael@0 | 82 | /** |
michael@0 | 83 | * Clone DateTimePatternGenerator object. Clients are responsible for |
michael@0 | 84 | * deleting the DateTimePatternGenerator object cloned. |
michael@0 | 85 | * @stable ICU 3.8 |
michael@0 | 86 | */ |
michael@0 | 87 | DateTimePatternGenerator* clone() const; |
michael@0 | 88 | |
michael@0 | 89 | /** |
michael@0 | 90 | * Return true if another object is semantically equal to this one. |
michael@0 | 91 | * |
michael@0 | 92 | * @param other the DateTimePatternGenerator object to be compared with. |
michael@0 | 93 | * @return true if other is semantically equal to this. |
michael@0 | 94 | * @stable ICU 3.8 |
michael@0 | 95 | */ |
michael@0 | 96 | UBool operator==(const DateTimePatternGenerator& other) const; |
michael@0 | 97 | |
michael@0 | 98 | /** |
michael@0 | 99 | * Return true if another object is semantically unequal to this one. |
michael@0 | 100 | * |
michael@0 | 101 | * @param other the DateTimePatternGenerator object to be compared with. |
michael@0 | 102 | * @return true if other is semantically unequal to this. |
michael@0 | 103 | * @stable ICU 3.8 |
michael@0 | 104 | */ |
michael@0 | 105 | UBool operator!=(const DateTimePatternGenerator& other) const; |
michael@0 | 106 | |
michael@0 | 107 | /** |
michael@0 | 108 | * Utility to return a unique skeleton from a given pattern. For example, |
michael@0 | 109 | * both "MMM-dd" and "dd/MMM" produce the skeleton "MMMdd". |
michael@0 | 110 | * |
michael@0 | 111 | * @param pattern Input pattern, such as "dd/MMM" |
michael@0 | 112 | * @param status Output param set to success/failure code on exit, |
michael@0 | 113 | * which must not indicate a failure before the function call. |
michael@0 | 114 | * @return skeleton such as "MMMdd" |
michael@0 | 115 | * @stable ICU 3.8 |
michael@0 | 116 | */ |
michael@0 | 117 | UnicodeString getSkeleton(const UnicodeString& pattern, UErrorCode& status); |
michael@0 | 118 | |
michael@0 | 119 | /** |
michael@0 | 120 | * Utility to return a unique base skeleton from a given pattern. This is |
michael@0 | 121 | * the same as the skeleton, except that differences in length are minimized |
michael@0 | 122 | * so as to only preserve the difference between string and numeric form. So |
michael@0 | 123 | * for example, both "MMM-dd" and "d/MMM" produce the skeleton "MMMd" |
michael@0 | 124 | * (notice the single d). |
michael@0 | 125 | * |
michael@0 | 126 | * @param pattern Input pattern, such as "dd/MMM" |
michael@0 | 127 | * @param status Output param set to success/failure code on exit, |
michael@0 | 128 | * which must not indicate a failure before the function call. |
michael@0 | 129 | * @return base skeleton, such as "Md" |
michael@0 | 130 | * @stable ICU 3.8 |
michael@0 | 131 | */ |
michael@0 | 132 | UnicodeString getBaseSkeleton(const UnicodeString& pattern, UErrorCode& status); |
michael@0 | 133 | |
michael@0 | 134 | /** |
michael@0 | 135 | * Adds a pattern to the generator. If the pattern has the same skeleton as |
michael@0 | 136 | * an existing pattern, and the override parameter is set, then the previous |
michael@0 | 137 | * value is overriden. Otherwise, the previous value is retained. In either |
michael@0 | 138 | * case, the conflicting status is set and previous vale is stored in |
michael@0 | 139 | * conflicting pattern. |
michael@0 | 140 | * <p> |
michael@0 | 141 | * Note that single-field patterns (like "MMM") are automatically added, and |
michael@0 | 142 | * don't need to be added explicitly! |
michael@0 | 143 | * |
michael@0 | 144 | * @param pattern Input pattern, such as "dd/MMM" |
michael@0 | 145 | * @param override When existing values are to be overridden use true, |
michael@0 | 146 | * otherwise use false. |
michael@0 | 147 | * @param conflictingPattern Previous pattern with the same skeleton. |
michael@0 | 148 | * @param status Output param set to success/failure code on exit, |
michael@0 | 149 | * which must not indicate a failure before the function call. |
michael@0 | 150 | * @return conflicting status. The value could be UDATPG_NO_CONFLICT, |
michael@0 | 151 | * UDATPG_BASE_CONFLICT or UDATPG_CONFLICT. |
michael@0 | 152 | * @stable ICU 3.8 |
michael@0 | 153 | * <p> |
michael@0 | 154 | * <h4>Sample code</h4> |
michael@0 | 155 | * \snippet samples/dtptngsample/dtptngsample.cpp getBestPatternExample1 |
michael@0 | 156 | * \snippet samples/dtptngsample/dtptngsample.cpp addPatternExample |
michael@0 | 157 | * <p> |
michael@0 | 158 | */ |
michael@0 | 159 | UDateTimePatternConflict addPattern(const UnicodeString& pattern, |
michael@0 | 160 | UBool override, |
michael@0 | 161 | UnicodeString& conflictingPattern, |
michael@0 | 162 | UErrorCode& status); |
michael@0 | 163 | |
michael@0 | 164 | /** |
michael@0 | 165 | * An AppendItem format is a pattern used to append a field if there is no |
michael@0 | 166 | * good match. For example, suppose that the input skeleton is "GyyyyMMMd", |
michael@0 | 167 | * and there is no matching pattern internally, but there is a pattern |
michael@0 | 168 | * matching "yyyyMMMd", say "d-MM-yyyy". Then that pattern is used, plus the |
michael@0 | 169 | * G. The way these two are conjoined is by using the AppendItemFormat for G |
michael@0 | 170 | * (era). So if that value is, say "{0}, {1}" then the final resulting |
michael@0 | 171 | * pattern is "d-MM-yyyy, G". |
michael@0 | 172 | * <p> |
michael@0 | 173 | * There are actually three available variables: {0} is the pattern so far, |
michael@0 | 174 | * {1} is the element we are adding, and {2} is the name of the element. |
michael@0 | 175 | * <p> |
michael@0 | 176 | * This reflects the way that the CLDR data is organized. |
michael@0 | 177 | * |
michael@0 | 178 | * @param field such as UDATPG_ERA_FIELD. |
michael@0 | 179 | * @param value pattern, such as "{0}, {1}" |
michael@0 | 180 | * @stable ICU 3.8 |
michael@0 | 181 | */ |
michael@0 | 182 | void setAppendItemFormat(UDateTimePatternField field, const UnicodeString& value); |
michael@0 | 183 | |
michael@0 | 184 | /** |
michael@0 | 185 | * Getter corresponding to setAppendItemFormat. Values below 0 or at or |
michael@0 | 186 | * above UDATPG_FIELD_COUNT are illegal arguments. |
michael@0 | 187 | * |
michael@0 | 188 | * @param field such as UDATPG_ERA_FIELD. |
michael@0 | 189 | * @return append pattern for field |
michael@0 | 190 | * @stable ICU 3.8 |
michael@0 | 191 | */ |
michael@0 | 192 | const UnicodeString& getAppendItemFormat(UDateTimePatternField field) const; |
michael@0 | 193 | |
michael@0 | 194 | /** |
michael@0 | 195 | * Sets the names of field, eg "era" in English for ERA. These are only |
michael@0 | 196 | * used if the corresponding AppendItemFormat is used, and if it contains a |
michael@0 | 197 | * {2} variable. |
michael@0 | 198 | * <p> |
michael@0 | 199 | * This reflects the way that the CLDR data is organized. |
michael@0 | 200 | * |
michael@0 | 201 | * @param field such as UDATPG_ERA_FIELD. |
michael@0 | 202 | * @param value name of the field |
michael@0 | 203 | * @stable ICU 3.8 |
michael@0 | 204 | */ |
michael@0 | 205 | void setAppendItemName(UDateTimePatternField field, const UnicodeString& value); |
michael@0 | 206 | |
michael@0 | 207 | /** |
michael@0 | 208 | * Getter corresponding to setAppendItemNames. Values below 0 or at or above |
michael@0 | 209 | * UDATPG_FIELD_COUNT are illegal arguments. |
michael@0 | 210 | * |
michael@0 | 211 | * @param field such as UDATPG_ERA_FIELD. |
michael@0 | 212 | * @return name for field |
michael@0 | 213 | * @stable ICU 3.8 |
michael@0 | 214 | */ |
michael@0 | 215 | const UnicodeString& getAppendItemName(UDateTimePatternField field) const; |
michael@0 | 216 | |
michael@0 | 217 | /** |
michael@0 | 218 | * The date time format is a message format pattern used to compose date and |
michael@0 | 219 | * time patterns. The default value is "{0} {1}", where {0} will be replaced |
michael@0 | 220 | * by the date pattern and {1} will be replaced by the time pattern. |
michael@0 | 221 | * <p> |
michael@0 | 222 | * This is used when the input skeleton contains both date and time fields, |
michael@0 | 223 | * but there is not a close match among the added patterns. For example, |
michael@0 | 224 | * suppose that this object was created by adding "dd-MMM" and "hh:mm", and |
michael@0 | 225 | * its datetimeFormat is the default "{0} {1}". Then if the input skeleton |
michael@0 | 226 | * is "MMMdhmm", there is not an exact match, so the input skeleton is |
michael@0 | 227 | * broken up into two components "MMMd" and "hmm". There are close matches |
michael@0 | 228 | * for those two skeletons, so the result is put together with this pattern, |
michael@0 | 229 | * resulting in "d-MMM h:mm". |
michael@0 | 230 | * |
michael@0 | 231 | * @param dateTimeFormat |
michael@0 | 232 | * message format pattern, here {0} will be replaced by the date |
michael@0 | 233 | * pattern and {1} will be replaced by the time pattern. |
michael@0 | 234 | * @stable ICU 3.8 |
michael@0 | 235 | */ |
michael@0 | 236 | void setDateTimeFormat(const UnicodeString& dateTimeFormat); |
michael@0 | 237 | |
michael@0 | 238 | /** |
michael@0 | 239 | * Getter corresponding to setDateTimeFormat. |
michael@0 | 240 | * @return DateTimeFormat. |
michael@0 | 241 | * @stable ICU 3.8 |
michael@0 | 242 | */ |
michael@0 | 243 | const UnicodeString& getDateTimeFormat() const; |
michael@0 | 244 | |
michael@0 | 245 | /** |
michael@0 | 246 | * Return the best pattern matching the input skeleton. It is guaranteed to |
michael@0 | 247 | * have all of the fields in the skeleton. |
michael@0 | 248 | * |
michael@0 | 249 | * @param skeleton |
michael@0 | 250 | * The skeleton is a pattern containing only the variable fields. |
michael@0 | 251 | * For example, "MMMdd" and "mmhh" are skeletons. |
michael@0 | 252 | * @param status Output param set to success/failure code on exit, |
michael@0 | 253 | * which must not indicate a failure before the function call. |
michael@0 | 254 | * @return bestPattern |
michael@0 | 255 | * The best pattern found from the given skeleton. |
michael@0 | 256 | * @stable ICU 3.8 |
michael@0 | 257 | * <p> |
michael@0 | 258 | * <h4>Sample code</h4> |
michael@0 | 259 | * \snippet samples/dtptngsample/dtptngsample.cpp getBestPatternExample1 |
michael@0 | 260 | * \snippet samples/dtptngsample/dtptngsample.cpp getBestPatternExample |
michael@0 | 261 | * <p> |
michael@0 | 262 | */ |
michael@0 | 263 | UnicodeString getBestPattern(const UnicodeString& skeleton, UErrorCode& status); |
michael@0 | 264 | |
michael@0 | 265 | |
michael@0 | 266 | /** |
michael@0 | 267 | * Return the best pattern matching the input skeleton. It is guaranteed to |
michael@0 | 268 | * have all of the fields in the skeleton. |
michael@0 | 269 | * |
michael@0 | 270 | * @param skeleton |
michael@0 | 271 | * The skeleton is a pattern containing only the variable fields. |
michael@0 | 272 | * For example, "MMMdd" and "mmhh" are skeletons. |
michael@0 | 273 | * @param options |
michael@0 | 274 | * Options for forcing the length of specified fields in the |
michael@0 | 275 | * returned pattern to match those in the skeleton (when this |
michael@0 | 276 | * would not happen otherwise). For default behavior, use |
michael@0 | 277 | * UDATPG_MATCH_NO_OPTIONS. |
michael@0 | 278 | * @param status |
michael@0 | 279 | * Output param set to success/failure code on exit, |
michael@0 | 280 | * which must not indicate a failure before the function call. |
michael@0 | 281 | * @return bestPattern |
michael@0 | 282 | * The best pattern found from the given skeleton. |
michael@0 | 283 | * @stable ICU 4.4 |
michael@0 | 284 | */ |
michael@0 | 285 | UnicodeString getBestPattern(const UnicodeString& skeleton, |
michael@0 | 286 | UDateTimePatternMatchOptions options, |
michael@0 | 287 | UErrorCode& status); |
michael@0 | 288 | |
michael@0 | 289 | |
michael@0 | 290 | /** |
michael@0 | 291 | * Adjusts the field types (width and subtype) of a pattern to match what is |
michael@0 | 292 | * in a skeleton. That is, if you supply a pattern like "d-M H:m", and a |
michael@0 | 293 | * skeleton of "MMMMddhhmm", then the input pattern is adjusted to be |
michael@0 | 294 | * "dd-MMMM hh:mm". This is used internally to get the best match for the |
michael@0 | 295 | * input skeleton, but can also be used externally. |
michael@0 | 296 | * |
michael@0 | 297 | * @param pattern Input pattern |
michael@0 | 298 | * @param skeleton |
michael@0 | 299 | * The skeleton is a pattern containing only the variable fields. |
michael@0 | 300 | * For example, "MMMdd" and "mmhh" are skeletons. |
michael@0 | 301 | * @param status Output param set to success/failure code on exit, |
michael@0 | 302 | * which must not indicate a failure before the function call. |
michael@0 | 303 | * @return pattern adjusted to match the skeleton fields widths and subtypes. |
michael@0 | 304 | * @stable ICU 3.8 |
michael@0 | 305 | * <p> |
michael@0 | 306 | * <h4>Sample code</h4> |
michael@0 | 307 | * \snippet samples/dtptngsample/dtptngsample.cpp getBestPatternExample1 |
michael@0 | 308 | * \snippet samples/dtptngsample/dtptngsample.cpp replaceFieldTypesExample |
michael@0 | 309 | * <p> |
michael@0 | 310 | */ |
michael@0 | 311 | UnicodeString replaceFieldTypes(const UnicodeString& pattern, |
michael@0 | 312 | const UnicodeString& skeleton, |
michael@0 | 313 | UErrorCode& status); |
michael@0 | 314 | |
michael@0 | 315 | /** |
michael@0 | 316 | * Adjusts the field types (width and subtype) of a pattern to match what is |
michael@0 | 317 | * in a skeleton. That is, if you supply a pattern like "d-M H:m", and a |
michael@0 | 318 | * skeleton of "MMMMddhhmm", then the input pattern is adjusted to be |
michael@0 | 319 | * "dd-MMMM hh:mm". This is used internally to get the best match for the |
michael@0 | 320 | * input skeleton, but can also be used externally. |
michael@0 | 321 | * |
michael@0 | 322 | * @param pattern Input pattern |
michael@0 | 323 | * @param skeleton |
michael@0 | 324 | * The skeleton is a pattern containing only the variable fields. |
michael@0 | 325 | * For example, "MMMdd" and "mmhh" are skeletons. |
michael@0 | 326 | * @param options |
michael@0 | 327 | * Options controlling whether the length of specified fields in the |
michael@0 | 328 | * pattern are adjusted to match those in the skeleton (when this |
michael@0 | 329 | * would not happen otherwise). For default behavior, use |
michael@0 | 330 | * UDATPG_MATCH_NO_OPTIONS. |
michael@0 | 331 | * @param status |
michael@0 | 332 | * Output param set to success/failure code on exit, |
michael@0 | 333 | * which must not indicate a failure before the function call. |
michael@0 | 334 | * @return pattern adjusted to match the skeleton fields widths and subtypes. |
michael@0 | 335 | * @stable ICU 4.4 |
michael@0 | 336 | */ |
michael@0 | 337 | UnicodeString replaceFieldTypes(const UnicodeString& pattern, |
michael@0 | 338 | const UnicodeString& skeleton, |
michael@0 | 339 | UDateTimePatternMatchOptions options, |
michael@0 | 340 | UErrorCode& status); |
michael@0 | 341 | |
michael@0 | 342 | /** |
michael@0 | 343 | * Return a list of all the skeletons (in canonical form) from this class. |
michael@0 | 344 | * |
michael@0 | 345 | * Call getPatternForSkeleton() to get the corresponding pattern. |
michael@0 | 346 | * |
michael@0 | 347 | * @param status Output param set to success/failure code on exit, |
michael@0 | 348 | * which must not indicate a failure before the function call. |
michael@0 | 349 | * @return StringEnumeration with the skeletons. |
michael@0 | 350 | * The caller must delete the object. |
michael@0 | 351 | * @stable ICU 3.8 |
michael@0 | 352 | */ |
michael@0 | 353 | StringEnumeration* getSkeletons(UErrorCode& status) const; |
michael@0 | 354 | |
michael@0 | 355 | /** |
michael@0 | 356 | * Get the pattern corresponding to a given skeleton. |
michael@0 | 357 | * @param skeleton |
michael@0 | 358 | * @return pattern corresponding to a given skeleton. |
michael@0 | 359 | * @stable ICU 3.8 |
michael@0 | 360 | */ |
michael@0 | 361 | const UnicodeString& getPatternForSkeleton(const UnicodeString& skeleton) const; |
michael@0 | 362 | |
michael@0 | 363 | /** |
michael@0 | 364 | * Return a list of all the base skeletons (in canonical form) from this class. |
michael@0 | 365 | * |
michael@0 | 366 | * @param status Output param set to success/failure code on exit, |
michael@0 | 367 | * which must not indicate a failure before the function call. |
michael@0 | 368 | * @return a StringEnumeration with the base skeletons. |
michael@0 | 369 | * The caller must delete the object. |
michael@0 | 370 | * @stable ICU 3.8 |
michael@0 | 371 | */ |
michael@0 | 372 | StringEnumeration* getBaseSkeletons(UErrorCode& status) const; |
michael@0 | 373 | |
michael@0 | 374 | #ifndef U_HIDE_INTERNAL_API |
michael@0 | 375 | /** |
michael@0 | 376 | * Return a list of redundant patterns are those which if removed, make no |
michael@0 | 377 | * difference in the resulting getBestPattern values. This method returns a |
michael@0 | 378 | * list of them, to help check the consistency of the patterns used to build |
michael@0 | 379 | * this generator. |
michael@0 | 380 | * |
michael@0 | 381 | * @param status Output param set to success/failure code on exit, |
michael@0 | 382 | * which must not indicate a failure before the function call. |
michael@0 | 383 | * @return a StringEnumeration with the redundant pattern. |
michael@0 | 384 | * The caller must delete the object. |
michael@0 | 385 | * @internal ICU 3.8 |
michael@0 | 386 | */ |
michael@0 | 387 | StringEnumeration* getRedundants(UErrorCode& status); |
michael@0 | 388 | #endif /* U_HIDE_INTERNAL_API */ |
michael@0 | 389 | |
michael@0 | 390 | /** |
michael@0 | 391 | * The decimal value is used in formatting fractions of seconds. If the |
michael@0 | 392 | * skeleton contains fractional seconds, then this is used with the |
michael@0 | 393 | * fractional seconds. For example, suppose that the input pattern is |
michael@0 | 394 | * "hhmmssSSSS", and the best matching pattern internally is "H:mm:ss", and |
michael@0 | 395 | * the decimal string is ",". Then the resulting pattern is modified to be |
michael@0 | 396 | * "H:mm:ss,SSSS" |
michael@0 | 397 | * |
michael@0 | 398 | * @param decimal |
michael@0 | 399 | * @stable ICU 3.8 |
michael@0 | 400 | */ |
michael@0 | 401 | void setDecimal(const UnicodeString& decimal); |
michael@0 | 402 | |
michael@0 | 403 | /** |
michael@0 | 404 | * Getter corresponding to setDecimal. |
michael@0 | 405 | * @return UnicodeString corresponding to the decimal point |
michael@0 | 406 | * @stable ICU 3.8 |
michael@0 | 407 | */ |
michael@0 | 408 | const UnicodeString& getDecimal() const; |
michael@0 | 409 | |
michael@0 | 410 | /** |
michael@0 | 411 | * ICU "poor man's RTTI", returns a UClassID for the actual class. |
michael@0 | 412 | * |
michael@0 | 413 | * @stable ICU 3.8 |
michael@0 | 414 | */ |
michael@0 | 415 | virtual UClassID getDynamicClassID() const; |
michael@0 | 416 | |
michael@0 | 417 | /** |
michael@0 | 418 | * ICU "poor man's RTTI", returns a UClassID for this class. |
michael@0 | 419 | * |
michael@0 | 420 | * @stable ICU 3.8 |
michael@0 | 421 | */ |
michael@0 | 422 | static UClassID U_EXPORT2 getStaticClassID(void); |
michael@0 | 423 | |
michael@0 | 424 | private: |
michael@0 | 425 | /** |
michael@0 | 426 | * Constructor. |
michael@0 | 427 | * @stable ICU 3.8 |
michael@0 | 428 | */ |
michael@0 | 429 | DateTimePatternGenerator(UErrorCode & status); |
michael@0 | 430 | |
michael@0 | 431 | /** |
michael@0 | 432 | * Constructor. |
michael@0 | 433 | * @stable ICU 3.8 |
michael@0 | 434 | */ |
michael@0 | 435 | DateTimePatternGenerator(const Locale& locale, UErrorCode & status); |
michael@0 | 436 | |
michael@0 | 437 | /** |
michael@0 | 438 | * Copy constructor. |
michael@0 | 439 | * @param other DateTimePatternGenerator to copy |
michael@0 | 440 | * @stable ICU 3.8 |
michael@0 | 441 | */ |
michael@0 | 442 | DateTimePatternGenerator(const DateTimePatternGenerator& other); |
michael@0 | 443 | |
michael@0 | 444 | /** |
michael@0 | 445 | * Default assignment operator. |
michael@0 | 446 | * @param other DateTimePatternGenerator to copy |
michael@0 | 447 | * @stable ICU 3.8 |
michael@0 | 448 | */ |
michael@0 | 449 | DateTimePatternGenerator& operator=(const DateTimePatternGenerator& other); |
michael@0 | 450 | |
michael@0 | 451 | Locale pLocale; // pattern locale |
michael@0 | 452 | FormatParser *fp; |
michael@0 | 453 | DateTimeMatcher* dtMatcher; |
michael@0 | 454 | DistanceInfo *distanceInfo; |
michael@0 | 455 | PatternMap *patternMap; |
michael@0 | 456 | UnicodeString appendItemFormats[UDATPG_FIELD_COUNT]; |
michael@0 | 457 | UnicodeString appendItemNames[UDATPG_FIELD_COUNT]; |
michael@0 | 458 | UnicodeString dateTimeFormat; |
michael@0 | 459 | UnicodeString decimal; |
michael@0 | 460 | DateTimeMatcher *skipMatcher; |
michael@0 | 461 | Hashtable *fAvailableFormatKeyHash; |
michael@0 | 462 | UnicodeString hackPattern; |
michael@0 | 463 | UnicodeString emptyString; |
michael@0 | 464 | UChar fDefaultHourFormatChar; |
michael@0 | 465 | |
michael@0 | 466 | /* internal flags masks for adjustFieldTypes etc. */ |
michael@0 | 467 | enum { |
michael@0 | 468 | kDTPGNoFlags = 0, |
michael@0 | 469 | kDTPGFixFractionalSeconds = 1, |
michael@0 | 470 | kDTPGSkeletonUsesCapJ = 2 |
michael@0 | 471 | }; |
michael@0 | 472 | |
michael@0 | 473 | void initData(const Locale &locale, UErrorCode &status); |
michael@0 | 474 | void addCanonicalItems(); |
michael@0 | 475 | void addICUPatterns(const Locale& locale, UErrorCode& status); |
michael@0 | 476 | void hackTimes(const UnicodeString& hackPattern, UErrorCode& status); |
michael@0 | 477 | void addCLDRData(const Locale& locale, UErrorCode& status); |
michael@0 | 478 | UDateTimePatternConflict addPatternWithSkeleton(const UnicodeString& pattern, const UnicodeString * skeletonToUse, UBool override, UnicodeString& conflictingPattern, UErrorCode& status); |
michael@0 | 479 | void initHashtable(UErrorCode& status); |
michael@0 | 480 | void setDateTimeFromCalendar(const Locale& locale, UErrorCode& status); |
michael@0 | 481 | void setDecimalSymbols(const Locale& locale, UErrorCode& status); |
michael@0 | 482 | UDateTimePatternField getAppendFormatNumber(const char* field) const; |
michael@0 | 483 | UDateTimePatternField getAppendNameNumber(const char* field) const; |
michael@0 | 484 | void getAppendName(UDateTimePatternField field, UnicodeString& value); |
michael@0 | 485 | int32_t getCanonicalIndex(const UnicodeString& field); |
michael@0 | 486 | const UnicodeString* getBestRaw(DateTimeMatcher& source, int32_t includeMask, DistanceInfo* missingFields, const PtnSkeleton** specifiedSkeletonPtr = 0); |
michael@0 | 487 | UnicodeString adjustFieldTypes(const UnicodeString& pattern, const PtnSkeleton* specifiedSkeleton, int32_t flags, UDateTimePatternMatchOptions options = UDATPG_MATCH_NO_OPTIONS); |
michael@0 | 488 | UnicodeString getBestAppending(int32_t missingFields, int32_t flags, UDateTimePatternMatchOptions options = UDATPG_MATCH_NO_OPTIONS); |
michael@0 | 489 | int32_t getTopBitNumber(int32_t foundMask); |
michael@0 | 490 | void setAvailableFormat(const UnicodeString &key, UErrorCode& status); |
michael@0 | 491 | UBool isAvailableFormatSet(const UnicodeString &key) const; |
michael@0 | 492 | void copyHashtable(Hashtable *other, UErrorCode &status); |
michael@0 | 493 | UBool isCanonicalItem(const UnicodeString& item) const; |
michael@0 | 494 | } ;// end class DateTimePatternGenerator |
michael@0 | 495 | |
michael@0 | 496 | U_NAMESPACE_END |
michael@0 | 497 | |
michael@0 | 498 | #endif |