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

msgfmt.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 MSGFMT.H
00006 *
00007 * Modification History:
00008 *
00009 *   Date        Name        Description
00010 *   02/19/97    aliu        Converted from java.
00011 *   03/20/97    helena      Finished first cut of implementation.
00012 *   07/22/98    stephen     Removed operator!= (defined in Format)
00013 ********************************************************************************
00014 */
00015 // *****************************************************************************
00016 // This file was generated from the java source file MessageFormat.java
00017 // *****************************************************************************
00018 
00019 #ifndef MSGFMT_H
00020 #define MSGFMT_H
00021 
00022 #include "unicode/utypes.h"
00023 #include "unicode/format.h"
00024 #include "unicode/locid.h"
00025 #include "unicode/parseerr.h"
00026 
00027 U_NAMESPACE_BEGIN
00028 
00029 class NumberFormat;
00030 
00194 class U_I18N_API MessageFormat : public Format {
00195 public:
00196     enum EFormatNumber { kMaxFormat = 10 };
00205     MessageFormat(const UnicodeString& pattern,
00206                   UErrorCode &status);
00207 
00216     MessageFormat(const UnicodeString& pattern,
00217                   const Locale& newLocale,
00218                         UErrorCode& success);
00229     MessageFormat(const UnicodeString& pattern,
00230                   const Locale& newLocale,
00231                   UParseError& parseError,
00232                   UErrorCode& success);
00237     MessageFormat(const MessageFormat&);
00238 
00243     const MessageFormat& operator=(const MessageFormat&);
00244 
00249     virtual ~MessageFormat();
00250 
00256     virtual Format* clone(void) const;
00257 
00265     virtual UBool operator==(const Format& other) const;
00266 
00273     virtual void setLocale(const Locale& theLocale);
00274 
00281     virtual const Locale& getLocale(void) const;
00282 
00292     virtual void applyPattern(const UnicodeString& pattern,
00293                               UErrorCode& status);
00304     virtual void applyPattern(const UnicodeString& pattern,
00305                              UParseError& parseError,
00306                              UErrorCode& status);
00307 
00314     virtual UnicodeString& toPattern(UnicodeString& result) const;
00315 
00328     virtual void adoptFormats(Format** formatsToAdopt, int32_t count);
00329 
00341     virtual void setFormats(const Format** newFormats,int32_t cnt);
00342 
00343 
00354     virtual void adoptFormat(int32_t formatNumber, Format* formatToAdopt);
00355 
00365     virtual void setFormat(int32_t variable, const Format& newFormat);
00366 
00373     virtual const Format** getFormats(int32_t& count) const;
00374 
00387     UnicodeString& format(  const Formattable* source,
00388                             int32_t count,
00389                             UnicodeString& result,
00390                             FieldPosition& ignore,
00391                             UErrorCode& success) const;
00392 
00403     static UnicodeString& format(   const UnicodeString& pattern,
00404                                     const Formattable* arguments,
00405                                     int32_t count,
00406                                     UnicodeString& result,
00407                                     UErrorCode& success);
00408 
00424     virtual UnicodeString& format(const Formattable& obj,
00425                                   UnicodeString& toAppendTo,
00426                                   FieldPosition& pos,
00427                                   UErrorCode& status) const;
00428 
00437     UnicodeString& format(const Formattable& obj,
00438                           UnicodeString& result,
00439                           UErrorCode& status) const;
00440 
00469     virtual Formattable* parse( const UnicodeString& source,
00470                                 ParsePosition& status,
00471                                 int32_t& count) const;
00472 
00482     virtual Formattable* parse( const UnicodeString& source,
00483                                 int32_t& count,
00484                                 UErrorCode& status) const;
00485 
00515     virtual void parseObject(const UnicodeString& source,
00516                              Formattable& result,
00517                              ParsePosition& parse_pos) const;
00518 
00519 public:
00531     virtual UClassID getDynamicClassID(void) const;
00532 
00544     static UClassID getStaticClassID(void) { return (UClassID)&fgClassID; }
00545     
00553     const Formattable::Type* getFormatTypeList(int32_t& listCount){
00554         listCount=fListCount;
00555         return fFormatTypeList; 
00556     }
00557 
00558 private:
00559     static const char fgClassID;
00560     //static NumberFormat* fgNumberFormat;
00561 
00562     /* stores types of formattable objects in the pattern
00563      * is for umsg_* CAPI 
00564      */
00565     Formattable::Type fFormatTypeList[kMaxFormat];
00566     int32_t fListCount;
00567 
00568     // fgNumberFormat is held in a cache of one.
00573     static NumberFormat* getNumberFormat(UErrorCode &status); // call this function to 'check out' a numberformat from the cache.
00574     static void          releaseNumberFormat(NumberFormat *adopt); // call this function to 'return' the number format to the cache.
00575 
00576     Locale                 fLocale;
00577     UnicodeString         fPattern;
00578     // later, allow more than ten items
00579     Format                 *fFormats[kMaxFormat];
00580     int32_t             *fOffsets;
00581     int32_t             fCount;
00582     int32_t             *fArgumentNumbers;
00583     int32_t             fMaxOffset;
00584 
00591     static int32_t findKeyword( const UnicodeString& s,
00592                             const UChar * const *list);
00593 
00605     UnicodeString&  format( const Formattable* arguments,
00606                             int32_t cnt,
00607                             UnicodeString& result,
00608                             FieldPosition& status,
00609                             int32_t recursionProtection,
00610                             UErrorCode& success) const;
00611 
00620     int32_t          makeFormat( /*int32_t position, */
00621                                 int32_t offsetNumber,
00622                                 UnicodeString* segments,
00623                                 UParseError& parseError,
00624                                 UErrorCode& success);
00625 
00629     NumberFormat* createIntegerFormat(const Locale& locale, UErrorCode& status) const;
00630 
00639     static void copyAndFixQuotes(const UnicodeString& source, int32_t start, int32_t end, UnicodeString& target);
00640 
00648     static int32_t stoi(const UnicodeString& string);
00649 
00658     static UnicodeString& itos(int32_t i, UnicodeString& string);
00659 };
00660 
00661 inline UClassID
00662 MessageFormat::getDynamicClassID() const
00663 {
00664     return MessageFormat::getStaticClassID();
00665 }
00666 
00667 inline UnicodeString&
00668 MessageFormat::format(const Formattable& obj,
00669                       UnicodeString& result,
00670                       UErrorCode& status) const {
00671     return Format::format(obj, result, status);
00672 }
00673 U_NAMESPACE_END
00674 
00675 #endif // _MSGFMT
00676 //eof

Generated on Thu Aug 15 14:13:26 2002 for ICU 2.2 by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001