Skip to content

Commit

Permalink
Fix doc comments and move InternalValue to a private header file
Browse files Browse the repository at this point in the history
  • Loading branch information
catamorphism committed Oct 1, 2024
1 parent 71209d9 commit c8d28b3
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 26 deletions.
22 changes: 22 additions & 0 deletions icu4c/source/i18n/messageformat2_evaluation.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
25 changes: 1 addition & 24 deletions icu4c/source/i18n/unicode/messageformat2.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
* <p>MessageFormatter is a Technical Preview API implementing MessageFormat 2.0.
Expand Down
12 changes: 10 additions & 2 deletions icu4c/source/i18n/unicode/messageformat2_formattable.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand Down

0 comments on commit c8d28b3

Please sign in to comment.