1 // © 2024 and later: Unicode, Inc. and others. 2 // License & terms of use: http://www.unicode.org/copyright.html 3 4 #include "unicode/utypes.h" 5 6 #if !UCONFIG_NO_FORMATTING 7 8 #if !UCONFIG_NO_MF2 9 10 #include "unicode/messageformat2_arguments.h" 11 #include "unicode/messageformat2_data_model_names.h" 12 #include "uvector.h" // U_ASSERT 13 14 U_NAMESPACE_BEGIN 15 16 namespace message2 { 17 18 using namespace data_model; 19 20 // ------------------------------------------------------ 21 // MessageArguments 22 23 using Arguments = MessageArguments; 24 getArgument(const VariableName & arg,UErrorCode & errorCode) const25 const Formattable* Arguments::getArgument(const VariableName& arg, UErrorCode& errorCode) const { 26 if (U_SUCCESS(errorCode)) { 27 U_ASSERT(argsLen == 0 || arguments.isValid()); 28 for (int32_t i = 0; i < argsLen; i++) { 29 if (argumentNames[i] == arg) { 30 return &arguments[i]; 31 } 32 } 33 errorCode = U_ILLEGAL_ARGUMENT_ERROR; 34 } 35 return nullptr; 36 } 37 ~MessageArguments()38 MessageArguments::~MessageArguments() {} 39 40 // Message arguments 41 // ----------------- 42 operator =(MessageArguments && other)43 MessageArguments& MessageArguments::operator=(MessageArguments&& other) noexcept { 44 U_ASSERT(other.arguments.isValid() || other.argsLen == 0); 45 argsLen = other.argsLen; 46 if (argsLen != 0) { 47 argumentNames.adoptInstead(other.argumentNames.orphan()); 48 arguments.adoptInstead(other.arguments.orphan()); 49 } 50 return *this; 51 } 52 53 } // namespace message2 54 55 U_NAMESPACE_END 56 57 #endif /* #if !UCONFIG_NO_MF2 */ 58 59 #endif /* #if !UCONFIG_NO_FORMATTING */ 60