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