ICU 65.1  65.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"
17 
18 U_NAMESPACE_BEGIN
19 
29 #ifndef U_HIDE_DRAFT_API
30 
44  public:
45 
54 
57 
66  void reset();
67 
90  void constrainCategory(int32_t category);
91 
115  void constrainField(int32_t category, int32_t field);
116 
126  inline int32_t getCategory() const {
127  return fCategory;
128  }
129 
139  inline int32_t getField() const {
140  return fField;
141  }
142 
151  inline int32_t getStart() const {
152  return fStart;
153  }
154 
163  inline int32_t getLimit() const {
164  return fLimit;
165  }
166 
171 
182  inline int64_t getInt64IterationContext() const {
183  return fContext;
184  }
185 
194  void setInt64IterationContext(int64_t context);
195 
206  UBool matchesField(int32_t category, int32_t field) const;
207 
222  void setState(
223  int32_t category,
224  int32_t field,
225  int32_t start,
226  int32_t limit);
227 
228  private:
229  int64_t fContext = 0LL;
230  int32_t fField = 0;
231  int32_t fStart = 0;
232  int32_t fLimit = 0;
233  int32_t fCategory = UFIELD_CATEGORY_UNDEFINED;
234  int8_t fConstraint = 0;
235 };
236 
237 #endif // U_HIDE_DRAFT_API
238 
245 class U_I18N_API FormattedValue /* not : public UObject because this is an interface/mixin class */ {
246  public:
248  virtual ~FormattedValue();
249 
260  virtual UnicodeString toString(UErrorCode& status) const = 0;
261 
276  virtual UnicodeString toTempString(UErrorCode& status) const = 0;
277 
289  virtual Appendable& appendTo(Appendable& appendable, UErrorCode& status) const = 0;
290 
291 #ifndef U_HIDE_DRAFT_API
292 
314  virtual UBool nextPosition(ConstrainedFieldPosition& cfpos, UErrorCode& status) const = 0;
315 #endif
316 };
317 
318 
319 U_NAMESPACE_END
320 
321 #endif /* #if !UCONFIG_NO_FORMATTING */
322 
323 #endif /* U_SHOW_CPLUSPLUS_API */
324 
325 #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
int64_t getInt64IterationContext() const
Gets an int64 that FormattedValue implementations may use for storage.
Represents a span of a string containing a given field.
UErrorCode
Standard ICU4C error code type, a substitute for exceptions.
Definition: utypes.h:415
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:294
UMemory is the common ICU base class.
Definition: uobject.h:115
int8_t UBool
The ICU boolean type.
Definition: umachine.h:260
Base class for objects to which Unicode characters and strings can be appended.
Definition: appendable.h:54
int32_t getLimit() const
Gets the EXCLUSIVE end index stored for the current position.