ICU 57.1  57.1
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 
238  UnicodeString& appendTo,
239  FieldPosition& pos,
240  UErrorCode& status) const;
241 
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 
291  UnicodeString& appendTo,
292  FieldPosition& pos,
293  UErrorCode& status) const;
294 
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
FieldPosition is a simple class used by Format and its subclasses to identify fields in formatted out...
Definition: fieldpos.h:106
Base class for all formats.
Definition: format.h:94
UnicodeString & format(const Formattable &obj, UnicodeString &appendTo, UErrorCode &status) const
Formats an object to produce a string.
Formattable objects can be passed to the Format class or its subclasses for formatting.
Definition: fmtable.h:66
Parses and represents ICU MessageFormat patterns.
ParsePosition is a simple class used by Format and its subclasses to keep track of the current positi...
Definition: parsepos.h:47
SelectFormat(const SelectFormat &other)
copy constructor.
static UClassID getStaticClassID(void)
ICU "poor man's RTTI", returns a UClassID for this class.
virtual UBool operator!=(const Format &other) const
Return true if another object is semantically unequal to this one.
SelectFormat(const UnicodeString &pattern, UErrorCode &status)
Creates a new SelectFormat for a given pattern string.
virtual ~SelectFormat()
Destructor.
void applyPattern(const UnicodeString &pattern, UErrorCode &status)
Sets the pattern used by this select format.
virtual void parseObject(const UnicodeString &source, Formattable &result, ParsePosition &parse_pos) const
This method is not yet supported by SelectFormat.
virtual Format * clone(void) const
Clones this Format object polymorphically.
SelectFormat & operator=(const SelectFormat &other)
Assignment operator.
UnicodeString & format(const UnicodeString &keyword, UnicodeString &appendTo, FieldPosition &pos, UErrorCode &status) const
Selects the phrase for the given keyword.
virtual UBool operator==(const Format &other) const
Return true if another object is semantically equal to this one.
UnicodeString & format(const Formattable &obj, UnicodeString &appendTo, FieldPosition &pos, UErrorCode &status) const
Format an object to produce a string.
UnicodeString & toPattern(UnicodeString &appendTo)
Returns the pattern from applyPattern() or constructor.
virtual UClassID getDynamicClassID() const
ICU "poor man's RTTI", returns a UClassID for the actual class.
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition: unistr.h:294
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:234
void * UClassID
UClassID is used to identify classes without using the compiler's RTTI.
Definition: uobject.h:91
Basic definitions for ICU, for both C and C++ APIs.
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers,...
Definition: utypes.h:476
#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_END
This is used to end a declaration of a public ICU C++ API.
Definition: uversion.h:130
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition: uversion.h:129