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 *   08/19/2002  srl         Removing Javaisms
00014 ********************************************************************************
00015 */
00016 // *****************************************************************************
00017 // This file was generated from the java source file MessageFormat.java
00018 // *****************************************************************************
00019 
00020 #ifndef MSGFMT_H
00021 #define MSGFMT_H
00022 
00023 #include "unicode/utypes.h"
00024 
00025 #if !UCONFIG_NO_FORMATTING
00026 
00027 #include "unicode/format.h"
00028 #include "unicode/locid.h"
00029 #include "unicode/parseerr.h"
00030 
00031 U_NAMESPACE_BEGIN
00032 
00033 class NumberFormat;
00034 
00198 class U_I18N_API MessageFormat : public Format {
00199 public:
00200     enum EFormatNumber { kMaxFormat = 10 };
00209     MessageFormat(const UnicodeString& pattern,
00210                   UErrorCode &status);
00211 
00220     MessageFormat(const UnicodeString& pattern,
00221                   const Locale& newLocale,
00222                         UErrorCode& success);
00233     MessageFormat(const UnicodeString& pattern,
00234                   const Locale& newLocale,
00235                   UParseError& parseError,
00236                   UErrorCode& success);
00241     MessageFormat(const MessageFormat&);
00242 
00247     const MessageFormat& operator=(const MessageFormat&);
00248 
00253     virtual ~MessageFormat();
00254 
00260     virtual Format* clone(void) const;
00261 
00269     virtual UBool operator==(const Format& other) const;
00270 
00277     virtual void setLocale(const Locale& theLocale);
00278 
00285     virtual const Locale& getLocale(void) const;
00286 
00296     virtual void applyPattern(const UnicodeString& pattern,
00297                               UErrorCode& status);
00308     virtual void applyPattern(const UnicodeString& pattern,
00309                              UParseError& parseError,
00310                              UErrorCode& status);
00311 
00319     virtual UnicodeString& toPattern(UnicodeString& appendTo) const;
00320 
00333     virtual void adoptFormats(Format** formatsToAdopt, int32_t count);
00334 
00346     virtual void setFormats(const Format** newFormats,int32_t cnt);
00347 
00348 
00359     virtual void adoptFormat(int32_t formatNumber, Format* formatToAdopt);
00360 
00370     virtual void setFormat(int32_t variable, const Format& newFormat);
00371 
00378     virtual const Format** getFormats(int32_t& count) const;
00379 
00394     UnicodeString& format(  const Formattable* source,
00395                             int32_t count,
00396                             UnicodeString& appendTo,
00397                             FieldPosition& ignore,
00398                             UErrorCode& success) const;
00399 
00412     static UnicodeString& format(   const UnicodeString& pattern,
00413                                     const Formattable* arguments,
00414                                     int32_t count,
00415                                     UnicodeString& appendTo,
00416                                     UErrorCode& success);
00417 
00433     virtual UnicodeString& format(const Formattable& obj,
00434                                   UnicodeString& appendTo,
00435                                   FieldPosition& pos,
00436                                   UErrorCode& status) const;
00437 
00447     UnicodeString& format(const Formattable& obj,
00448                           UnicodeString& appendTo,
00449                           UErrorCode& status) const;
00450 
00479     virtual Formattable* parse( const UnicodeString& source,
00480                                 ParsePosition& status,
00481                                 int32_t& count) const;
00482 
00492     virtual Formattable* parse( const UnicodeString& source,
00493                                 int32_t& count,
00494                                 UErrorCode& status) const;
00495 
00525     virtual void parseObject(const UnicodeString& source,
00526                              Formattable& result,
00527                              ParsePosition& parse_pos) const;
00528 
00529 public:
00541     virtual UClassID getDynamicClassID(void) const;
00542 
00554     static UClassID getStaticClassID(void) { return (UClassID)&fgClassID; }
00555     
00563     const Formattable::Type* getFormatTypeList(int32_t& listCount){
00564         listCount=fListCount;
00565         return fFormatTypeList; 
00566     }
00567 
00568 private:
00569     static const char fgClassID;
00570     //static NumberFormat* fgNumberFormat;
00571 
00572     /* stores types of formattable objects in the pattern
00573      * is for umsg_* CAPI 
00574      */
00575     Formattable::Type fFormatTypeList[kMaxFormat];
00576     int32_t fListCount;
00577 
00578     // fgNumberFormat is held in a cache of one.
00583     static NumberFormat* getNumberFormat(UErrorCode &status); // call this function to 'check out' a numberformat from the cache.
00584     static void          releaseNumberFormat(NumberFormat *adopt); // call this function to 'return' the number format to the cache.
00585 
00586     Locale                 fLocale;
00587     UnicodeString         fPattern;
00588     // later, allow more than ten items
00589     Format                 *fFormats[kMaxFormat];
00590     int32_t             *fOffsets;
00591     int32_t             fCount;
00592     int32_t             *fArgumentNumbers;
00593     int32_t             fMaxOffset;
00594 
00601     static int32_t findKeyword( const UnicodeString& s,
00602                             const UChar * const *list);
00603 
00620     UnicodeString&  format( const Formattable* arguments,
00621                             int32_t cnt,
00622                             UnicodeString& appendTo,
00623                             FieldPosition& status,
00624                             int32_t recursionProtection,
00625                             UErrorCode& success) const;
00626 
00635     int32_t          makeFormat( /*int32_t position, */
00636                                 int32_t offsetNumber,
00637                                 UnicodeString* segments,
00638                                 UParseError& parseError,
00639                                 UErrorCode& success);
00640 
00644     NumberFormat* createIntegerFormat(const Locale& locale, UErrorCode& status) const;
00645 
00655     static void copyAndFixQuotes(const UnicodeString& appendTo, int32_t start, int32_t end, UnicodeString& target);
00656 
00664     static int32_t stoi(const UnicodeString& string);
00665 
00675     static UnicodeString& itos(int32_t i, UnicodeString& appendTo);
00676 };
00677 
00678 inline UClassID
00679 MessageFormat::getDynamicClassID() const
00680 {
00681     return MessageFormat::getStaticClassID();
00682 }
00683 
00684 inline UnicodeString&
00685 MessageFormat::format(const Formattable& obj,
00686                       UnicodeString& appendTo,
00687                       UErrorCode& status) const {
00688     return Format::format(obj, appendTo, status);
00689 }
00690 U_NAMESPACE_END
00691 
00692 #endif /* #if !UCONFIG_NO_FORMATTING */
00693 
00694 #endif // _MSGFMT
00695 //eof

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