From b215909ee4f6ec4b8ca92cc799a01216297a306b Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Fri, 29 Mar 2024 14:54:26 -0700 Subject: [PATCH] ICU-22261 Refactor MF2 attributes and options parsing code Previously, there were separate overrides for the options and attributes parsing methods in the parser that were used in different context. (Options can appear in Operator and Markup, while attributes can appear in Expression and Markup.) This is a refactoring that eliminates this duplicated code. To enable it, a builder is added for the internal OptionMap type. Separately, this patch also explicitly deletes copy constructors and copy assignment operators for all Builder classes; a bug in an earlier version of this patch caused me to notice this hadn't been done. Also explicitly deletes move constructors/assignment operators with the exception of OptionMap::Builder (OptionMap is non-public, so that shouldn't cause confusion). --- .../source/i18n/messageformat2_data_model.cpp | 178 +++++++-------- icu4c/source/i18n/messageformat2_parser.cpp | 202 ++---------------- icu4c/source/i18n/messageformat2_parser.h | 42 +++- .../i18n/unicode/messageformat2_data_model.h | 96 +++++---- 4 files changed, 208 insertions(+), 310 deletions(-) diff --git a/icu4c/source/i18n/messageformat2_data_model.cpp b/icu4c/source/i18n/messageformat2_data_model.cpp index b29f29e81342..822d20c3b84d 100644 --- a/icu4c/source/i18n/messageformat2_data_model.cpp +++ b/icu4c/source/i18n/messageformat2_data_model.cpp @@ -262,7 +262,7 @@ OptionMap::OptionMap(const UVector& opts, UErrorCode& status) { len = opts.size(); Option* result = copyVectorToArray