diff --git a/icu4c/source/i18n/messageformat2_evaluation.h b/icu4c/source/i18n/messageformat2_evaluation.h index 82655cf7149b..bed6c197dca5 100644 --- a/icu4c/source/i18n/messageformat2_evaluation.h +++ b/icu4c/source/i18n/messageformat2_evaluation.h @@ -32,6 +32,28 @@ namespace message2 { using namespace data_model; + // InternalValue + // Encodes an "either a fallback string or a FormattedPlaceholder" + class InternalValue : public UObject { + public: + bool isFallback() const { return !fallbackString.isEmpty(); } + InternalValue() : fallbackString("") {} + // Fallback constructor + explicit InternalValue(UnicodeString fb) : fallbackString(fb) {} + // Regular value constructor + explicit InternalValue(FormattedPlaceholder&& f) + : fallbackString(""), val(std::move(f)) {} + FormattedPlaceholder value() { return std::move(val); } + UnicodeString asFallback() const { return fallbackString; } + virtual ~InternalValue(); + InternalValue& operator=(InternalValue&&); + InternalValue(InternalValue&&); + private: + UnicodeString fallbackString; // Non-empty if fallback + // Otherwise, assumed to be a FormattedPlaceholder + FormattedPlaceholder val; + }; // class InternalValue + // PrioritizedVariant // For how this class is used, see the references to (integer, variant) tuples diff --git a/icu4c/source/i18n/unicode/messageformat2.h b/icu4c/source/i18n/unicode/messageformat2.h index c875f762d2ed..7a306d8b96b8 100644 --- a/icu4c/source/i18n/unicode/messageformat2.h +++ b/icu4c/source/i18n/unicode/messageformat2.h @@ -32,30 +32,7 @@ namespace message2 { class MessageContext; class ResolvedSelector; class StaticErrors; - - // Internal use only - // None = null operand - // String = fallback value - // FormattedPlaceholder = non-error value - class InternalValue : public UObject { - public: - bool isFallback() const { return !fallbackString.isEmpty(); } - InternalValue() : fallbackString("") {} - // Fallback constructor - explicit InternalValue(UnicodeString fb) : fallbackString(fb) {} - // Regular value constructor - explicit InternalValue(FormattedPlaceholder&& f) - : fallbackString(""), val(std::move(f)) {} - FormattedPlaceholder value() { return std::move(val); } - UnicodeString asFallback() const { return fallbackString; } - virtual ~InternalValue(); - InternalValue& operator=(InternalValue&&); - InternalValue(InternalValue&&); - private: - UnicodeString fallbackString; // Non-empty if fallback - // Otherwise, assumed to be a FormattedPlaceholder - FormattedPlaceholder val; - }; // class InternalValue + class InternalValue; /** *

MessageFormatter is a Technical Preview API implementing MessageFormat 2.0. diff --git a/icu4c/source/i18n/unicode/messageformat2_formattable.h b/icu4c/source/i18n/unicode/messageformat2_formattable.h index ed396dd87fa6..ab748d7c61d8 100644 --- a/icu4c/source/i18n/unicode/messageformat2_formattable.h +++ b/icu4c/source/i18n/unicode/messageformat2_formattable.h @@ -642,7 +642,7 @@ class U_I18N_API ResolvedFunctionOption : public UObject { * @internal ICU 75 technology preview * @deprecated This API is for technology preview only. */ - FormattedPlaceholder(const Formattable& input, const UnicodeString& fb, UErrorCode& status); + FormattedPlaceholder(const Formattable& input, const UnicodeString& fb, UErrorCode& errorCode); /** * Default constructor. Leaves the FormattedPlaceholder in a * valid but undefined state. @@ -651,7 +651,15 @@ class U_I18N_API ResolvedFunctionOption : public UObject { * @deprecated This API is for technology preview only. */ FormattedPlaceholder(); - // TODO + /** + * Returns true iff this FormattedPlaceholder represents a null operand + * (the absence of an operand). + * + * @return A boolean indicating whether this is a null operand. + * + * @internal ICU 75 technology preview + * @deprecated This API is for technology preview only. + */ UBool isNullOperand() const { return type == kNull; } /** * Returns a pointer to