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

- Search for |

- File List
- Globals

# plurfmt.h

Go to the documentation of this file.

    00001 /*
    00002 *******************************************************************************
    00003 * Copyright (C) 2007-2009, 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
    00322     UnicodeString format(int32_t number, UErrorCode& status) const;
    00323
    00336     UnicodeString format(double number, UErrorCode& status) const;
    00337
    00354     UnicodeString& format(int32_t number,
    00355                           UnicodeString& appendTo,
    00356                           FieldPosition& pos,
    00357                           UErrorCode& status) const;
    00358
    00375     UnicodeString& format(double number,
    00376                           UnicodeString& appendTo,
    00377                           FieldPosition& pos,
    00378                           UErrorCode& status) const;
    00379
    00392     void setLocale(const Locale& locale, UErrorCode& status);
    00393
    00403     void setNumberFormat(const NumberFormat* format, UErrorCode& status);
    00404
    00411     PluralFormat& operator=(const PluralFormat& other);
    00412
    00420     virtual UBool operator==(const Format& other) const;
    00421
    00429     virtual UBool operator!=(const Format& other) const;
    00430
    00436     virtual Format* clone(void) const;
    00437
    00450    UnicodeString& format(const Formattable& obj,
    00451                          UnicodeString& appendTo,
    00452                          FieldPosition& pos,
    00453                          UErrorCode& status) const;
    00454
    00463    UnicodeString& toPattern(UnicodeString& appendTo);
    00464
    00487    virtual void parseObject(const UnicodeString& source,
    00488                             Formattable& result,
    00489                             ParsePosition& parse_pos) const;
    00490
    00497     static UClassID U_EXPORT2 getStaticClassID(void);
    00498
    00504      virtual UClassID getDynamicClassID() const;
    00505
    00506 private:
    00507     typedef enum fmtToken {
    00508         none,
    00509         tLetter,
    00510         tNumber,
    00511         tSpace,
    00512         tNumberSign,
    00513         tLeftBrace,
    00514         tRightBrace
    00515     }fmtToken;
    00516
    00517     Locale  locale;
    00518     PluralRules* pluralRules;
    00519     UnicodeString pattern;
    00520     Hashtable  *fParsedValuesHash;
    00521     NumberFormat*  numberFormat;
    00522     NumberFormat*  replacedNumberFormat;
    00523
    00524     PluralFormat();   // default constructor not implemented
    00525     void init(const PluralRules* rules, const Locale& curlocale, UErrorCode& status);
    00526     UBool inRange(UChar ch, fmtToken& type);
    00527     UBool checkSufficientDefinition();
    00528     void parsingFailure();
    00529     UnicodeString insertFormattedNumber(double number,
    00530                                         UnicodeString& message,
    00531                                         UnicodeString& appendTo,
    00532                                         FieldPosition& pos) const;
    00533     void copyHashtable(Hashtable *other, UErrorCode& status);
    00534 };
    00535
    00536 U_NAMESPACE_END
    00537
    00538 #endif /* #if !UCONFIG_NO_FORMATTING */
    00539
    00540 #endif // _PLURFMT
    00541 //eof