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

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 class NumberFormat;
00026 
00190 class U_I18N_API MessageFormat : public Format {
00191 public:
00192     enum EFormatNumber { kMaxFormat = 10 };
00201     MessageFormat(const UnicodeString& pattern,
00202                   UErrorCode &status);
00203 
00212     MessageFormat(const UnicodeString& pattern,
00213                   const Locale& newLocale,
00214                         UErrorCode& success);
00215 
00220     MessageFormat(const MessageFormat&);
00221 
00226     const MessageFormat& operator=(const MessageFormat&);
00227 
00232     virtual ~MessageFormat();
00233 
00239     virtual Format* clone(void) const;
00240 
00246     virtual UBool operator==(const Format& other) const;
00247 
00253     virtual void setLocale(const Locale& theLocale);
00254 
00260     virtual const Locale& getLocale(void) const;
00261 
00271     virtual void applyPattern(const UnicodeString& pattern,
00272                               UErrorCode& status);
00273 
00278     virtual UnicodeString& toPattern(UnicodeString& result) const;
00279 
00286     virtual void adoptFormats(Format** formatsToAdopt, int32_t count);
00287 
00293     virtual void setFormats(const Format** newFormats,int32_t cnt);
00294 
00295 
00302     virtual void adoptFormat(int32_t formatNumber, Format* formatToAdopt);
00303 
00309     virtual void setFormat(int32_t variable, const Format& newFormat);
00310 
00311 
00317     virtual const Format** getFormats(int32_t& count) const;
00318 
00329     UnicodeString& format(  const Formattable* source,
00330                             int32_t count,
00331                             UnicodeString& result,
00332                             FieldPosition& ignore,
00333                             UErrorCode& success) const;
00334 
00340     static UnicodeString& format(   const UnicodeString& pattern,
00341                                     const Formattable* arguments,
00342                                     int32_t count,
00343                                     UnicodeString& result,
00344                                     UErrorCode& success);
00345 
00361     virtual UnicodeString& format(const Formattable& obj,
00362                                   UnicodeString& toAppendTo,
00363                                   FieldPosition& pos,
00364                                   UErrorCode& status) const;
00365 
00370     UnicodeString& format(const Formattable& obj,
00371                           UnicodeString& result,
00372                           UErrorCode& status) const;
00373 
00405     virtual Formattable* parse( const UnicodeString& source,
00406                                 ParsePosition& status,
00407                                 int32_t& count) const;
00408 
00420     virtual Formattable* parse( const UnicodeString& source,
00421                                 int32_t& count,
00422                                 UErrorCode& status) const;
00423 
00453     virtual void parseObject(const UnicodeString& source,
00454                              Formattable& result,
00455                              ParsePosition& parse_pos) const;
00456 
00457 public:
00469     virtual UClassID getDynamicClassID(void) const;
00470 
00482     static UClassID getStaticClassID(void) { return (UClassID)&fgClassID; }
00483 
00484 private:
00485     static char fgClassID;
00486     static NumberFormat* fgNumberFormat;
00487 
00488     // fgNumberFormat is held in a cache of one.
00489 
00490     static NumberFormat* getNumberFormat(UErrorCode &status); // call this function to 'check out' a numberformat from the cache.
00491     static void          releaseNumberFormat(NumberFormat *adopt); // call this function to 'return' the number format to the cache.
00492 
00493     Locale                 fLocale;
00494     UnicodeString         fPattern;
00495     // later, allow more than ten items
00496     Format                 *fFormats[kMaxFormat];
00497     int32_t             *fOffsets;
00498     int32_t             fCount;
00499     int32_t             *fArgumentNumbers;
00500     int32_t             fMaxOffset;
00501 
00508     static const int32_t         fgListLength;
00509     static const UnicodeString     fgTypeList[];
00510     static const UnicodeString     fgModifierList[];
00511     static const UnicodeString     fgDateModifierList[];
00512 
00519     static int32_t findKeyword( const UnicodeString& s,
00520                             const UnicodeString* list);
00521 
00533     UnicodeString&  format( const Formattable* arguments,
00534                             int32_t cnt,
00535                             UnicodeString& result,
00536                             FieldPosition& status,
00537                             int32_t recursionProtection,
00538                             UErrorCode& success) const;
00539 
00548     void            makeFormat( /*int32_t position, */
00549                                 int32_t offsetNumber,
00550                                 UnicodeString* segments,
00551                                 UErrorCode& success);
00552 
00556     NumberFormat* createIntegerFormat(const Locale& locale, UErrorCode& status) const;
00557 
00566     static void copyAndFixQuotes(const UnicodeString& source, int32_t start, int32_t end, UnicodeString& target);
00567 
00576     static int32_t stoi(const UnicodeString& string, UErrorCode& status);
00577 
00586     static UnicodeString& itos(int32_t i, UnicodeString& string);
00587 };
00588 
00589 inline UClassID
00590 MessageFormat::getDynamicClassID() const
00591 {
00592     return MessageFormat::getStaticClassID();
00593 }
00594 
00595 inline UnicodeString&
00596 MessageFormat::format(const Formattable& obj,
00597                       UnicodeString& result,
00598                       UErrorCode& status) const {
00599     return Format::format(obj, result, status);
00600 }
00601 
00602 #endif // _MSGFMT
00603 //eof

Generated at Tue Jun 12 14:03:57 2001 for ICU 1.8.1 by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000