ICU 64.2  64.2
selfmt.h
Go to the documentation of this file.
1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
3 /********************************************************************
4  * COPYRIGHT:
5  * Copyright (c) 1997-2011, International Business Machines Corporation and
6  * others. All Rights Reserved.
7  * Copyright (C) 2010 , Yahoo! Inc.
8  ********************************************************************
9  *
10  * File SELFMT.H
11  *
12  * Modification History:
13  *
14  * Date Name Description
15  * 11/11/09 kirtig Finished first cut of implementation.
16  ********************************************************************/
17 
18 #ifndef SELFMT
19 #define SELFMT
20 
21 #include "unicode/messagepattern.h"
22 #include "unicode/numfmt.h"
23 #include "unicode/utypes.h"
24 
30 #if !UCONFIG_NO_FORMATTING
31 
33 
34 class MessageFormat;
35 
186 public:
187 
196  SelectFormat(const UnicodeString& pattern, UErrorCode& status);
197 
202  SelectFormat(const SelectFormat& other);
203 
208  virtual ~SelectFormat();
209 
221  void applyPattern(const UnicodeString& pattern, UErrorCode& status);
222 
223 
224  using Format::format;
225 
239  UnicodeString& format(const UnicodeString& keyword,
240  UnicodeString& appendTo,
241  FieldPosition& pos,
242  UErrorCode& status) const;
243 
250  SelectFormat& operator=(const SelectFormat& other);
251 
259  virtual UBool operator==(const Format& other) const;
260 
268  virtual UBool operator!=(const Format& other) const;
269 
275  virtual Format* clone(void) const;
276 
292  UnicodeString& format(const Formattable& obj,
293  UnicodeString& appendTo,
294  FieldPosition& pos,
295  UErrorCode& status) const;
296 
305  UnicodeString& toPattern(UnicodeString& appendTo);
306 
329  virtual void parseObject(const UnicodeString& source,
330  Formattable& result,
331  ParsePosition& parse_pos) const;
332 
337  static UClassID U_EXPORT2 getStaticClassID(void);
338 
343  virtual UClassID getDynamicClassID() const;
344 
345 private:
346  friend class MessageFormat;
347 
348  SelectFormat(); // default constructor not implemented.
349 
358  static int32_t findSubMessage(const MessagePattern& pattern, int32_t partIndex,
359  const UnicodeString& keyword, UErrorCode& ec);
360 
361  MessagePattern msgPattern;
362 };
363 
365 
366 #endif /* #if !UCONFIG_NO_FORMATTING */
367 
368 #endif // _SELFMT
369 //eof
Base class for all formats.
Definition: format.h:96
UBool operator!=(const Format &other) const
Return true if the given Format objects are not semantically equal.
Definition: format.h:121
UnicodeString & format(const Formattable &obj, UnicodeString &appendTo, UErrorCode &status) const
Formats an object to produce a string.
void * UClassID
UClassID is used to identify classes without using the compiler's RTTI.
Definition: uobject.h:93
virtual Format * clone() const =0
Clone this object polymorphically.
Parses and represents ICU MessageFormat patterns.
#define U_I18N_API
Set to export library symbols from inside the i18n library, and to import them from outside...
Definition: utypes.h:301
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition: uversion.h:137
virtual UClassID getDynamicClassID() const
ICU4C "poor man's RTTI", returns a UClassID for the actual ICU class.
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
Definition: uversion.h:138
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers...
Definition: utypes.h:401
FieldPosition is a simple class used by Format and its subclasses to identify fields in formatted out...
Definition: fieldpos.h:108
ParsePosition is a simple class used by Format and its subclasses to keep track of the current positi...
Definition: parsepos.h:49
virtual UBool operator==(const Format &other) const =0
Return true if the given Format objects are semantically equal.
virtual void parseObject(const UnicodeString &source, Formattable &result, ParsePosition &parse_pos) const =0
Parse a string to produce an object.
Basic definitions for ICU, for both C and C++ APIs.
Format & operator=(const Format &)
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition: unistr.h:289
Formattable objects can be passed to the Format class or its subclasses for formatting.
Definition: fmtable.h:62
C++ API: MessagePattern class: Parses and represents ICU MessageFormat patterns.
C++ API: Compatibility APIs for number formatting.
int8_t UBool
The ICU boolean type.
Definition: umachine.h:225