1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
4 *******************************************************************************
5 * Copyright (C) 2015, International Business Machines
6 * Corporation and others. All Rights Reserved.
7 *******************************************************************************
10 * created on: 2015jan06
11 * created by: Travis Keep
14 #ifndef __DIGITAFFIX_H__
15 #define __DIGITAFFIX_H__
17 #include "unicode/uobject.h"
19 #if !UCONFIG_NO_FORMATTING
21 #include "unicode/unistr.h"
22 #include "unicode/unum.h"
23 #include "unicode/utypes.h"
27 class FieldPositionHandler
;
30 * A prefix or suffix of a formatted number.
32 class U_I18N_API DigitAffix
: public UMemory
{
36 * Creates an empty DigitAffix.
41 * Creates a DigitAffix containing given UChars where all of it has
42 * a field type of fieldId.
47 int32_t fieldId
=UNUM_FIELD_COUNT
);
50 * Makes this affix be the empty string.
55 * Append value to this affix. If fieldId is present, the appended
56 * string is considered to be the type fieldId.
58 void appendUChar(UChar value
, int32_t fieldId
=UNUM_FIELD_COUNT
);
61 * Append value to this affix. If fieldId is present, the appended
62 * string is considered to be the type fieldId.
64 void append(const UnicodeString
&value
, int32_t fieldId
=UNUM_FIELD_COUNT
);
67 * Sets this affix to given string. The entire string
68 * is considered to be the type fieldId.
70 void setTo(const UnicodeString
&value
, int32_t fieldId
=UNUM_FIELD_COUNT
);
73 * Append value to this affix. If fieldId is present, the appended
74 * string is considered to be the type fieldId.
76 void append(const UChar
*value
, int32_t charCount
, int32_t fieldId
=UNUM_FIELD_COUNT
);
81 UnicodeString
&format(
82 FieldPositionHandler
&handler
, UnicodeString
&appendTo
) const;
83 int32_t countChar32() const { return fAffix
.countChar32(); }
86 * Returns this affix as a unicode string.
88 const UnicodeString
& toString() const { return fAffix
; }
91 * Returns TRUE if this object equals rhs.
93 UBool
equals(const DigitAffix
&rhs
) const {
94 return ((fAffix
== rhs
.fAffix
) && (fAnnotations
== rhs
.fAnnotations
));
98 UnicodeString fAnnotations
;
103 #endif // #if !UCONFIG_NO_FORMATTING
104 #endif // __DIGITAFFIX_H__