ICU 64.2
64.2
|
Represents a span of a string containing a given field. More...
#include <formattedvalue.h>
Public Member Functions | |
ConstrainedFieldPosition () | |
Initializes a ConstrainedFieldPosition. More... | |
~ConstrainedFieldPosition () | |
void | reset () |
Resets this ConstrainedFieldPosition to its initial state, as if it were newly created: More... | |
void | constrainCategory (int32_t category) |
Sets a constraint on the field category. More... | |
void | constrainField (int32_t category, int32_t field) |
Sets a constraint on the category and field. More... | |
int32_t | getCategory () const |
Gets the field category for the current position. More... | |
int32_t | getField () const |
Gets the field for the current position. More... | |
int32_t | getStart () const |
Gets the INCLUSIVE start index for the current position. More... | |
int32_t | getLimit () const |
Gets the EXCLUSIVE end index stored for the current position. More... | |
int64_t | getInt64IterationContext () const |
Gets an int64 that FormattedValue implementations may use for storage. More... | |
void | setInt64IterationContext (int64_t context) |
Sets an int64 that FormattedValue implementations may use for storage. More... | |
UBool | matchesField (int32_t category, int32_t field) const |
Determines whether a given field should be included given the constraints. More... | |
void | setState (int32_t category, int32_t field, int32_t start, int32_t limit) |
Sets new values for the primary public getters. More... | |
Represents a span of a string containing a given field.
This class differs from FieldPosition in the following ways:
This class is not intended for public subclassing.
Definition at line 40 of file formattedvalue.h.
icu::ConstrainedFieldPosition::ConstrainedFieldPosition | ( | ) |
Initializes a ConstrainedFieldPosition.
By default, the ConstrainedFieldPosition has no iteration constraints.
icu::ConstrainedFieldPosition::~ConstrainedFieldPosition | ( | ) |
void icu::ConstrainedFieldPosition::constrainCategory | ( | int32_t | category | ) |
Sets a constraint on the field category.
When this instance of ConstrainedFieldPosition is passed to FormattedValue::nextPosition, positions are skipped unless they have the given category.
Any previously set constraints are cleared.
For example, to loop over only the number-related fields:
ConstrainedFieldPosition cfpos; cfpos.constrainCategory(UFIELDCATEGORY_NUMBER_FORMAT); while (fmtval.nextPosition(cfpos, status)) { // handle the number-related field position }
Changing the constraint while in the middle of iterating over a FormattedValue does not generally have well-defined behavior.
category | The field category to fix when iterating. |
void icu::ConstrainedFieldPosition::constrainField | ( | int32_t | category, |
int32_t | field | ||
) |
Sets a constraint on the category and field.
When this instance of ConstrainedFieldPosition is passed to FormattedValue::nextPosition, positions are skipped unless they have the given category and field.
Any previously set constraints are cleared.
For example, to loop over all grouping separators:
ConstrainedFieldPosition cfpos; cfpos.constrainField(UFIELDCATEGORY_NUMBER_FORMAT, UNUM_GROUPING_SEPARATOR_FIELD); while (fmtval.nextPosition(cfpos, status)) { // handle the grouping separator position }
Changing the constraint while in the middle of iterating over a FormattedValue does not generally have well-defined behavior.
category | The field category to fix when iterating. |
field | The field to fix when iterating. |
|
inline |
Gets the field category for the current position.
The return value is well-defined only after FormattedValue::nextPosition returns TRUE.
Definition at line 123 of file formattedvalue.h.
|
inline |
Gets the field for the current position.
The return value is well-defined only after FormattedValue::nextPosition returns TRUE.
Definition at line 136 of file formattedvalue.h.
|
inline |
Gets an int64 that FormattedValue implementations may use for storage.
The initial value is zero.
Users of FormattedValue should not need to call this method.
Definition at line 179 of file formattedvalue.h.
References UFIELD_CATEGORY_UNDEFINED.
|
inline |
Gets the EXCLUSIVE end index stored for the current position.
The return value is well-defined only after FormattedValue::nextPosition returns TRUE.
Definition at line 160 of file formattedvalue.h.
|
inline |
Gets the INCLUSIVE start index for the current position.
The return value is well-defined only after FormattedValue::nextPosition returns TRUE.
Definition at line 148 of file formattedvalue.h.
UBool icu::ConstrainedFieldPosition::matchesField | ( | int32_t | category, |
int32_t | field | ||
) | const |
Determines whether a given field should be included given the constraints.
Intended to be used by FormattedValue implementations.
category | The category to test. |
field | The field to test. |
void icu::ConstrainedFieldPosition::reset | ( | ) |
Resets this ConstrainedFieldPosition to its initial state, as if it were newly created:
void icu::ConstrainedFieldPosition::setInt64IterationContext | ( | int64_t | context | ) |
Sets an int64 that FormattedValue implementations may use for storage.
Intended to be used by FormattedValue implementations.
context | The new iteration context. |
void icu::ConstrainedFieldPosition::setState | ( | int32_t | category, |
int32_t | field, | ||
int32_t | start, | ||
int32_t | limit | ||
) |
Sets new values for the primary public getters.
Intended to be used by FormattedValue implementations.
It is up to the implementation to ensure that the user-requested constraints are satisfied. This method does not check!
category | The new field category. |
field | The new field. |
start | The new inclusive start index. |
limit | The new exclusive end index. |