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

- File List
- Globals

# plurfmt.h

Go to the documentation of this file.

    00001 /*
    00002 *******************************************************************************
    00003 * Copyright (C) 2007-2010, International Business Machines Corporation and
    00004 * others. All Rights Reserved.
    00005 *******************************************************************************
    00006 *
    00007
    00008 * File PLURFMT.H
    00009 *
    00010 * Modification History:*
    00011 *   Date        Name        Description
    00012 *
    00013 ********************************************************************************
    00014 */
    00015
    00016 #ifndef PLURFMT
    00017 #define PLURFMT
    00018
    00019 #include "unicode/utypes.h"
    00020
    00026 #if !UCONFIG_NO_FORMATTING
    00027
    00028 #include "unicode/numfmt.h"
    00029 #include "unicode/plurrule.h"
    00030
    00031 U_NAMESPACE_BEGIN
    00032
    00033 class Hashtable;
    00034
    00174 class U_I18N_API PluralFormat : public Format {
    00175 public:
    00176
    00185     PluralFormat(UErrorCode& status);
    00186
    00196     PluralFormat(const Locale& locale, UErrorCode& status);
    00197
    00207     PluralFormat(const PluralRules& rules, UErrorCode& status);
    00208
    00220     PluralFormat(const Locale& locale, const PluralRules& rules, UErrorCode& status);
    00221
    00232     PluralFormat(const UnicodeString& pattern, UErrorCode& status);
    00233
    00248     PluralFormat(const Locale& locale, const UnicodeString& pattern, UErrorCode& status);
    00249
    00261     PluralFormat(const PluralRules& rules,
    00262                  const UnicodeString& pattern,
    00263                  UErrorCode& status);
    00264
    00279     PluralFormat(const Locale& locale,
    00280                  const PluralRules& rules,
    00281                  const UnicodeString& pattern,
    00282                  UErrorCode& status);
    00283
    00288     PluralFormat(const PluralFormat& other);
    00289
    00294     virtual ~PluralFormat();
    00295
    00308     void applyPattern(const UnicodeString& pattern, UErrorCode& status);
    00309
    00310
    00311     using Format::format;
    00312
    00325     UnicodeString format(int32_t number, UErrorCode& status) const;
    00326
    00339     UnicodeString format(double number, UErrorCode& status) const;
    00340
    00357     UnicodeString& format(int32_t number,
    00358                           UnicodeString& appendTo,
    00359                           FieldPosition& pos,
    00360                           UErrorCode& status) const;
    00361
    00378     UnicodeString& format(double number,
    00379                           UnicodeString& appendTo,
    00380                           FieldPosition& pos,
    00381                           UErrorCode& status) const;
    00382
    00395     void setLocale(const Locale& locale, UErrorCode& status);
    00396
    00406     void setNumberFormat(const NumberFormat* format, UErrorCode& status);
    00407
    00414     PluralFormat& operator=(const PluralFormat& other);
    00415
    00423     virtual UBool operator==(const Format& other) const;
    00424
    00432     virtual UBool operator!=(const Format& other) const;
    00433
    00439     virtual Format* clone(void) const;
    00440
    00453    UnicodeString& format(const Formattable& obj,
    00454                          UnicodeString& appendTo,
    00455                          FieldPosition& pos,
    00456                          UErrorCode& status) const;
    00457
    00466    UnicodeString& toPattern(UnicodeString& appendTo);
    00467
    00490    virtual void parseObject(const UnicodeString& source,
    00491                             Formattable& result,
    00492                             ParsePosition& parse_pos) const;
    00493
    00500     static UClassID U_EXPORT2 getStaticClassID(void);
    00501
    00507      virtual UClassID getDynamicClassID() const;
    00508
    00509 private:
    00510     typedef enum fmtToken {
    00511         none,
    00512         tLetter,
    00513         tNumber,
    00514         tSpace,
    00515         tNumberSign,
    00516         tLeftBrace,
    00517         tRightBrace
    00518     }fmtToken;
    00519
    00520     Locale  locale;
    00521     PluralRules* pluralRules;
    00522     UnicodeString pattern;
    00523     Hashtable  *fParsedValuesHash;
    00524     NumberFormat*  numberFormat;
    00525     NumberFormat*  replacedNumberFormat;
    00526
    00527     PluralFormat();   // default constructor not implemented
    00528     void init(const PluralRules* rules, const Locale& curlocale, UErrorCode& status);
    00529     UBool inRange(UChar ch, fmtToken& type);
    00530     UBool checkSufficientDefinition();
    00531     void parsingFailure();
    00532     UnicodeString insertFormattedNumber(double number,
    00533                                         UnicodeString& message,
    00534                                         UnicodeString& appendTo,
    00535                                         FieldPosition& pos) const;
    00536     void copyHashtable(Hashtable *other, UErrorCode& status);
    00537 };
    00538
    00539 U_NAMESPACE_END
    00540
    00541 #endif /* #if !UCONFIG_NO_FORMATTING */
    00542
    00543 #endif // _PLURFMT
    00544 //eof

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines