+ prevIndex = part.getLimit();
+ } else if (type == UMSGPAT_PART_TYPE_ARG_START) {
+ sb.append(msgString, prevIndex, index - prevIndex);
+ prevIndex = index;
+ i = msgPattern.getLimitPartIndex(i);
+ index = msgPattern.getPart(i).getLimit();
+ MessageImpl::appendReducedApostrophes(msgString, prevIndex, index, sb);
+ prevIndex = index;
+ }
+ }
+ if (sb.indexOf(LEFT_CURLY_BRACE) >= 0) {
+ UnicodeString emptyPattern; // gcc 3.3.3 fails with "UnicodeString()" as the first parameter.
+ MessageFormat subMsgFormat(emptyPattern, fLocale, success);
+ subMsgFormat.applyPattern(sb, UMSGPAT_APOS_DOUBLE_REQUIRED, NULL, success);
+ subMsgFormat.format(0, 0, arguments, argumentNames, cnt, appendTo, NULL, success);
+ } else {
+ appendTo.append(sb);
+ }
+}
+
+
+UnicodeString MessageFormat::getLiteralStringUntilNextArgument(int32_t from) const {
+ const UnicodeString& msgString=msgPattern.getPatternString();
+ int32_t prevIndex=msgPattern.getPart(from).getLimit();
+ UnicodeString b;
+ for (int32_t i = from + 1; ; ++i) {
+ const MessagePattern::Part& part = msgPattern.getPart(i);
+ const UMessagePatternPartType type=part.getType();
+ int32_t index=part.getIndex();
+ b.append(msgString, prevIndex, index - prevIndex);
+ if(type==UMSGPAT_PART_TYPE_ARG_START || type==UMSGPAT_PART_TYPE_MSG_LIMIT) {
+ return b;
+ }
+ // Unexpected Part "part" in parsed message.
+ U_ASSERT(type==UMSGPAT_PART_TYPE_SKIP_SYNTAX || type==UMSGPAT_PART_TYPE_INSERT_CHAR);
+ prevIndex=part.getLimit();
+ }
+}
+
+
+FieldPosition* MessageFormat::updateMetaData(AppendableWrapper& /*dest*/, int32_t /*prevLength*/,
+ FieldPosition* /*fp*/, const Formattable* /*argId*/) const {
+ // Unlike in Java, there are no field attributes defined for MessageFormat. Do nothing.
+ return NULL;
+ /*
+ if (fp != NULL && Field.ARGUMENT.equals(fp.getFieldAttribute())) {
+ fp->setBeginIndex(prevLength);
+ fp->setEndIndex(dest.get_length());
+ return NULL;
+ }
+ return fp;
+ */
+}
+
+void MessageFormat::copyObjects(const MessageFormat& that, UErrorCode& ec) {
+ // Deep copy pointer fields.
+ // We need not copy the formatAliases because they are re-filled
+ // in each getFormats() call.
+ // The defaultNumberFormat, defaultDateFormat and pluralProvider.rules
+ // also get created on demand.
+ argTypeCount = that.argTypeCount;
+ if (argTypeCount > 0) {
+ if (!allocateArgTypes(argTypeCount, ec)) {
+ return;
+ }
+ uprv_memcpy(argTypes, that.argTypes, argTypeCount * sizeof(argTypes[0]));
+ }
+ if (cachedFormatters != NULL) {
+ uhash_removeAll(cachedFormatters);
+ }
+ if (customFormatArgStarts != NULL) {
+ uhash_removeAll(customFormatArgStarts);
+ }
+ if (that.cachedFormatters) {
+ if (cachedFormatters == NULL) {
+ cachedFormatters=uhash_open(uhash_hashLong, uhash_compareLong,
+ equalFormatsForHash, &ec);
+ if (U_FAILURE(ec)) {
+ return;