]> git.saurik.com Git - apple/icu.git/blame - icuSources/i18n/digitaffix.h
ICU-59173.0.1.tar.gz
[apple/icu.git] / icuSources / i18n / digitaffix.h
CommitLineData
f3c0d7a5
A
1// © 2016 and later: Unicode, Inc. and others.
2// License & terms of use: http://www.unicode.org/copyright.html
2ca993e8
A
3/*
4*******************************************************************************
5* Copyright (C) 2015, International Business Machines
6* Corporation and others. All Rights Reserved.
7*******************************************************************************
8* digitaffix.h
9*
10* created on: 2015jan06
11* created by: Travis Keep
12*/
13
14#ifndef __DIGITAFFIX_H__
15#define __DIGITAFFIX_H__
16
17#include "unicode/uobject.h"
18
19#if !UCONFIG_NO_FORMATTING
20
21#include "unicode/unistr.h"
22#include "unicode/unum.h"
23#include "unicode/utypes.h"
24
25U_NAMESPACE_BEGIN
26
27class FieldPositionHandler;
28
29/**
30 * A prefix or suffix of a formatted number.
31 */
32class U_I18N_API DigitAffix : public UMemory {
33public:
34
35 /**
36 * Creates an empty DigitAffix.
37 */
38 DigitAffix();
39
40 /**
41 * Creates a DigitAffix containing given UChars where all of it has
42 * a field type of fieldId.
43 */
44 DigitAffix(
45 const UChar *value,
46 int32_t charCount,
47 int32_t fieldId=UNUM_FIELD_COUNT);
48
49 /**
50 * Makes this affix be the empty string.
51 */
52 void remove();
53
54 /**
55 * Append value to this affix. If fieldId is present, the appended
56 * string is considered to be the type fieldId.
57 */
58 void appendUChar(UChar value, int32_t fieldId=UNUM_FIELD_COUNT);
59
60 /**
61 * Append value to this affix. If fieldId is present, the appended
62 * string is considered to be the type fieldId.
63 */
64 void append(const UnicodeString &value, int32_t fieldId=UNUM_FIELD_COUNT);
65
66 /**
67 * Sets this affix to given string. The entire string
68 * is considered to be the type fieldId.
69 */
70 void setTo(const UnicodeString &value, int32_t fieldId=UNUM_FIELD_COUNT);
71
72 /**
73 * Append value to this affix. If fieldId is present, the appended
74 * string is considered to be the type fieldId.
75 */
76 void append(const UChar *value, int32_t charCount, int32_t fieldId=UNUM_FIELD_COUNT);
77
78 /**
79 * Formats this affix.
80 */
81 UnicodeString &format(
82 FieldPositionHandler &handler, UnicodeString &appendTo) const;
83 int32_t countChar32() const { return fAffix.countChar32(); }
84
85 /**
86 * Returns this affix as a unicode string.
87 */
88 const UnicodeString & toString() const { return fAffix; }
89
90 /**
91 * Returns TRUE if this object equals rhs.
92 */
93 UBool equals(const DigitAffix &rhs) const {
94 return ((fAffix == rhs.fAffix) && (fAnnotations == rhs.fAnnotations));
95 }
96private:
97 UnicodeString fAffix;
98 UnicodeString fAnnotations;
99};
100
101
102U_NAMESPACE_END
103#endif // #if !UCONFIG_NO_FORMATTING
104#endif // __DIGITAFFIX_H__