* created by: Umesh P. Nair
*/
+#include "unicode/utypes.h"
+
+#if !UCONFIG_NO_FORMATTING
+
#include "cmemory.h"
#include "unicode/fpositer.h" // FieldPositionIterator
#include "unicode/listformatter.h"
UErrorCode& status) {
if (uprv_strcmp(lang, "es") == 0) {
// Spanish
- UnicodeString spanishYStr(TRUE, spanishY, -1);
+ UnicodeString spanishYStr(true, spanishY, -1);
bool twoIsY = two == spanishYStr;
bool endIsY = end == spanishYStr;
if (twoIsY || endIsY) {
- UnicodeString replacement(TRUE, spanishE, -1);
+ UnicodeString replacement(true, spanishE, -1);
return new ContextualHandler(
shouldChangeToE,
twoIsY ? replacement : two, two,
endIsY ? replacement : end, end, status);
}
- UnicodeString spanishOStr(TRUE, spanishO, -1);
+ UnicodeString spanishOStr(true, spanishO, -1);
bool twoIsO = two == spanishOStr;
bool endIsO = end == spanishOStr;
if (twoIsO || endIsO) {
- UnicodeString replacement(TRUE, spanishU, -1);
+ UnicodeString replacement(true, spanishU, -1);
return new ContextualHandler(
shouldChangeToU,
twoIsO ? replacement : two, two,
}
} else if (uprv_strcmp(lang, "he") == 0 || uprv_strcmp(lang, "iw") == 0) {
// Hebrew
- UnicodeString hebrewVavStr(TRUE, hebrewVav, -1);
+ UnicodeString hebrewVavStr(true, hebrewVav, -1);
bool twoIsVav = two == hebrewVavStr;
bool endIsVav = end == hebrewVavStr;
if (twoIsVav || endIsVav) {
- UnicodeString replacement(TRUE, hebrewVavDash, -1);
+ UnicodeString replacement(true, hebrewVavDash, -1);
return new ContextualHandler(
shouldChangeToVavDash,
twoIsVav ? replacement : two, two,
};
-#if !UCONFIG_NO_FORMATTING
class FormattedListData : public FormattedValueStringBuilderImpl {
public:
FormattedListData(UErrorCode&) : FormattedValueStringBuilderImpl(kUndefinedField) {}
FormattedListData::~FormattedListData() = default;
UPRV_FORMATTED_VALUE_SUBCLASS_AUTO_IMPL(FormattedList)
-#endif
static Hashtable* listPatternHash = nullptr;
static UBool U_CALLCONV uprv_listformatter_cleanup() {
delete listPatternHash;
listPatternHash = nullptr;
- return TRUE;
+ return true;
}
static void U_CALLCONV
return result;
}
-#if !UCONFIG_NO_FORMATTING
static const char* typeWidthToStyleString(UListFormatterType type, UListFormatterWidth width) {
switch (type) {
case ULISTFMT_TYPE_AND:
return nullptr;
}
-#endif
static const UChar solidus = 0x2F;
static const UChar aliasPrefix[] = { 0x6C,0x69,0x73,0x74,0x50,0x61,0x74,0x74,0x65,0x72,0x6E,0x2F }; // "listPattern/"
}
ListFormatter* ListFormatter::createInstance(const Locale& locale, UErrorCode& errorCode) {
-#if !UCONFIG_NO_FORMATTING
return createInstance(locale, ULISTFMT_TYPE_AND, ULISTFMT_WIDTH_WIDE, errorCode);
-#else
- return createInstance(locale, "standard", errorCode);
-#endif
}
-#if !UCONFIG_NO_FORMATTING
ListFormatter* ListFormatter::createInstance(
const Locale& locale, UListFormatterType type, UListFormatterWidth width, UErrorCode& errorCode) {
const char* style = typeWidthToStyleString(type, width);
}
return createInstance(locale, style, errorCode);
}
-#endif
ListFormatter* ListFormatter::createInstance(const Locale& locale, const char *style, UErrorCode& errorCode) {
const ListFormatInternal* listFormatInternal = getListFormatInternal(locale, style, errorCode);
int32_t index,
int32_t &offset,
UErrorCode& errorCode) const {
-#if !UCONFIG_NO_FORMATTING
int32_t initialOffset = appendTo.length();
auto result = formatStringsToValue(items, nItems, errorCode);
UnicodeStringAppendable appendable(appendTo);
result.nextPosition(cfpos, errorCode);
offset = initialOffset + cfpos.getStart();
}
-#endif
return appendTo;
}
-#if !UCONFIG_NO_FORMATTING
FormattedList ListFormatter::formatStringsToValue(
const UnicodeString items[],
int32_t nItems,
return FormattedList(result.data.orphan());
}
}
-#endif
U_NAMESPACE_END
+
+#endif /* #if !UCONFIG_NO_FORMATTING */
#if U_SHOW_CPLUSPLUS_API
+#if !UCONFIG_NO_FORMATTING
+
#include "unicode/unistr.h"
#include "unicode/locid.h"
#include "unicode/formattedvalue.h"
*/
-#if !UCONFIG_NO_FORMATTING
/**
* An immutable class containing the result of a list formatting operation.
*
: fData(nullptr), fErrorCode(errorCode) {}
friend class ListFormatter;
};
-#endif // !UCONFIG_NO_FORMATTING
/**
*/
static ListFormatter* createInstance(const Locale& locale, UErrorCode& errorCode);
-#ifndef U_HIDE_DRAFT_API
-#if !UCONFIG_NO_FORMATTING
/**
* Creates a ListFormatter for the given locale, list type, and style.
*
* @param width The width of formatting to use.
* @param errorCode ICU error code, set if no data available for the given locale.
* @return A ListFormatter object created from internal data derived from CLDR data.
- * @draft ICU 67
+ * @stable ICU 67
*/
static ListFormatter* createInstance(
const Locale& locale, UListFormatterType type, UListFormatterWidth width, UErrorCode& errorCode);
-#endif /* !UCONFIG_NO_FORMATTING */
-#endif /* U_HIDE_DRAFT_API */
#ifndef U_HIDE_INTERNAL_API
/**
UnicodeString& format(const UnicodeString items[], int32_t n_items,
UnicodeString& appendTo, UErrorCode& errorCode) const;
-#if !UCONFIG_NO_FORMATTING
/**
* Formats a list of strings to a FormattedList, which exposes field
* position information. The FormattedList contains more information than
const UnicodeString items[],
int32_t n_items,
UErrorCode& errorCode) const;
-#endif // !UCONFIG_NO_FORMATTING
#ifndef U_HIDE_INTERNAL_API
/**
U_NAMESPACE_END
+#endif /* #if !UCONFIG_NO_FORMATTING */
+
#endif /* U_SHOW_CPLUSPLUS_API */
#endif // __LISTFORMATTER_H__
ULISTFMT_ELEMENT_FIELD
} UListFormatterField;
-#ifndef U_HIDE_DRAFT_API
/**
* Type of meaning expressed by the list.
*
- * @draft ICU 67
+ * @stable ICU 67
*/
typedef enum UListFormatterType {
/**
* Conjunction formatting, e.g. "Alice, Bob, Charlie, and Delta".
*
- * @draft ICU 67
+ * @stable ICU 67
*/
ULISTFMT_TYPE_AND,
* Disjunction (or alternative, or simply one of) formatting, e.g.
* "Alice, Bob, Charlie, or Delta".
*
- * @draft ICU 67
+ * @stable ICU 67
*/
ULISTFMT_TYPE_OR,
/**
* Formatting of a list of values with units, e.g. "5 pounds, 12 ounces".
*
- * @draft ICU 67
+ * @stable ICU 67
*/
ULISTFMT_TYPE_UNITS
} UListFormatterType;
/**
* Verbosity level of the list patterns.
*
- * @draft ICU 67
+ * @stable ICU 67
*/
typedef enum UListFormatterWidth {
/**
* Use list formatting with full words (no abbreviations) when possible.
*
- * @draft ICU 67
+ * @stable ICU 67
*/
ULISTFMT_WIDTH_WIDE,
/**
* Use list formatting of typical length.
- * @draft ICU 67
+ * @stable ICU 67
*/
ULISTFMT_WIDTH_SHORT,
/**
* Use list formatting of the shortest possible length.
- * @draft ICU 67
+ * @stable ICU 67
*/
ULISTFMT_WIDTH_NARROW,
} UListFormatterWidth;
-#endif /* U_HIDE_DRAFT_API */
/**
* Open a new UListFormatter object using the rules for a given locale.
ulistfmt_open(const char* locale,
UErrorCode* status);
-#ifndef U_HIDE_DRAFT_API
/**
* Open a new UListFormatter object appropriate for the given locale, list type,
* and style.
* @return
* A pointer to a UListFormatter object for the specified locale,
* or NULL if an error occurred.
- * @draft ICU 67
+ * @stable ICU 67
*/
U_CAPI UListFormatter* U_EXPORT2
ulistfmt_openForType(const char* locale, UListFormatterType type,
UListFormatterWidth width, UErrorCode* status);
-#endif /* U_HIDE_DRAFT_API */
/**
* Close a UListFormatter object. Once closed it may no longer be used.