6 #ifndef MESSAGEFORMAT2_H
7 #define MESSAGEFORMAT2_H
9 #if U_SHOW_CPLUSPLUS_API
11 #if !UCONFIG_NO_FORMATTING
21 #include "unicode/messageformat2_data_model.h"
22 #include "unicode/messageformat2_function_registry.h"
25 #ifndef U_HIDE_DEPRECATED_API
33 class ResolvedSelector;
154 bool hasPattern =
false;
155 bool hasDataModel =
false;
165 StaticErrors* errors;
269 friend class Builder;
270 friend class MessageContext;
285 void resolveSelectors(MessageContext&,
const Environment& env,
UErrorCode&, UVector&)
const;
287 void filterVariants(
const UVector&, UVector&,
UErrorCode&)
const;
289 void sortVariants(
const UVector&, UVector&,
UErrorCode&)
const;
291 void matchSelectorKeys(
const UVector&, MessageContext&, ResolvedSelector&& rv, UVector&,
UErrorCode&)
const;
294 void resolvePreferences(MessageContext&, UVector&, UVector&,
UErrorCode&)
const;
302 MessageContext& context,
308 MessageContext& context,
314 [[nodiscard]]
FunctionOptions resolveOptions(
const Environment& env,
const OptionMap&, MessageContext&,
UErrorCode&)
const;
317 void formatSelectors(MessageContext& context,
const Environment& env,
UErrorCode &status,
UnicodeString& result)
const;
320 bool hasCustomMFFunctionRegistry()
const {
321 return (customMFFunctionRegistry !=
nullptr);
327 const MFFunctionRegistry& getCustomMFFunctionRegistry()
const;
329 bool isCustomFormatter(
const FunctionName&)
const;
330 FormatterFactory* lookupFormatterFactory(
const FunctionName&,
UErrorCode& status)
const;
331 bool isBuiltInSelector(
const FunctionName&)
const;
332 bool isBuiltInFormatter(
const FunctionName&)
const;
333 bool isCustomSelector(
const FunctionName&)
const;
334 const SelectorFactory* lookupSelectorFactory(MessageContext&,
const FunctionName&,
UErrorCode&)
const;
335 bool isSelector(
const FunctionName& fn)
const {
return isBuiltInSelector(fn) || isCustomSelector(fn); }
336 bool isFormatter(
const FunctionName& fn)
const {
return isBuiltInFormatter(fn) || isCustomFormatter(fn); }
337 const Formatter* lookupFormatter(
const FunctionName&,
UErrorCode&)
const;
339 Selector* getSelector(MessageContext&,
const FunctionName&,
UErrorCode&)
const;
340 Formatter* getFormatter(
const FunctionName&,
UErrorCode&)
const;
341 bool getDefaultFormatterNameByType(
const UnicodeString&, FunctionName&)
const;
344 void checkDeclarations(MessageContext&, Environment*&,
UErrorCode&)
const;
345 void check(MessageContext&,
const Environment&,
const data_model::Expression&,
UErrorCode&)
const;
346 void check(MessageContext&,
const Environment&,
const data_model::Operand&,
UErrorCode&)
const;
347 void check(MessageContext&,
const Environment&,
const OptionMap&,
UErrorCode&)
const;
350 void clearErrors()
const;
351 void cleanup() noexcept;
357 MFFunctionRegistry standardMFFunctionRegistry;
368 const MFFunctionRegistry* customMFFunctionRegistry;
371 MFDataModel dataModel;
374 UnicodeString normalizedInput;
381 StaticErrors* errors;
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.
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.