2 *******************************************************************************
3 * Copyright (C) 2015, International Business Machines
4 * Corporation and others. All Rights Reserved.
5 *******************************************************************************
8 * created on: 2015jan06
9 * created by: Travis Keep
12 #ifndef __DIGITAFFIX_H__
13 #define __DIGITAFFIX_H__
15 #include "unicode/uobject.h"
17 #if !UCONFIG_NO_FORMATTING
19 #include "unicode/unistr.h"
20 #include "unicode/unum.h"
21 #include "unicode/utypes.h"
25 class FieldPositionHandler
;
28 * A prefix or suffix of a formatted number.
30 class U_I18N_API DigitAffix
: public UMemory
{
34 * Creates an empty DigitAffix.
39 * Creates a DigitAffix containing given UChars where all of it has
40 * a field type of fieldId.
45 int32_t fieldId
=UNUM_FIELD_COUNT
);
48 * Makes this affix be the empty string.
53 * Append value to this affix. If fieldId is present, the appended
54 * string is considered to be the type fieldId.
56 void appendUChar(UChar value
, int32_t fieldId
=UNUM_FIELD_COUNT
);
59 * Append value to this affix. If fieldId is present, the appended
60 * string is considered to be the type fieldId.
62 void append(const UnicodeString
&value
, int32_t fieldId
=UNUM_FIELD_COUNT
);
65 * Sets this affix to given string. The entire string
66 * is considered to be the type fieldId.
68 void setTo(const UnicodeString
&value
, int32_t fieldId
=UNUM_FIELD_COUNT
);
71 * Append value to this affix. If fieldId is present, the appended
72 * string is considered to be the type fieldId.
74 void append(const UChar
*value
, int32_t charCount
, int32_t fieldId
=UNUM_FIELD_COUNT
);
79 UnicodeString
&format(
80 FieldPositionHandler
&handler
, UnicodeString
&appendTo
) const;
81 int32_t countChar32() const { return fAffix
.countChar32(); }
84 * Returns this affix as a unicode string.
86 const UnicodeString
& toString() const { return fAffix
; }
89 * Returns TRUE if this object equals rhs.
91 UBool
equals(const DigitAffix
&rhs
) const {
92 return ((fAffix
== rhs
.fAffix
) && (fAnnotations
== rhs
.fAnnotations
));
96 UnicodeString fAnnotations
;
101 #endif // #if !UCONFIG_NO_FORMATTING
102 #endif // __DIGITAFFIX_H__