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"
15 
17 
41  public:
42 
51 
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 
314 
315 #endif /* U_HIDE_DRAFT_API */
316 #endif /* #if !UCONFIG_NO_FORMATTING */
317 #endif // __FORMATTEDVALUE_H__
int32_t getCategory() const
Gets the field category for the current position.
C API: Abstract operations for localized strings.
int32_t getField() const
Gets the field for the current position.
C++ API: FieldPosition Iterator.
C++ API: Unicode String.
C++ API: Appendable class: Sink for Unicode code points and 16-bit code units (char16_ts).
An abstract formatted value: a string with associated field attributes.
For an undefined field category.
int32_t getStart() const
Gets the INCLUSIVE start index for the current position.
#define U_I18N_API
Set to export library symbols from inside the i18n library, and to import them from outside...
Definition: utypes.h:301
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition: uversion.h:137
int64_t getInt64IterationContext() const
Gets an int64 that FormattedValue implementations may use for storage.
Represents a span of a string containing a given field.
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
Definition: uversion.h:138
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers...
Definition: utypes.h:401
Basic definitions for ICU, for both C and C++ APIs.
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition: unistr.h:289
UMemory is the common ICU base class.
Definition: uobject.h:112
int8_t UBool
The ICU boolean type.
Definition: umachine.h:225
Base class for objects to which Unicode characters and strings can be appended.
Definition: appendable.h:51
int32_t getLimit() const
Gets the EXCLUSIVE end index stored for the current position.