6 #ifndef MESSAGEFORMAT2_H 7 #define MESSAGEFORMAT2_H 9 #if U_SHOW_CPLUSPLUS_API 11 #if !UCONFIG_NO_NORMALIZATION 13 #if !UCONFIG_NO_FORMATTING 23 #include "unicode/messageformat2_data_model.h" 24 #include "unicode/messageformat2_function_registry.h" 28 #ifndef U_HIDE_DEPRECATED_API 159 U_MF_BEST_EFFORT = 0,
168 } UMFErrorHandlingBehavior;
182 bool hasPattern =
false;
183 bool hasDataModel =
false;
193 StaticErrors* errors;
198 bool signalErrors =
false;
332 friend class Builder;
333 friend class Checker;
335 friend class MessageContext;
347 void resolveSelectors(MessageContext&,
const Environment& env,
UErrorCode&, UVector&)
const;
349 void filterVariants(
const UVector&, UVector&,
UErrorCode&)
const;
351 void sortVariants(
const UVector&, UVector&,
UErrorCode&)
const;
353 void matchSelectorKeys(
const UVector&, MessageContext&, InternalValue* rv, UVector&,
UErrorCode&)
const;
356 void resolvePreferences(MessageContext&, UVector&, UVector&,
UErrorCode&)
const;
365 MessageContext& context,
368 [[nodiscard]] InternalValue* evalFunctionCall(
const FunctionName& functionName,
369 InternalValue* argument,
371 MessageContext& context,
374 [[nodiscard]] InternalValue* formatExpression(
const UnicodeString&,
379 [[nodiscard]]
FunctionOptions resolveOptions(
const Environment& env,
const OptionMap&, MessageContext&,
UErrorCode&)
const;
380 [[nodiscard]] InternalValue* formatOperand(
const UnicodeString&,
389 void formatSelectors(MessageContext& context,
const Environment& env,
UErrorCode &status,
UnicodeString& result)
const;
392 bool hasCustomMFFunctionRegistry()
const {
393 return (customMFFunctionRegistry !=
nullptr);
399 const MFFunctionRegistry& getCustomMFFunctionRegistry()
const;
401 bool isCustomFormatter(
const FunctionName&)
const;
402 FormatterFactory* lookupFormatterFactory(
const FunctionName&,
UErrorCode& status)
const;
403 bool isBuiltInSelector(
const FunctionName&)
const;
404 bool isBuiltInFormatter(
const FunctionName&)
const;
405 bool isCustomSelector(
const FunctionName&)
const;
406 const SelectorFactory* lookupSelectorFactory(MessageContext&,
const FunctionName&,
UErrorCode&)
const;
407 bool isSelector(
const FunctionName& fn)
const {
return isBuiltInSelector(fn) || isCustomSelector(fn); }
408 bool isFormatter(
const FunctionName& fn)
const {
return isBuiltInFormatter(fn) || isCustomFormatter(fn); }
409 const Formatter* lookupFormatter(
const FunctionName&,
UErrorCode&)
const;
411 Selector* getSelector(MessageContext&,
const FunctionName&,
UErrorCode&)
const;
412 Formatter* getFormatter(
const FunctionName&,
UErrorCode&)
const;
413 bool getDefaultFormatterNameByType(
const UnicodeString&, FunctionName&)
const;
416 void checkDeclarations(MessageContext&, Environment*&,
UErrorCode&)
const;
417 void check(MessageContext&,
const Environment&,
const data_model::Expression&,
UErrorCode&)
const;
418 void check(MessageContext&,
const Environment&,
const data_model::Operand&,
UErrorCode&)
const;
419 void check(MessageContext&,
const Environment&,
const OptionMap&,
UErrorCode&)
const;
422 void clearErrors()
const;
423 void cleanup() noexcept;
429 MFFunctionRegistry standardMFFunctionRegistry;
440 const MFFunctionRegistry* customMFFunctionRegistry;
443 MFDataModel dataModel;
446 UnicodeString normalizedInput;
453 StaticErrors* errors =
nullptr;
461 bool signalErrors = false;
469 #endif // U_HIDE_DEPRECATED_API 479 #endif // MESSAGEFORMAT2_H
#define U_SUCCESS(x)
Does the error code indicate success?
The MessageArguments class represents the named arguments to a message.
C++ API: New API for Unicode Normalization.
The Literal class corresponds to the literal nonterminal in the MessageFormat 2 grammar, https://github.com/unicode-org/message-format-wg/blob/main/spec/message.abnf and the Literal interface defined in // https://github.com/unicode-org/message-format-wg/blob/main/spec/data-model.md#expressions.
#define U_I18N_API
Set to export library symbols from inside the i18n library, and to import them from outside...
#define U_I18N_API_CLASS
Set to export library symbols from inside the i18n library, and to import them from outside...
Requested operation not supported in current context.
The Operand class corresponds to the operand nonterminal in the MessageFormat 2 grammar, https://github.com/unicode-org/message-format-wg/blob/main/spec/message.abnf .
The Expression class corresponds to the expression nonterminal in the MessageFormat 2 grammar and the...
UErrorCode
Standard ICU4C error code type, a substitute for exceptions.
Structure encapsulating named options passed to a custom selector or formatter.
The MFDataModel class describes a parsed representation of the text of a message. ...
A UParseError struct is used to returned detailed information about parsing errors.
Basic definitions for ICU, for both C and C++ APIs.
A Pattern is a sequence of formattable parts.
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Defines mappings from names of formatters and selectors to functions implementing them...
UObject is the common ICU "boilerplate" class.
A Locale object represents a specific geographical, political, or cultural region.