ICU 50.1.2  50.1.2
selfmt.h
Go to the documentation of this file.
1 /********************************************************************
2  * COPYRIGHT:
3  * Copyright (c) 1997-2011, International Business Machines Corporation and
4  * others. All Rights Reserved.
5  * Copyright (C) 2010 , Yahoo! Inc.
6  ********************************************************************
7  *
8  * File SELFMT.H
9  *
10  * Modification History:
11  *
12  * Date Name Description
13  * 11/11/09 kirtig Finished first cut of implementation.
14  ********************************************************************/
15 
16 #ifndef SELFMT
17 #define SELFMT
18 
19 #include "unicode/messagepattern.h"
20 #include "unicode/numfmt.h"
21 #include "unicode/utypes.h"
22 
28 #if !UCONFIG_NO_FORMATTING
29 
31 
32 class MessageFormat;
33 
184 public:
185 
194  SelectFormat(const UnicodeString& pattern, UErrorCode& status);
195 
200  SelectFormat(const SelectFormat& other);
201 
206  virtual ~SelectFormat();
207 
219  void applyPattern(const UnicodeString& pattern, UErrorCode& status);
220 
221 
222  using Format::format;
223 
237  UnicodeString& format(const UnicodeString& keyword,
238  UnicodeString& appendTo,
239  FieldPosition& pos,
240  UErrorCode& status) const;
241 
248  SelectFormat& operator=(const SelectFormat& other);
249 
257  virtual UBool operator==(const Format& other) const;
258 
266  virtual UBool operator!=(const Format& other) const;
267 
273  virtual Format* clone(void) const;
274 
290  UnicodeString& format(const Formattable& obj,
291  UnicodeString& appendTo,
292  FieldPosition& pos,
293  UErrorCode& status) const;
294 
303  UnicodeString& toPattern(UnicodeString& appendTo);
304 
327  virtual void parseObject(const UnicodeString& source,
328  Formattable& result,
329  ParsePosition& parse_pos) const;
330 
335  static UClassID U_EXPORT2 getStaticClassID(void);
336 
341  virtual UClassID getDynamicClassID() const;
342 
343 private:
344  friend class MessageFormat;
345 
346  SelectFormat(); // default constructor not implemented.
347 
356  static int32_t findSubMessage(const MessagePattern& pattern, int32_t partIndex,
357  const UnicodeString& keyword, UErrorCode& ec);
358 
359  MessagePattern msgPattern;
360 };
361 
363 
364 #endif /* #if !UCONFIG_NO_FORMATTING */
365 
366 #endif // _SELFMT
367 //eof
Base class for all formats.
Definition: format.h:94
virtual UClassID getDynamicClassID() const =0
ICU4C "poor man's RTTI", returns a UClassID for the actual ICU class.
void * UClassID
UClassID is used to identify classes without using the compiler's RTTI.
Definition: uobject.h:96
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:358
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition: uversion.h:129
UnicodeString & format(const Formattable &obj, UnicodeString &appendTo, UErrorCode &status) const
Formats an object to produce a string.
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
Definition: uversion.h:130
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers...
Definition: utypes.h:476
FieldPosition is a simple class used by Format and its subclasses to identify fields in formatted out...
Definition: fieldpos.h:106
ParsePosition is a simple class used by Format and its subclasses to keep track of the current positi...
Definition: parsepos.h:47
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 &)
UBool operator!=(const Format &other) const
Return true if the given Format objects are not semantically equal.
Definition: format.h:119
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition: unistr.h:246
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: Abstract base class for all number formats.
int8_t UBool
The ICU boolean type.
Definition: umachine.h:200