|
ICU 73.2
73.2
|
00001 // © 2016 and later: Unicode, Inc. and others. 00002 // License & terms of use: http://www.unicode.org/copyright.html 00003 /* 00004 ******************************************************************************** 00005 * Copyright (C) 1997-2013, International Business Machines 00006 * Corporation and others. All Rights Reserved. 00007 ******************************************************************************** 00008 * 00009 * File CHOICFMT.H 00010 * 00011 * Modification History: 00012 * 00013 * Date Name Description 00014 * 02/19/97 aliu Converted from java. 00015 * 03/20/97 helena Finished first cut of implementation and got rid 00016 * of nextDouble/previousDouble and replaced with 00017 * boolean array. 00018 * 4/10/97 aliu Clean up. Modified to work on AIX. 00019 * 8/6/97 nos Removed overloaded constructor, member var 'buffer'. 00020 * 07/22/98 stephen Removed operator!= (implemented in Format) 00021 ******************************************************************************** 00022 */ 00023 00024 #ifndef CHOICFMT_H 00025 #define CHOICFMT_H 00026 00027 #include "unicode/utypes.h" 00028 00029 #if U_SHOW_CPLUSPLUS_API 00030 00036 #if !UCONFIG_NO_FORMATTING 00037 00038 #include "unicode/fieldpos.h" 00039 #include "unicode/format.h" 00040 #include "unicode/messagepattern.h" 00041 #include "unicode/numfmt.h" 00042 #include "unicode/unistr.h" 00043 00044 #ifndef U_HIDE_DEPRECATED_API 00045 00046 U_NAMESPACE_BEGIN 00047 00048 class MessageFormat; 00049 00176 class U_I18N_API ChoiceFormat: public NumberFormat { 00177 public: 00186 ChoiceFormat(const UnicodeString& pattern, 00187 UErrorCode& status); 00188 00189 00202 ChoiceFormat(const double* limits, 00203 const UnicodeString* formats, 00204 int32_t count ); 00205 00220 ChoiceFormat(const double* limits, 00221 const UBool* closures, 00222 const UnicodeString* formats, 00223 int32_t count); 00224 00231 ChoiceFormat(const ChoiceFormat& that); 00232 00239 const ChoiceFormat& operator=(const ChoiceFormat& that); 00240 00245 virtual ~ChoiceFormat(); 00246 00254 virtual ChoiceFormat* clone() const override; 00255 00264 virtual bool operator==(const Format& other) const override; 00265 00274 virtual void applyPattern(const UnicodeString& pattern, 00275 UErrorCode& status); 00276 00287 virtual void applyPattern(const UnicodeString& pattern, 00288 UParseError& parseError, 00289 UErrorCode& status); 00298 virtual UnicodeString& toPattern(UnicodeString &pattern) const; 00299 00313 virtual void setChoices(const double* limitsToCopy, 00314 const UnicodeString* formatsToCopy, 00315 int32_t count ); 00316 00327 virtual void setChoices(const double* limits, 00328 const UBool* closures, 00329 const UnicodeString* formats, 00330 int32_t count); 00331 00340 virtual const double* getLimits(int32_t& count) const; 00341 00350 virtual const UBool* getClosures(int32_t& count) const; 00351 00360 virtual const UnicodeString* getFormats(int32_t& count) const; 00361 00362 00363 using NumberFormat::format; 00364 00376 virtual UnicodeString& format(double number, 00377 UnicodeString& appendTo, 00378 FieldPosition& pos) const override; 00390 virtual UnicodeString& format(int32_t number, 00391 UnicodeString& appendTo, 00392 FieldPosition& pos) const override; 00393 00405 virtual UnicodeString& format(int64_t number, 00406 UnicodeString& appendTo, 00407 FieldPosition& pos) const override; 00408 00423 virtual UnicodeString& format(const Formattable* objs, 00424 int32_t cnt, 00425 UnicodeString& appendTo, 00426 FieldPosition& pos, 00427 UErrorCode& success) const; 00428 00429 using NumberFormat::parse; 00430 00445 virtual void parse(const UnicodeString& text, 00446 Formattable& result, 00447 ParsePosition& parsePosition) const override; 00448 00457 virtual UClassID getDynamicClassID(void) const override; 00458 00470 static UClassID U_EXPORT2 getStaticClassID(void); 00471 00472 private: 00479 static UnicodeString& dtos(double value, UnicodeString& string); 00480 00481 ChoiceFormat() = delete; // default constructor not implemented 00482 00493 ChoiceFormat(const UnicodeString& newPattern, 00494 UParseError& parseError, 00495 UErrorCode& status); 00496 00497 friend class MessageFormat; 00498 00499 virtual void setChoices(const double* limits, 00500 const UBool* closures, 00501 const UnicodeString* formats, 00502 int32_t count, 00503 UErrorCode &errorCode); 00504 00512 static int32_t findSubMessage(const MessagePattern &pattern, int32_t partIndex, double number); 00513 00514 static double parseArgument( 00515 const MessagePattern &pattern, int32_t partIndex, 00516 const UnicodeString &source, ParsePosition &pos); 00517 00526 static int32_t matchStringUntilLimitPart( 00527 const MessagePattern &pattern, int32_t partIndex, int32_t limitPartIndex, 00528 const UnicodeString &source, int32_t sourceOffset); 00529 00536 UErrorCode constructorErrorCode; 00537 00545 MessagePattern msgPattern; 00546 00586 // double* fChoiceLimits; 00587 // UBool* fClosures; 00588 // UnicodeString* fChoiceFormats; 00589 // int32_t fCount; 00590 }; 00591 00592 00593 U_NAMESPACE_END 00594 00595 #endif // U_HIDE_DEPRECATED_API 00596 #endif /* #if !UCONFIG_NO_FORMATTING */ 00597 00598 #endif /* U_SHOW_CPLUSPLUS_API */ 00599 00600 #endif // CHOICFMT_H 00601 //eof
1.7.6.1