ICU 71.1 71.1

formattedvalue.h
Go to the documentation of this file.
1 // © 2018 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
3
4 #ifndef __FORMATTEDVALUE_H__
5 #define __FORMATTEDVALUE_H__
6
7 #include "unicode/utypes.h"
8
9 #if U_SHOW_CPLUSPLUS_API
10
11 #if !UCONFIG_NO_FORMATTING
12
13 #include "unicode/appendable.h"
14 #include "unicode/fpositer.h"
15 #include "unicode/unistr.h"
16 #include "unicode/uformattedvalue.h"
17
18 U_NAMESPACE_BEGIN
19
41 class U_I18N_API ConstrainedFieldPosition : public UMemory {
42 public:
43
51 ConstrainedFieldPosition();
52
54 ~ConstrainedFieldPosition();
55
64 void reset();
65
88 void constrainCategory(int32_t category);
89
113 void constrainField(int32_t category, int32_t field);
114
124 inline int32_t getCategory() const {
125 return fCategory;
126 }
127
137 inline int32_t getField() const {
138 return fField;
139 }
140
149 inline int32_t getStart() const {
150 return fStart;
151 }
152
161 inline int32_t getLimit() const {
162 return fLimit;
163 }
164
169
180 inline int64_t getInt64IterationContext() const {
181 return fContext;
182 }
183
192 void setInt64IterationContext(int64_t context);
193
204 UBool matchesField(int32_t category, int32_t field) const;
205
220 void setState(
221 int32_t category,
222 int32_t field,
223 int32_t start,
224 int32_t limit);
225
226 private:
227 int64_t fContext = 0LL;
228 int32_t fField = 0;
229 int32_t fStart = 0;
230 int32_t fLimit = 0;
231 int32_t fCategory = UFIELD_CATEGORY_UNDEFINED;
232 int8_t fConstraint = 0;
233 };
234
241 class U_I18N_API FormattedValue /* not : public UObject because this is an interface/mixin class */ {
242 public:
244 virtual ~FormattedValue();
245
256 virtual UnicodeString toString(UErrorCode& status) const = 0;
257
272 virtual UnicodeString toTempString(UErrorCode& status) const = 0;
273
285 virtual Appendable& appendTo(Appendable& appendable, UErrorCode& status) const = 0;
286
309 virtual UBool nextPosition(ConstrainedFieldPosition& cfpos, UErrorCode& status) const = 0;
310 };
311
312 U_NAMESPACE_END
313
314 #endif /* #if !UCONFIG_NO_FORMATTING */
315
316 #endif /* U_SHOW_CPLUSPLUS_API */
317
318 #endif // __FORMATTEDVALUE_H__
fpositer.h
C++ API: FieldPosition Iterator.
utypes.h
Basic definitions for ICU, for both C and C++ APIs.
U_I18N_API
#define U_I18N_API
Definition: utypes.h:301
UBool
int8_t UBool
The ICU boolean type, a signed-byte integer.
Definition: umachine.h:269
uformattedvalue.h
C API: Abstract operations for localized strings.
icu::FormattedValue
An abstract formatted value: a string with associated field attributes.
Definition: formattedvalue.h:241
icu::ConstrainedFieldPosition::getStart
int32_t getStart() const
Gets the INCLUSIVE start index for the current position.
Definition: formattedvalue.h:149
icu::UnicodeString
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition: unistr.h:295
UErrorCode
UErrorCode
Standard ICU4C error code type, a substitute for exceptions.
Definition: utypes.h:415
icu::UMemory
UMemory is the common ICU base class.
Definition: uobject.h:115
icu::ConstrainedFieldPosition::getLimit
int32_t getLimit() const
Gets the EXCLUSIVE end index stored for the current position.
Definition: formattedvalue.h:161
appendable.h
C++ API: Appendable class: Sink for Unicode code points and 16-bit code units (char16_ts).
icu::Appendable
Base class for objects to which Unicode characters and strings can be appended.
Definition: appendable.h:54
icu::ConstrainedFieldPosition::getCategory
int32_t getCategory() const
Gets the field category for the current position.
Definition: formattedvalue.h:124
icu::ConstrainedFieldPosition::getInt64IterationContext
int64_t getInt64IterationContext() const
Gets an int64 that FormattedValue implementations may use for storage.
Definition: formattedvalue.h:180
UFIELD_CATEGORY_UNDEFINED
@ UFIELD_CATEGORY_UNDEFINED
For an undefined field category.
Definition: uformattedvalue.h:40
icu::ConstrainedFieldPosition::getField
int32_t getField() const
Gets the field for the current position.
Definition: formattedvalue.h:137
unistr.h
C++ API: Unicode String.
icu::ConstrainedFieldPosition
Represents a span of a string containing a given field.
Definition: formattedvalue.h:41