Movatterモバイル変換


[0]ホーム

URL:


ICU 78.1  78.1
measfmt.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 **********************************************************************
5 * Copyright (c) 2004-2016, International Business Machines
6 * Corporation and others. All Rights Reserved.
7 **********************************************************************
8 * Author: Alan Liu
9 * Created: April 20, 2004
10 * Since: ICU 3.0
11 **********************************************************************
12 */
13 #ifndef MEASUREFORMAT_H
14 #define MEASUREFORMAT_H
15 
16 #include "unicode/utypes.h"
17 
18 #if U_SHOW_CPLUSPLUS_API
19 
20 #if !UCONFIG_NO_FORMATTING
21 
22 #include "unicode/format.h"
23 #include "unicode/udat.h"
24 
38 enumUMeasureFormatWidth {
39 
40 // Wide, short, and narrow must be first and in this order.
45 UMEASFMT_WIDTH_WIDE,
46 
51 UMEASFMT_WIDTH_SHORT,
52 
57 UMEASFMT_WIDTH_NARROW,
58 
64 UMEASFMT_WIDTH_NUMERIC,
65 
66 #ifndef U_HIDE_DEPRECATED_API
71 UMEASFMT_WIDTH_COUNT = 4
72 #endif// U_HIDE_DEPRECATED_API
73 };
75 typedefenumUMeasureFormatWidthUMeasureFormatWidth;
76 
77 U_NAMESPACE_BEGIN
78 
79 classMeasure;
80 classMeasureUnit;
81 classNumberFormat;
82 classPluralRules;
83 classMeasureFormatCacheData;
84 classSharedNumberFormat;
85 classSharedPluralRules;
86 classQuantityFormatter;
87 classSimpleFormatter;
88 classListFormatter;
89 classDateFormat;
90 
101 classU_I18N_APIMeasureFormat :publicFormat {
102 public:
103 usingFormat::parseObject;
104 usingFormat::format;
105 
113 MeasureFormat(
114 constLocale &locale,UMeasureFormatWidth width,UErrorCode &status);
115 
123 MeasureFormat(
124 constLocale &locale,
125 UMeasureFormatWidth width,
126 NumberFormat *nfToAdopt,
127 UErrorCode &status);
128 
133 MeasureFormat(constMeasureFormat &other);
134 
139 MeasureFormat &operator=(constMeasureFormat &rhs);
140 
145 virtual~MeasureFormat();
146 
151 virtualbooloperator==(constFormat &other)const override;
152 
157 virtualMeasureFormat *clone()const override;
158 
163 virtualUnicodeString &format(
164 constFormattable &obj,
165 UnicodeString &appendTo,
166 FieldPosition &pos,
167 UErrorCode &status)const override;
168 
169 #ifndef U_FORCE_HIDE_DRAFT_API
176 virtualvoidparseObject(
177 constUnicodeString &source,
178 Formattable &reslt,
179 ParsePosition &pos)const override;
180 #endif// U_FORCE_HIDE_DRAFT_API
181 
198 UnicodeString &formatMeasures(
199 constMeasure *measures,
200  int32_t measureCount,
201 UnicodeString &appendTo,
202 FieldPosition &pos,
203 UErrorCode &status)const;
204 
218 UnicodeString &formatMeasurePerUnit(
219 constMeasure &measure,
220 constMeasureUnit &perUnit,
221 UnicodeString &appendTo,
222 FieldPosition &pos,
223 UErrorCode &status)const;
224 
236 UnicodeStringgetUnitDisplayName(constMeasureUnit& unit,UErrorCode &status)const;
237 
238 
250 staticMeasureFormat* U_EXPORT2createCurrencyFormat(constLocale& locale,
251 UErrorCode& ec);
252 
263 staticMeasureFormat* U_EXPORT2createCurrencyFormat(UErrorCode& ec);
264 
276 staticUClassID U_EXPORT2getStaticClassID();
277 
289 virtualUClassIDgetDynamicClassID()const override;
290 
291 protected:
296 MeasureFormat();
297 
298 #ifndef U_HIDE_INTERNAL_API
299 
305 voidinitMeasureFormat(
306 constLocale &locale,
307 UMeasureFormatWidth width,
308 NumberFormat *nfToAdopt,
309 UErrorCode &status);
317 UBoolsetMeasureFormatLocale(constLocale &locale,UErrorCode &status);
318 
324 voidadoptNumberFormat(NumberFormat *nfToAdopt,UErrorCode &status);
325 
330 constNumberFormat &getNumberFormatInternal()const;
331 
337 constNumberFormat&getCurrencyFormatInternal()const;
338 
343 constPluralRules &getPluralRules()const;
344 
349 LocalegetLocale(UErrorCode &status)const;
350 
355 constchar *getLocaleID(UErrorCode &status)const;
356 
357 #endif/* U_HIDE_INTERNAL_API */
358 
359 private:
360 const MeasureFormatCacheData *cache;
361 const SharedNumberFormat *numberFormat;
362 const SharedPluralRules *pluralRules;
363 UMeasureFormatWidth fWidth;
364 
365 // Declared outside of MeasureFormatSharedData because ListFormatter
366 // objects are relatively cheap to copy; therefore, they don't need to be
367 // shared across instances.
368 ListFormatter *listFormatter;
369 
370 UnicodeString &formatMeasure(
371 constMeasure &measure,
372 constNumberFormat &nf,
373 UnicodeString &appendTo,
374 FieldPosition &pos,
375 UErrorCode &status)const;
376 
377 UnicodeString &formatMeasuresSlowTrack(
378 constMeasure *measures,
379  int32_t measureCount,
380 UnicodeString& appendTo,
381 FieldPosition& pos,
382 UErrorCode& status)const;
383 
384 UnicodeString &formatNumeric(
385 constFormattable *hms,// always length 3: [0] is hour; [1] is
386 // minute; [2] is second.
387  int32_t bitMap,// 1=hour set, 2=minute set, 4=second set
388 UnicodeString &appendTo,
389 UErrorCode &status)const;
390 };
391 
392 U_NAMESPACE_END
393 
394 #endif// #if !UCONFIG_NO_FORMATTING
395 
396 #endif/* U_SHOW_CPLUSPLUS_API */
397 
398 #endif// #ifndef MEASUREFORMAT_H
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
U_I18N_API UnicodeString & format(const Formattable &obj, UnicodeString &appendTo, UErrorCode &status) const
Formats an object to produce a string.
icu::Format::parseObject
virtual U_I18N_API void parseObject(const UnicodeString &source, Formattable &result, ParsePosition &parse_pos) const =0
Parse a string to produce an object.
icu::Formattable
Formattable objects can be passed to the Format class or its subclasses for formatting.
Definition:fmtable.h:63
icu::ListFormatter
An immutable class for formatting a list, using data from CLDR (or supplied separately).
Definition:listformatter.h:151
icu::Locale
A Locale object represents a specific geographical, political, or cultural region.
Definition:locid.h:198
icu::MeasureFormat
Definition:measfmt.h:101
icu::MeasureFormat::createCurrencyFormat
static MeasureFormat * createCurrencyFormat(UErrorCode &ec)
Return a formatter for CurrencyAmount objects in the default locale.
icu::MeasureFormat::parseObject
virtual void parseObject(const UnicodeString &source, Formattable &reslt, ParsePosition &pos) const override
Parse a string to produce an object.
icu::MeasureFormat::operator=
MeasureFormat & operator=(const MeasureFormat &rhs)
Assignment operator.
icu::MeasureFormat::MeasureFormat
MeasureFormat(const Locale &locale, UMeasureFormatWidth width, UErrorCode &status)
Constructor.
icu::MeasureFormat::initMeasureFormat
void initMeasureFormat(const Locale &locale, UMeasureFormatWidth width, NumberFormat *nfToAdopt, UErrorCode &status)
ICU use only.
icu::MeasureFormat::formatMeasurePerUnit
UnicodeString & formatMeasurePerUnit(const Measure &measure, const MeasureUnit &perUnit, UnicodeString &appendTo, FieldPosition &pos, UErrorCode &status) const
Formats a single measure per unit.
icu::MeasureFormat::getNumberFormatInternal
const NumberFormat & getNumberFormatInternal() const
ICU use only.
icu::MeasureFormat::MeasureFormat
MeasureFormat(const MeasureFormat &other)
Copy constructor.
icu::MeasureFormat::getStaticClassID
static UClassID getStaticClassID()
Return the class ID for this class.
icu::MeasureFormat::getCurrencyFormatInternal
const NumberFormat & getCurrencyFormatInternal() const
ICU use only.
icu::MeasureFormat::~MeasureFormat
virtual ~MeasureFormat()
Destructor.
icu::MeasureFormat::getUnitDisplayName
UnicodeString getUnitDisplayName(const MeasureUnit &unit, UErrorCode &status) const
Gets the display name of the specified MeasureUnit corresponding to the current locale and format wid...
icu::MeasureFormat::getLocaleID
const char * getLocaleID(UErrorCode &status) const
ICU use only.
icu::MeasureFormat::format
virtual UnicodeString & format(const Formattable &obj, UnicodeString &appendTo, FieldPosition &pos, UErrorCode &status) const override
Formats object to produce a string.
icu::MeasureFormat::clone
virtual MeasureFormat * clone() const override
Clones this object polymorphically.
icu::MeasureFormat::createCurrencyFormat
static MeasureFormat * createCurrencyFormat(const Locale &locale, UErrorCode &ec)
Return a formatter for CurrencyAmount objects in the given locale.
icu::MeasureFormat::getPluralRules
const PluralRules & getPluralRules() const
ICU use only.
icu::MeasureFormat::getDynamicClassID
virtual UClassID getDynamicClassID() const override
Returns a unique class ID POLYMORPHICALLY.
icu::MeasureFormat::setMeasureFormatLocale
UBool setMeasureFormatLocale(const Locale &locale, UErrorCode &status)
ICU use only.
icu::MeasureFormat::MeasureFormat
MeasureFormat()
Default constructor.
icu::MeasureFormat::operator==
virtual bool operator==(const Format &other) const override
Return true if given Format objects are semantically equal.
icu::MeasureFormat::adoptNumberFormat
void adoptNumberFormat(NumberFormat *nfToAdopt, UErrorCode &status)
ICU use only.
icu::MeasureFormat::formatMeasures
UnicodeString & formatMeasures(const Measure *measures, int32_t measureCount, UnicodeString &appendTo, FieldPosition &pos, UErrorCode &status) const
Formats measure objects to produce a string.
icu::MeasureFormat::getLocale
Locale getLocale(UErrorCode &status) const
ICU use only.
icu::MeasureFormat::MeasureFormat
MeasureFormat(const Locale &locale, UMeasureFormatWidth width, NumberFormat *nfToAdopt, UErrorCode &status)
Constructor.
icu::MeasureUnit
A unit such as length, mass, volume, currency, etc.
Definition:measunit.h:405
icu::Measure
An amount of a specified unit, consisting of a number and a Unit.
Definition:measure.h:45
icu::NumberFormat
Definition:numfmt.h:175
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::PluralRules
Defines rules for mapping non-negative numeric values onto a small set of keywords.
Definition:plurrule.h:212
icu::UnicodeString
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition:unistr.h:303
format.h
C++ API: Base class for all formats.
UMeasureFormatWidth
UMeasureFormatWidth
Constants for various widths.
Definition:measfmt.h:38
UMEASFMT_WIDTH_NARROW
@ UMEASFMT_WIDTH_NARROW
Use symbols for measure units when possible.
Definition:measfmt.h:57
UMEASFMT_WIDTH_WIDE
@ UMEASFMT_WIDTH_WIDE
Spell out measure units.
Definition:measfmt.h:45
UMEASFMT_WIDTH_COUNT
@ UMEASFMT_WIDTH_COUNT
One more than the highest normal UMeasureFormatWidth value.
Definition:measfmt.h:71
UMEASFMT_WIDTH_NUMERIC
@ UMEASFMT_WIDTH_NUMERIC
Completely omit measure units when possible.
Definition:measfmt.h:64
UMEASFMT_WIDTH_SHORT
@ UMEASFMT_WIDTH_SHORT
Abbreviate measure units.
Definition:measfmt.h:51
udat.h
C API: DateFormat.
UBool
int8_t UBool
The ICU boolean type, a signed-byte integer.
Definition:umachine.h:269
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:509
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:316

Generated by doxygen 1.9.1
[8]ページ先頭

©2009-2025 Movatter.jp