File indexing completed on 2026-01-07 10:23:59
0001
0002
0003
0004 #include "unicode/utypes.h"
0005
0006 #ifndef MESSAGEFORMAT2_ARGUMENTS_H
0007 #define MESSAGEFORMAT2_ARGUMENTS_H
0008
0009 #if U_SHOW_CPLUSPLUS_API
0010
0011 #if !UCONFIG_NO_FORMATTING
0012
0013 #if !UCONFIG_NO_MF2
0014
0015
0016
0017
0018
0019
0020 #include "unicode/messageformat2_data_model_names.h"
0021 #include "unicode/messageformat2_formattable.h"
0022 #include "unicode/unistr.h"
0023
0024 #ifndef U_HIDE_DEPRECATED_API
0025
0026 #include <map>
0027
0028 U_NAMESPACE_BEGIN
0029
0030
0031
0032
0033
0034
0035
0036 #if U_PF_WINDOWS <= U_PLATFORM && U_PLATFORM <= U_PF_CYGWIN
0037 template class U_I18N_API LocalPointerBase<UnicodeString>;
0038 template class U_I18N_API LocalPointerBase<message2::Formattable>;
0039 template class U_I18N_API LocalArray<UnicodeString>;
0040 template class U_I18N_API LocalArray<message2::Formattable>;
0041 #endif
0042
0043
0044 namespace message2 {
0045
0046 class MessageContext;
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059 class U_I18N_API MessageArguments : public UObject {
0060 public:
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072 MessageArguments(const std::map<UnicodeString, Formattable>& args, UErrorCode& status) {
0073 if (U_FAILURE(status)) {
0074 return;
0075 }
0076 argumentNames = LocalArray<UnicodeString>(new UnicodeString[argsLen = static_cast<int32_t>(args.size())]);
0077 arguments = LocalArray<Formattable>(new Formattable[argsLen]);
0078 if (!argumentNames.isValid() || !arguments.isValid()) {
0079 status = U_MEMORY_ALLOCATION_ERROR;
0080 return;
0081 }
0082 int32_t i = 0;
0083 for (auto iter = args.begin(); iter != args.end(); ++iter) {
0084 argumentNames[i] = iter->first;
0085 arguments[i] = iter->second;
0086 i++;
0087 }
0088 }
0089
0090
0091
0092
0093
0094
0095
0096 MessageArguments& operator=(MessageArguments&&) noexcept;
0097
0098
0099
0100
0101
0102
0103
0104 MessageArguments() = default;
0105
0106
0107
0108
0109
0110
0111 virtual ~MessageArguments();
0112 private:
0113 friend class MessageContext;
0114
0115 const Formattable* getArgument(const data_model::VariableName&, UErrorCode&) const;
0116
0117
0118
0119 LocalArray<UnicodeString> argumentNames;
0120 LocalArray<Formattable> arguments;
0121 int32_t argsLen = 0;
0122 };
0123
0124 }
0125
0126 U_NAMESPACE_END
0127
0128 #endif
0129
0130 #endif
0131
0132 #endif
0133
0134 #endif
0135
0136 #endif
0137
0138