formattedvalue.h
Go to the documentation of this file.
// © 2018 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
#ifndef __FORMATTEDVALUE_H__
#define __FORMATTEDVALUE_H__
#include "unicode/utypes.h"
#if U_SHOW_CPLUSPLUS_API
#if !UCONFIG_NO_FORMATTING
#include "unicode/appendable.h"
#include "unicode/fpositer.h"
#include "unicode/unistr.h"
#include "unicode/uformattedvalue.h"
U_NAMESPACE_BEGIN
class U_I18N_API ConstrainedFieldPosition : public UMemory {
public:
ConstrainedFieldPosition();
~ConstrainedFieldPosition();
void reset();
void constrainCategory(int32_t category);
void constrainField(int32_t category, int32_t field);
inline int32_t getCategory() const {
return fCategory;
}
inline int32_t getField() const {
return fField;
}
inline int32_t getStart() const {
return fStart;
}
inline int32_t getLimit() const {
return fLimit;
}
inline int64_t getInt64IterationContext() const {
return fContext;
}
void setInt64IterationContext(int64_t context);
UBool matchesField(int32_t category, int32_t field) const;
void setState(
int32_t category,
int32_t field,
int32_t start,
int32_t limit);
private:
int64_t fContext = 0LL;
int32_t fField = 0;
int32_t fStart = 0;
int32_t fLimit = 0;
int32_t fCategory = UFIELD_CATEGORY_UNDEFINED;
int8_t fConstraint = 0;
};
class U_I18N_API FormattedValue /* not : public UObject because this is an interface/mixin class */ {
public:
virtual ~FormattedValue();
virtual UnicodeString toString(UErrorCode& status) const = 0;
virtual UnicodeString toTempString(UErrorCode& status) const = 0;
virtual Appendable& appendTo(Appendable& appendable, UErrorCode& status) const = 0;
virtual UBool nextPosition(ConstrainedFieldPosition& cfpos, UErrorCode& status) const = 0;
};
U_NAMESPACE_END
#endif /* #if !UCONFIG_NO_FORMATTING */
#endif /* U_SHOW_CPLUSPLUS_API */
#endif // __FORMATTEDVALUE_H__
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
Represents a span of a string containing a given field.
Definition: formattedvalue.h:41
icu::ConstrainedFieldPosition::~ConstrainedFieldPosition
~ConstrainedFieldPosition()
icu::ConstrainedFieldPosition::reset
void reset()
Resets this ConstrainedFieldPosition to its initial state, as if it were newly created:
icu::ConstrainedFieldPosition::constrainField
void constrainField(int32_t category, int32_t field)
Sets a constraint on the category and field.
icu::ConstrainedFieldPosition::setState
void setState(int32_t category, int32_t field, int32_t start, int32_t limit)
Sets new values for the primary public getters.
icu::ConstrainedFieldPosition::getStart
int32_t getStart() const
Gets the INCLUSIVE start index for the current position.
Definition: formattedvalue.h:149
icu::ConstrainedFieldPosition::constrainCategory
void constrainCategory(int32_t category)
Sets a constraint on the field category.
icu::ConstrainedFieldPosition::getCategory
int32_t getCategory() const
Gets the field category for the current position.
Definition: formattedvalue.h:124
icu::ConstrainedFieldPosition::getLimit
int32_t getLimit() const
Gets the EXCLUSIVE end index stored for the current position.
Definition: formattedvalue.h:161
icu::ConstrainedFieldPosition::ConstrainedFieldPosition
ConstrainedFieldPosition()
Initializes a ConstrainedFieldPosition.
icu::ConstrainedFieldPosition::setInt64IterationContext
void setInt64IterationContext(int64_t context)
Sets an int64 that FormattedValue implementations may use for storage.
icu::ConstrainedFieldPosition::getInt64IterationContext
int64_t getInt64IterationContext() const
Gets an int64 that FormattedValue implementations may use for storage.
Definition: formattedvalue.h:180
icu::ConstrainedFieldPosition::getField
int32_t getField() const
Gets the field for the current position.
Definition: formattedvalue.h:137
icu::ConstrainedFieldPosition::matchesField
UBool matchesField(int32_t category, int32_t field) const
Determines whether a given field should be included given the constraints.
icu::FormattedValue
An abstract formatted value: a string with associated field attributes.
Definition: formattedvalue.h:241
icu::FormattedValue::nextPosition
virtual UBool nextPosition(ConstrainedFieldPosition &cfpos, UErrorCode &status) const =0
Iterates over field positions in the FormattedValue.
icu::FormattedValue::toString
virtual UnicodeString toString(UErrorCode &status) const =0
Returns the formatted string as a self-contained UnicodeString.
icu::FormattedValue::toTempString
virtual UnicodeString toTempString(UErrorCode &status) const =0
Returns the formatted string as a read-only alias to memory owned by the FormattedValue.
icu::FormattedValue::~FormattedValue
virtual ~FormattedValue()
icu::FormattedValue::appendTo
virtual Appendable & appendTo(Appendable &appendable, UErrorCode &status) const =0
Appends the formatted string to an Appendable.
icu::UMemory
UMemory is the common ICU base class.
Definition: uobject.h:115
icu::UnicodeString
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition: unistr.h:296
fpositer.h
C++ API: FieldPosition Iterator.
uformattedvalue.h
C API: Abstract operations for localized strings.
UFIELD_CATEGORY_UNDEFINED
@ UFIELD_CATEGORY_UNDEFINED
For an undefined field category.
Definition: uformattedvalue.h:40
UBool
int8_t UBool
The ICU boolean type, a signed-byte integer.
Definition: umachine.h:247
unistr.h
C++ API: Unicode String.
utypes.h
Basic definitions for ICU, for both C and C++ APIs.
UErrorCode
UErrorCode
Standard ICU4C error code type, a substitute for exceptions.
Definition: utypes.h:430
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:316