ICU 64.2 64.2

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 #if !UCONFIG_NO_FORMATTING
9 #ifndef U_HIDE_DRAFT_API
10
11 #include "unicode/appendable.h"
12 #include "unicode/fpositer.h"
13 #include "unicode/unistr.h"
14 #include "unicode/uformattedvalue.h"
15
16 U_NAMESPACE_BEGIN
17
40 class U_I18N_API ConstrainedFieldPosition : public UMemory {
41 public:
42
50 ConstrainedFieldPosition();
51
53 ~ConstrainedFieldPosition();
54
63 void reset();
64
87 void constrainCategory(int32_t category);
88
112 void constrainField(int32_t category, int32_t field);
113
123 inline int32_t getCategory() const {
124 return fCategory;
125 }
126
136 inline int32_t getField() const {
137 return fField;
138 }
139
148 inline int32_t getStart() const {
149 return fStart;
150 }
151
160 inline int32_t getLimit() const {
161 return fLimit;
162 }
163
168
179 inline int64_t getInt64IterationContext() const {
180 return fContext;
181 }
182
191 void setInt64IterationContext(int64_t context);
192
203 UBool matchesField(int32_t category, int32_t field) const;
204
219 void setState(
220 int32_t category,
221 int32_t field,
222 int32_t start,
223 int32_t limit);
224
225 private:
226 int64_t fContext = 0LL;
227 int32_t fField = 0;
228 int32_t fStart = 0;
229 int32_t fLimit = 0;
230 int32_t fCategory = UFIELD_CATEGORY_UNDEFINED;
231 int8_t fConstraint = 0;
232 };
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
313 U_NAMESPACE_END
314
315 #endif /* U_HIDE_DRAFT_API */
316 #endif /* #if !UCONFIG_NO_FORMATTING */
317 #endif // __FORMATTEDVALUE_H__
icu::ConstrainedFieldPosition::getCategory
int32_t getCategory() const
Gets the field category for the current position.
Definition: formattedvalue.h:123
uformattedvalue.h
C API: Abstract operations for localized strings.
icu::ConstrainedFieldPosition::getField
int32_t getField() const
Gets the field for the current position.
Definition: formattedvalue.h:136
fpositer.h
C++ API: FieldPosition Iterator.
unistr.h
C++ API: Unicode String.
appendable.h
C++ API: Appendable class: Sink for Unicode code points and 16-bit code units (char16_ts).
icu::FormattedValue
An abstract formatted value: a string with associated field attributes.
Definition: formattedvalue.h:241
UFIELD_CATEGORY_UNDEFINED
For an undefined field category.
Definition: uformattedvalue.h:41
icu::ConstrainedFieldPosition::getStart
int32_t getStart() const
Gets the INCLUSIVE start index for the current position.
Definition: formattedvalue.h:148
U_I18N_API
#define U_I18N_API
Set to export library symbols from inside the i18n library, and to import them from outside.
Definition: utypes.h:301
U_NAMESPACE_BEGIN
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition: uversion.h:137
icu::ConstrainedFieldPosition::getInt64IterationContext
int64_t getInt64IterationContext() const
Gets an int64 that FormattedValue implementations may use for storage.
Definition: formattedvalue.h:179
icu::ConstrainedFieldPosition
Represents a span of a string containing a given field.
Definition: formattedvalue.h:40
U_NAMESPACE_END
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
Definition: uversion.h:138
UErrorCode
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers,...
Definition: utypes.h:401
utypes.h
Basic definitions for ICU, for both C and C++ APIs.
icu::UnicodeString
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition: unistr.h:289
icu::UMemory
UMemory is the common ICU base class.
Definition: uobject.h:112
UBool
int8_t UBool
The ICU boolean type.
Definition: umachine.h:225
icu::Appendable
Base class for objects to which Unicode characters and strings can be appended.
Definition: appendable.h:51
icu::ConstrainedFieldPosition::getLimit
int32_t getLimit() const
Gets the EXCLUSIVE end index stored for the current position.
Definition: formattedvalue.h:160