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;
330 friend class Builder;
331 friend class Checker;
333 friend class MessageContext;
345 void resolveSelectors(MessageContext&,
const Environment& env,
UErrorCode&, UVector&)
const;
347 void filterVariants(
const UVector&, UVector&,
UErrorCode&)
const;
349 void sortVariants(
const UVector&, UVector&,
UErrorCode&)
const;
351 void matchSelectorKeys(
const UVector&, MessageContext&, InternalValue* rv, UVector&,
UErrorCode&)
const;
354 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 Environment&,
378 [[nodiscard]]
FunctionOptions resolveOptions(
const Environment& env,
const OptionMap&, MessageContext&,
UErrorCode&)
const;
381 void formatSelectors(MessageContext& context,
const Environment& env,
UErrorCode &status,
UnicodeString& result)
const;
384 bool hasCustomMFFunctionRegistry()
const {
385 return (customMFFunctionRegistry !=
nullptr);
391 const MFFunctionRegistry& getCustomMFFunctionRegistry()
const;
393 bool isCustomFormatter(
const FunctionName&)
const;
394 FormatterFactory* lookupFormatterFactory(
const FunctionName&,
UErrorCode& status)
const;
395 bool isBuiltInSelector(
const FunctionName&)
const;
396 bool isBuiltInFormatter(
const FunctionName&)
const;
397 bool isCustomSelector(
const FunctionName&)
const;
398 const SelectorFactory* lookupSelectorFactory(MessageContext&,
const FunctionName&,
UErrorCode&)
const;
399 bool isSelector(
const FunctionName& fn)
const {
return isBuiltInSelector(fn) || isCustomSelector(fn); }
400 bool isFormatter(
const FunctionName& fn)
const {
return isBuiltInFormatter(fn) || isCustomFormatter(fn); }
401 const Formatter* lookupFormatter(
const FunctionName&,
UErrorCode&)
const;
403 Selector* getSelector(MessageContext&,
const FunctionName&,
UErrorCode&)
const;
404 Formatter* getFormatter(
const FunctionName&,
UErrorCode&)
const;
405 bool getDefaultFormatterNameByType(
const UnicodeString&, FunctionName&)
const;
408 void checkDeclarations(MessageContext&, Environment*&,
UErrorCode&)
const;
409 void check(MessageContext&,
const Environment&,
const data_model::Expression&,
UErrorCode&)
const;
410 void check(MessageContext&,
const Environment&,
const data_model::Operand&,
UErrorCode&)
const;
411 void check(MessageContext&,
const Environment&,
const OptionMap&,
UErrorCode&)
const;
414 void clearErrors()
const;
415 void cleanup() noexcept;
421 MFFunctionRegistry standardMFFunctionRegistry;
432 const MFFunctionRegistry* customMFFunctionRegistry;
435 MFDataModel dataModel;
438 UnicodeString normalizedInput;
445 StaticErrors* errors =
nullptr;
453 bool signalErrors = false;
456 const Normalizer2* nfcNormalizer =
nullptr;
A Locale object represents a specific geographical, political, or cultural region.
UObject is the common ICU "boilerplate" class.
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Structure encapsulating named options passed to a custom selector or formatter.
The MFDataModel class describes a parsed representation of the text of a message.
Defines mappings from names of formatters and selectors to functions implementing them.
The MessageArguments class represents the named arguments to a message.
The Expression class corresponds to the expression nonterminal in the MessageFormat 2 grammar and the...
The Literal class corresponds to the literal nonterminal in the MessageFormat 2 grammar,...
The Operand class corresponds to the operand nonterminal in the MessageFormat 2 grammar,...
A Pattern is a sequence of formattable parts.
C++ API: New API for Unicode Normalization.
A UParseError struct is used to returned detailed information about parsing errors.
Basic definitions for ICU, for both C and C++ APIs.
UErrorCode
Standard ICU4C error code type, a substitute for exceptions.
@ U_UNSUPPORTED_ERROR
Requested operation not supported in current context.
#define U_SUCCESS(x)
Does the error code indicate success?
#define U_I18N_API
Set to export library symbols from inside the i18n library, and to import them from outside.