Main Page | Class Hierarchy | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

msgfmt.h

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 00263 virtual UBool operator==(const Format& other) const; 00264 00270 virtual void setLocale(const Locale& theLocale); 00271 00277 virtual const Locale& getLocale(void) const; 00278 00288 virtual void applyPattern(const UnicodeString& pattern, 00289 UErrorCode& status); 00300 virtual void applyPattern(const UnicodeString& pattern, 00301 UParseError& parseError, 00302 UErrorCode& status); 00303 00308 virtual UnicodeString& toPattern(UnicodeString& result) const; 00309 00316 virtual void adoptFormats(Format** formatsToAdopt, int32_t count); 00317 00323 virtual void setFormats(const Format** newFormats,int32_t cnt); 00324 00325 00332 virtual void adoptFormat(int32_t formatNumber, Format* formatToAdopt); 00333 00339 virtual void setFormat(int32_t variable, const Format& newFormat); 00340 00341 00347 virtual const Format** getFormats(int32_t& count) const; 00348 00359 UnicodeString& format( const Formattable* source, 00360 int32_t count, 00361 UnicodeString& result, 00362 FieldPosition& ignore, 00363 UErrorCode& success) const; 00364 00370 static UnicodeString& format( const UnicodeString& pattern, 00371 const Formattable* arguments, 00372 int32_t count, 00373 UnicodeString& result, 00374 UErrorCode& success); 00375 00391 virtual UnicodeString& format(const Formattable& obj, 00392 UnicodeString& toAppendTo, 00393 FieldPosition& pos, 00394 UErrorCode& status) const; 00395 00400 UnicodeString& format(const Formattable& obj, 00401 UnicodeString& result, 00402 UErrorCode& status) const; 00403 00435 virtual Formattable* parse( const UnicodeString& source, 00436 ParsePosition& status, 00437 int32_t& count) const; 00438 00450 virtual Formattable* parse( const UnicodeString& source, 00451 int32_t& count, 00452 UErrorCode& status) const; 00453 00483 virtual void parseObject(const UnicodeString& source, 00484 Formattable& result, 00485 ParsePosition& parse_pos) const; 00486 00487 public: 00499 virtual UClassID getDynamicClassID(void) const; 00500 00512 static UClassID getStaticClassID(void) { return (UClassID)&fgClassID; } 00513 00521 const Formattable::Type* getFormatTypeList(int32_t& listCount){ 00522 listCount=fListCount; 00523 return fFormatTypeList; 00524 } 00525 00526 private: 00527 static const char fgClassID; 00528 //static NumberFormat* fgNumberFormat; 00529 00530 /* stores types of formattable objects in the pattern 00531 * is for umsg_* CAPI 00532 */ 00533 Formattable::Type fFormatTypeList[kMaxFormat]; 00534 int32_t fListCount; 00535 00536 // fgNumberFormat is held in a cache of one. 00537 00538 static NumberFormat* getNumberFormat(UErrorCode &status); // call this function to 'check out' a numberformat from the cache. 00539 static void releaseNumberFormat(NumberFormat *adopt); // call this function to 'return' the number format to the cache. 00540 00541 Locale fLocale; 00542 UnicodeString fPattern; 00543 // later, allow more than ten items 00544 Format *fFormats[kMaxFormat]; 00545 int32_t *fOffsets; 00546 int32_t fCount; 00547 int32_t *fArgumentNumbers; 00548 int32_t fMaxOffset; 00549 00556 static int32_t findKeyword( const UnicodeString& s, 00557 const UChar * const *list); 00558 00570 UnicodeString& format( const Formattable* arguments, 00571 int32_t cnt, 00572 UnicodeString& result, 00573 FieldPosition& status, 00574 int32_t recursionProtection, 00575 UErrorCode& success) const; 00576 00586 int32_t makeFormat( /*int32_t position, */ 00587 int32_t offsetNumber, 00588 UnicodeString* segments, 00589 UParseError& parseError, 00590 UErrorCode& success); 00591 00595 NumberFormat* createIntegerFormat(const Locale& locale, UErrorCode& status) const; 00596 00605 static void copyAndFixQuotes(const UnicodeString& source, int32_t start, int32_t end, UnicodeString& target); 00606 00614 static int32_t stoi(const UnicodeString& string); 00615 00624 static UnicodeString& itos(int32_t i, UnicodeString& string); 00625 }; 00626 00627 inline UClassID 00628 MessageFormat::getDynamicClassID() const 00629 { 00630 return MessageFormat::getStaticClassID(); 00631 } 00632 00633 inline UnicodeString& 00634 MessageFormat::format(const Formattable& obj, 00635 UnicodeString& result, 00636 UErrorCode& status) const { 00637 return Format::format(obj, result, status); 00638 } 00639 U_NAMESPACE_END 00640 00641 #endif // _MSGFMT 00642 //eof

Generated on Wed Aug 18 05:18:14 2004 for ICU 2.1 by doxygen 1.3.7