ICU 73.2  73.2
selfmt.h
Go to the documentation of this file.
00001 // © 2016 and later: Unicode, Inc. and others.
00002 // License & terms of use: http://www.unicode.org/copyright.html
00003 /********************************************************************
00004  * COPYRIGHT:
00005  * Copyright (c) 1997-2011, International Business Machines Corporation and
00006  * others. All Rights Reserved.
00007  * Copyright (C) 2010 , Yahoo! Inc.
00008  ********************************************************************
00009  *
00010  * File SELFMT.H
00011  *
00012  * Modification History:
00013  *
00014  *   Date        Name        Description
00015  *   11/11/09    kirtig      Finished first cut of implementation.
00016  ********************************************************************/
00017 
00018 #ifndef SELFMT
00019 #define SELFMT
00020 
00021 #include "unicode/utypes.h"
00022 
00023 #if U_SHOW_CPLUSPLUS_API
00024 
00025 #include "unicode/messagepattern.h"
00026 #include "unicode/numfmt.h"
00027 
00033 #if !UCONFIG_NO_FORMATTING
00034 
00035 U_NAMESPACE_BEGIN
00036 
00037 class MessageFormat;
00038 
00188 class U_I18N_API SelectFormat : public Format {
00189 public:
00190 
00199     SelectFormat(const UnicodeString& pattern, UErrorCode& status);
00200 
00205     SelectFormat(const SelectFormat& other);
00206 
00211     virtual ~SelectFormat();
00212 
00224     void applyPattern(const UnicodeString& pattern, UErrorCode& status);
00225 
00226 
00227     using Format::format;
00228 
00242     UnicodeString& format(const UnicodeString& keyword,
00243                             UnicodeString& appendTo,
00244                             FieldPosition& pos,
00245                             UErrorCode& status) const;
00246 
00253     SelectFormat& operator=(const SelectFormat& other);
00254 
00262     virtual bool operator==(const Format& other) const override;
00263 
00271     virtual bool operator!=(const Format& other) const;
00272 
00278     virtual SelectFormat* clone() const override;
00279 
00295     UnicodeString& format(const Formattable& obj,
00296                          UnicodeString& appendTo,
00297                          FieldPosition& pos,
00298                          UErrorCode& status) const override;
00299 
00308     UnicodeString& toPattern(UnicodeString& appendTo);
00309 
00332     virtual void parseObject(const UnicodeString& source,
00333                             Formattable& result,
00334                             ParsePosition& parse_pos) const override;
00335 
00340     static UClassID U_EXPORT2 getStaticClassID(void);
00341 
00346     virtual UClassID getDynamicClassID() const override;
00347 
00348 private:
00349     friend class MessageFormat;
00350 
00351     SelectFormat() = delete;   // default constructor not implemented.
00352 
00361     static int32_t findSubMessage(const MessagePattern& pattern, int32_t partIndex,
00362                                   const UnicodeString& keyword, UErrorCode& ec);
00363 
00364     MessagePattern msgPattern;
00365 };
00366 
00367 U_NAMESPACE_END
00368 
00369 #endif /* #if !UCONFIG_NO_FORMATTING */
00370 
00371 #endif /* U_SHOW_CPLUSPLUS_API */
00372 
00373 #endif // _SELFMT
00374 //eof