ICU 56.1: choicfmt.h Source File

ICU 56.1 56.1

- Main Page
- Related Pages
- Modules
- Namespaces
- Data Structures
- Files

- File List
- Globals

choicfmt.h
Go to the documentation of this file.
1 /*
2 ********************************************************************************
3 * Copyright (C) 1997-2013, International Business Machines
4 * Corporation and others. All Rights Reserved.
5 ********************************************************************************
6 *
7 * File CHOICFMT.H
8 *
9 * Modification History:
10 *
11 * Date Name Description
12 * 02/19/97 aliu Converted from java.
13 * 03/20/97 helena Finished first cut of implementation and got rid
14 * of nextDouble/previousDouble and replaced with
15 * boolean array.
16 * 4/10/97 aliu Clean up. Modified to work on AIX.
17 * 8/6/97 nos Removed overloaded constructor, member var 'buffer'.
18 * 07/22/98 stephen Removed operator!= (implemented in Format)
19 ********************************************************************************
20 */
21
22 #ifndef CHOICFMT_H
23 #define CHOICFMT_H
24
25 #include "unicode/utypes.h"
26
32 #if !UCONFIG_NO_FORMATTING
33 #ifndef U_HIDE_DEPRECATED_API
34
35 #include "unicode/fieldpos.h"
36 #include "unicode/format.h"
37 #include "unicode/messagepattern.h"
38 #include "unicode/numfmt.h"
39 #include "unicode/unistr.h"
40
41 U_NAMESPACE_BEGIN
42
43 class MessageFormat;
44
171 class U_I18N_API ChoiceFormat: public NumberFormat {
172 public:
181 ChoiceFormat(const UnicodeString& pattern,
182 UErrorCode& status);
183
184
197 ChoiceFormat(const double* limits,
198 const UnicodeString* formats,
199 int32_t count );
200
215 ChoiceFormat(const double* limits,
216 const UBool* closures,
217 const UnicodeString* formats,
218 int32_t count);
219
226 ChoiceFormat(const ChoiceFormat& that);
227
234 const ChoiceFormat& operator=(const ChoiceFormat& that);
235
240 virtual ~ChoiceFormat();
241
249 virtual Format* clone(void) const;
250
259 virtual UBool operator==(const Format& other) const;
260
269 virtual void applyPattern(const UnicodeString& pattern,
270 UErrorCode& status);
271
282 virtual void applyPattern(const UnicodeString& pattern,
283 UParseError& parseError,
284 UErrorCode& status);
293 virtual UnicodeString& toPattern(UnicodeString &pattern) const;
294
308 virtual void setChoices(const double* limitsToCopy,
309 const UnicodeString* formatsToCopy,
310 int32_t count );
311
322 virtual void setChoices(const double* limits,
323 const UBool* closures,
324 const UnicodeString* formats,
325 int32_t count);
326
335 virtual const double* getLimits(int32_t& count) const;
336
345 virtual const UBool* getClosures(int32_t& count) const;
346
355 virtual const UnicodeString* getFormats(int32_t& count) const;
356
357
358 using NumberFormat::format;
359
371 virtual UnicodeString& format(double number,
372 UnicodeString& appendTo,
373 FieldPosition& pos) const;
385 virtual UnicodeString& format(int32_t number,
386 UnicodeString& appendTo,
387 FieldPosition& pos) const;
388
400 virtual UnicodeString& format(int64_t number,
401 UnicodeString& appendTo,
402 FieldPosition& pos) const;
403
418 virtual UnicodeString& format(const Formattable* objs,
419 int32_t cnt,
420 UnicodeString& appendTo,
421 FieldPosition& pos,
422 UErrorCode& success) const;
423
424 using NumberFormat::parse;
425
440 virtual void parse(const UnicodeString& text,
441 Formattable& result,
442 ParsePosition& parsePosition) const;
443
452 virtual UClassID getDynamicClassID(void) const;
453
465 static UClassID U_EXPORT2 getStaticClassID(void);
466
467 private:
474 static UnicodeString& dtos(double value, UnicodeString& string);
475
476 ChoiceFormat(); // default constructor not implemented
477
488 ChoiceFormat(const UnicodeString& newPattern,
489 UParseError& parseError,
490 UErrorCode& status);
491
492 friend class MessageFormat;
493
494 virtual void setChoices(const double* limits,
495 const UBool* closures,
496 const UnicodeString* formats,
497 int32_t count,
498 UErrorCode &errorCode);
499
507 static int32_t findSubMessage(const MessagePattern &pattern, int32_t partIndex, double number);
508
509 static double parseArgument(
510 const MessagePattern &pattern, int32_t partIndex,
511 const UnicodeString &source, ParsePosition &pos);
512
521 static int32_t matchStringUntilLimitPart(
522 const MessagePattern &pattern, int32_t partIndex, int32_t limitPartIndex,
523 const UnicodeString &source, int32_t sourceOffset);
524
531 UErrorCode constructorErrorCode;
532
540 MessagePattern msgPattern;
541
581 // double* fChoiceLimits;
582 // UBool* fClosures;
583 // UnicodeString* fChoiceFormats;
584 // int32_t fCount;
585 };
586
587
588 U_NAMESPACE_END
589
590 #endif // U_HIDE_DEPRECATED_API
591 #endif /* #if !UCONFIG_NO_FORMATTING */
592
593 #endif // CHOICFMT_H
594 //eof
icu::Format
Base class for all formats.
Definition: format.h:94
icu::NumberFormat
Abstract base class for all number formats.
Definition: numfmt.h:172
unistr.h
C++ API: Unicode String.
UClassID
void * UClassID
UClassID is used to identify classes without using the compiler's RTTI.
Definition: uobject.h:91
format.h
C++ API: Base class for all formats.
icu::MessagePattern
Parses and represents ICU MessageFormat patterns.
Definition: messagepattern.h:358
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:358
fieldpos.h
C++ API: FieldPosition identifies the fields in a formatted output.
icu::NumberFormat::getDynamicClassID
virtual UClassID getDynamicClassID(void) const =0
Returns a unique class ID POLYMORPHICALLY.
U_NAMESPACE_BEGIN
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition: uversion.h:129
icu::NumberFormat::operator==
virtual UBool operator==(const Format &other) const
Return true if the given Format objects are semantically equal.
icu::MessageFormat
Definition: msgfmt.h:323
U_NAMESPACE_END
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
Definition: uversion.h:130
UErrorCode
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers...
Definition: utypes.h:476
icu::NumberFormat::getStaticClassID
static UClassID getStaticClassID(void)
Return the class ID for this class.
icu::FieldPosition
FieldPosition is a simple class used by Format and its subclasses to identify fields in formatted out...
Definition: fieldpos.h:106
icu::NumberFormat::parse
virtual void parse(const UnicodeString &text, Formattable &result, ParsePosition &parsePosition) const =0
Return a long if possible (e.g.
icu::ParsePosition
ParsePosition is a simple class used by Format and its subclasses to keep track of the current positi...
Definition: parsepos.h:47
icu::ChoiceFormat
ChoiceFormat converts between ranges of numeric values and strings for those ranges.
Definition: choicfmt.h:171
UParseError
A UParseError struct is used to returned detailed information about parsing errors.
Definition: parseerr.h:56
utypes.h
Basic definitions for ICU, for both C and C++ APIs.
icu::UnicodeString
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition: unistr.h:293
icu::Formattable
Formattable objects can be passed to the Format class or its subclasses for formatting.
Definition: fmtable.h:66
icu::NumberFormat::format
virtual UnicodeString & format(const Formattable &obj, UnicodeString &appendTo, FieldPosition &pos, UErrorCode &status) const
Format an object to produce a string.
messagepattern.h
C++ API: MessagePattern class: Parses and represents ICU MessageFormat patterns.
numfmt.h
C++ API: Abstract base class for all number formats.
icu::NumberFormat::operator=
NumberFormat & operator=(const NumberFormat &)
Assignment operator.
icu::Format::clone
virtual Format * clone() const =0
Clone this object polymorphically.
UBool
int8_t UBool
The ICU boolean type.
Definition: umachine.h:234