selfmt.h
Go to the documentation of this file.
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/********************************************************************
* COPYRIGHT:
* Copyright (c) 1997-2011, International Business Machines Corporation and
* others. All Rights Reserved.
* Copyright (C) 2010 , Yahoo! Inc.
********************************************************************
*
* File SELFMT.H
*
* Modification History:
*
* Date Name Description
* 11/11/09 kirtig Finished first cut of implementation.
********************************************************************/
#ifndef SELFMT
#define SELFMT
#include "unicode/utypes.h"
#if U_SHOW_CPLUSPLUS_API
#include "unicode/messagepattern.h"
#include "unicode/numfmt.h"
#if !UCONFIG_NO_FORMATTING
U_NAMESPACE_BEGIN
class MessageFormat;
class U_I18N_API SelectFormat : public Format {
public:
SelectFormat(const UnicodeString& pattern, UErrorCode& status);
SelectFormat(const SelectFormat& other);
virtual ~SelectFormat();
void applyPattern(const UnicodeString& pattern, UErrorCode& status);
using Format::format;
UnicodeString& format(const UnicodeString& keyword,
UnicodeString& appendTo,
FieldPosition& pos,
UErrorCode& status) const;
SelectFormat& operator=(const SelectFormat& other);
virtual bool operator==(const Format& other) const override;
virtual bool operator!=(const Format& other) const;
virtual SelectFormat* clone() const override;
UnicodeString& format(const Formattable& obj,
UnicodeString& appendTo,
FieldPosition& pos,
UErrorCode& status) const override;
UnicodeString& toPattern(UnicodeString& appendTo);
virtual void parseObject(const UnicodeString& source,
Formattable& result,
ParsePosition& parse_pos) const override;
static UClassID U_EXPORT2 getStaticClassID(void);
virtual UClassID getDynamicClassID() const override;
private:
friend class MessageFormat;
SelectFormat() = delete; // default constructor not implemented.
static int32_t findSubMessage(const MessagePattern& pattern, int32_t partIndex,
const UnicodeString& keyword, UErrorCode& ec);
MessagePattern msgPattern;
};
U_NAMESPACE_END
#endif /* #if !UCONFIG_NO_FORMATTING */
#endif /* U_SHOW_CPLUSPLUS_API */
#endif // _SELFMT
//eof
icu::FieldPosition
FieldPosition is a simple class used by Format and its subclasses to identify fields in formatted out...
Definition: fieldpos.h:110
icu::Format
Base class for all formats.
Definition: format.h:98
icu::Format::format
UnicodeString & format(const Formattable &obj, UnicodeString &appendTo, UErrorCode &status) const
Formats an object to produce a string.
icu::Formattable
Formattable objects can be passed to the Format class or its subclasses for formatting.
Definition: fmtable.h:64
icu::MessageFormat
Definition: msgfmt.h:345
icu::MessagePattern
Parses and represents ICU MessageFormat patterns.
Definition: messagepattern.h:362
icu::ParsePosition
ParsePosition is a simple class used by Format and its subclasses to keep track of the current positi...
Definition: parsepos.h:52
icu::SelectFormat
Definition: selfmt.h:188
icu::SelectFormat::operator!=
virtual bool operator!=(const Format &other) const
Return true if another object is semantically unequal to this one.
icu::SelectFormat::SelectFormat
SelectFormat(const SelectFormat &other)
copy constructor.
icu::SelectFormat::format
UnicodeString & format(const Formattable &obj, UnicodeString &appendTo, FieldPosition &pos, UErrorCode &status) const override
Format an object to produce a string.
icu::SelectFormat::getStaticClassID
static UClassID getStaticClassID(void)
ICU "poor man's RTTI", returns a UClassID for this class.
icu::SelectFormat::clone
virtual SelectFormat * clone() const override
Clones this Format object polymorphically.
icu::SelectFormat::parseObject
virtual void parseObject(const UnicodeString &source, Formattable &result, ParsePosition &parse_pos) const override
This method is not yet supported by SelectFormat.
icu::SelectFormat::toPattern
UnicodeString & toPattern(UnicodeString &appendTo)
Returns the pattern from applyPattern() or constructor.
icu::SelectFormat::getDynamicClassID
virtual UClassID getDynamicClassID() const override
ICU "poor man's RTTI", returns a UClassID for the actual class.
icu::SelectFormat::format
UnicodeString & format(const UnicodeString &keyword, UnicodeString &appendTo, FieldPosition &pos, UErrorCode &status) const
Selects the phrase for the given keyword.
icu::SelectFormat::operator=
SelectFormat & operator=(const SelectFormat &other)
Assignment operator.
icu::SelectFormat::operator==
virtual bool operator==(const Format &other) const override
Return true if another object is semantically equal to this one.
icu::SelectFormat::~SelectFormat
virtual ~SelectFormat()
Destructor.
icu::SelectFormat::applyPattern
void applyPattern(const UnicodeString &pattern, UErrorCode &status)
Sets the pattern used by this select format.
icu::SelectFormat::SelectFormat
SelectFormat(const UnicodeString &pattern, UErrorCode &status)
Creates a new SelectFormat for a given pattern string.
icu::UnicodeString
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition: unistr.h:296
messagepattern.h
C++ API: MessagePattern class: Parses and represents ICU MessageFormat patterns.
numfmt.h
C++ API: Compatibility APIs for number formatting.
UClassID
void * UClassID
UClassID is used to identify classes without using the compiler's RTTI.
Definition: uobject.h:96
utypes.h
Basic definitions for ICU, for both C and C++ APIs.
UErrorCode
UErrorCode
Standard ICU4C error code type, a substitute for exceptions.
Definition: utypes.h:415
U_I18N_API
#define U_I18N_API
Set to export library symbols from inside the i18n library, and to import them from outside.
Definition: utypes.h:301