Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef SELFMT
00017 #define SELFMT
00018
00019 #include "unicode/utypes.h"
00020 #include "unicode/numfmt.h"
00021
00027 #if !UCONFIG_NO_FORMATTING
00028
00029 U_NAMESPACE_BEGIN
00030
00031 class Hashtable;
00032
00184 class U_I18N_API SelectFormat : public Format {
00185 public:
00186
00195 SelectFormat(const UnicodeString& pattern, UErrorCode& status);
00196
00201 SelectFormat(const SelectFormat& other);
00202
00207 virtual ~SelectFormat();
00208
00220 void applyPattern(const UnicodeString& pattern, UErrorCode& status);
00221
00222
00223 using Format::format;
00224
00238 UnicodeString& format(const UnicodeString& keyword,
00239 UnicodeString& appendTo,
00240 FieldPosition& pos,
00241 UErrorCode& status) const;
00242
00249 SelectFormat& operator=(const SelectFormat& other);
00250
00258 virtual UBool operator==(const Format& other) const;
00259
00267 virtual UBool operator!=(const Format& other) const;
00268
00274 virtual Format* clone(void) const;
00275
00291 UnicodeString& format(const Formattable& obj,
00292 UnicodeString& appendTo,
00293 FieldPosition& pos,
00294 UErrorCode& status) const;
00295
00304 UnicodeString& toPattern(UnicodeString& appendTo);
00305
00328 virtual void parseObject(const UnicodeString& source,
00329 Formattable& result,
00330 ParsePosition& parse_pos) const;
00331
00336 static UClassID U_EXPORT2 getStaticClassID(void);
00337
00342 virtual UClassID getDynamicClassID() const;
00343
00344 private:
00345 typedef enum classesForSelectFormat{
00346 tStartKeyword,
00347 tContinueKeyword,
00348 tLeftBrace,
00349 tRightBrace,
00350 tSpace,
00351 tOther
00352 }CharacterClass;
00353
00354 UnicodeString pattern;
00355
00356 Hashtable *parsedValuesHash;
00357
00358 SelectFormat();
00359 void initHashTable(UErrorCode &status);
00360 void cleanHashTable();
00361
00362
00363 CharacterClass classifyCharacter(UChar ch) const;
00364
00365 UBool checkSufficientDefinition();
00366
00367 UBool checkValidKeyword(const UnicodeString& argKeyword) const;
00368 void parsingFailure();
00369 void copyHashtable(Hashtable *other, UErrorCode& status);
00370 };
00371
00372 U_NAMESPACE_END
00373
00374 #endif
00375
00376 #endif // _SELFMT
00377