Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Search  

numfmt.h

Go to the documentation of this file.
00001 /*
00002 * Copyright (C) {1997-2001}, International Business Machines Corporation and others. All Rights Reserved.
00003 ********************************************************************************
00004 *
00005 * File NUMFMT.H
00006 *
00007 * Modification History:
00008 *
00009 *   Date        Name        Description
00010 *   02/19/97    aliu        Converted from java.
00011 *   03/18/97    clhuang     Updated per C++ implementation.
00012 *   04/17/97    aliu        Changed DigitCount to int per code review.
00013 *    07/20/98    stephen        JDK 1.2 sync up. Added scientific support.
00014 *                            Changed naming conventions to match C++ guidelines
00015 *                            Derecated Java style constants (eg, INTEGER_FIELD)
00016 ********************************************************************************
00017 */
00018 
00019 #ifndef NUMFMT_H
00020 #define NUMFMT_H
00021 
00022 
00023 #include "unicode/utypes.h"
00024 
00025 #if !UCONFIG_NO_FORMATTING
00026 
00027 #include "unicode/unistr.h"
00028 #include "unicode/format.h"
00029 
00030 U_NAMESPACE_BEGIN
00031 
00032 class Locale;
00033 
00128 class U_I18N_API NumberFormat : public Format {
00129 public:
00130 
00139     enum EAlignmentFields {
00140         kIntegerField,
00141         kFractionField,
00142 
00143 
00149         INTEGER_FIELD        = kIntegerField,
00150         FRACTION_FIELD        = kFractionField
00151     };
00152 
00157     virtual ~NumberFormat();
00158 
00165     virtual UBool operator==(const Format& other) const;
00166 
00182     virtual UnicodeString& format(const Formattable& obj,
00183                                   UnicodeString& appendTo,
00184                                   FieldPosition& pos,
00185                                   UErrorCode& status) const;
00186 
00215     virtual void parseObject(const UnicodeString& source,
00216                              Formattable& result,
00217                              ParsePosition& parse_pos) const;
00218 
00229     UnicodeString& format(  double number,
00230                             UnicodeString& appendTo) const;
00231 
00242     UnicodeString& format(  int32_t number,
00243                             UnicodeString& appendTo) const;
00244 
00257     virtual UnicodeString& format(double number,
00258                                   UnicodeString& appendTo,
00259                                   FieldPosition& pos) const = 0;
00272     virtual UnicodeString& format(int32_t number,
00273                                   UnicodeString& appendTo,
00274                                   FieldPosition& pos) const = 0;
00275 
00284     UnicodeString& format(const Formattable& obj,
00285                           UnicodeString& appendTo,
00286                           UErrorCode& status) const;
00287 
00309     virtual void parse(const UnicodeString& text,
00310                        Formattable& result,
00311                        ParsePosition& parsePosition) const = 0;
00312 
00327     virtual void parse( const UnicodeString& text,
00328                         Formattable& result,
00329                         UErrorCode& status) const;
00330 
00342     UBool isParseIntegerOnly(void) const;
00343 
00351     virtual void setParseIntegerOnly(UBool value);
00352 
00361     static NumberFormat* createInstance(UErrorCode&);
00362 
00371     static NumberFormat* createInstance(const Locale& inLocale,
00372                                         UErrorCode&);
00373 
00378     static NumberFormat* createCurrencyInstance(UErrorCode&);
00379 
00385     static NumberFormat* createCurrencyInstance(const Locale& inLocale,
00386                                                 UErrorCode&);
00387 
00392     static NumberFormat* createPercentInstance(UErrorCode&);
00393 
00399     static NumberFormat* createPercentInstance(const Locale& inLocale,
00400                                                UErrorCode&);
00401 
00406     static NumberFormat* createScientificInstance(UErrorCode&);
00407 
00413     static NumberFormat* createScientificInstance(const Locale& inLocale,
00414                                                 UErrorCode&);
00415 
00421     static const Locale* getAvailableLocales(int32_t& count);
00422 
00432     UBool isGroupingUsed(void) const;
00433 
00440     virtual void setGroupingUsed(UBool newValue);
00441 
00450     int32_t getMaximumIntegerDigits(void) const;
00451 
00464     virtual void setMaximumIntegerDigits(int32_t newValue);
00465 
00474     int32_t getMinimumIntegerDigits(void) const;
00475 
00486     virtual void setMinimumIntegerDigits(int32_t newValue);
00487 
00496     int32_t getMaximumFractionDigits(void) const;
00497 
00508     virtual void setMaximumFractionDigits(int32_t newValue);
00509 
00518     int32_t getMinimumFractionDigits(void) const;
00519 
00530     virtual void setMinimumFractionDigits(int32_t newValue);
00531 
00532 public:
00533 
00545     static UClassID getStaticClassID(void) { return (UClassID)&fgClassID; }
00546 
00559     virtual UClassID getDynamicClassID(void) const = 0;
00560 
00561 protected:
00562 
00567     NumberFormat();
00568 
00573     NumberFormat(const NumberFormat&);
00574 
00579     NumberFormat& operator=(const NumberFormat&);
00580 
00581 protected:
00582     static const int32_t fgMaxIntegerDigits;
00583     static const int32_t fgMinIntegerDigits;
00584 
00585 private:
00586     static const char fgClassID;
00587 
00588     enum EStyles {
00589         kNumberStyle,
00590         kCurrencyStyle,
00591         kPercentStyle,
00592         kScientificStyle,
00593         kStyleCount // ALWAYS LAST ENUM: number of styles
00594     };
00595     
00603     static NumberFormat* createInstance(const Locale& desiredLocale, EStyles choice, UErrorCode& success);
00604 
00605     static const int32_t    fgNumberPatternsCount;
00606     static const UChar* const fgLastResortNumberPatterns[];
00607 
00608     UBool      fGroupingUsed;
00609     int32_t     fMaxIntegerDigits;
00610     int32_t     fMinIntegerDigits;
00611     int32_t     fMaxFractionDigits;
00612     int32_t     fMinFractionDigits;
00613     UBool      fParseIntegerOnly;
00614 };
00615 
00616 // -------------------------------------
00617 
00618 inline UBool
00619 NumberFormat::isParseIntegerOnly() const
00620 {
00621     return fParseIntegerOnly;
00622 }
00623 
00624 inline UnicodeString&
00625 NumberFormat::format(const Formattable& obj,
00626                      UnicodeString& appendTo,
00627                      UErrorCode& status) const {
00628     return Format::format(obj, appendTo, status);
00629 }
00630 
00631 U_NAMESPACE_END
00632 
00633 #endif /* #if !UCONFIG_NO_FORMATTING */
00634 
00635 #endif // _NUMFMT
00636 //eof

Generated on Wed Dec 18 16:49:40 2002 for ICU 2.4 by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001