ICU 54.1 54.1

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

- File List
- Globals

All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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