2018-02-06 07:52:58 +00:00
|
|
|
// © 2018 and later: Unicode, Inc. and others.
|
|
|
|
// License & terms of use: http://www.unicode.org/copyright.html
|
|
|
|
|
2018-04-12 10:59:37 +00:00
|
|
|
// This file is in common instead of i18n because it is needed by ucurr.cpp.
|
|
|
|
|
2018-02-06 07:52:58 +00:00
|
|
|
#include "unicode/utypes.h"
|
|
|
|
|
2018-04-23 23:02:26 +00:00
|
|
|
#if !UCONFIG_NO_FORMATTING
|
2018-05-16 22:46:40 +00:00
|
|
|
#ifndef __STATIC_UNICODE_SETS_H__
|
|
|
|
#define __STATIC_UNICODE_SETS_H__
|
2018-02-06 07:52:58 +00:00
|
|
|
|
|
|
|
#include "unicode/uniset.h"
|
2018-04-12 10:59:37 +00:00
|
|
|
#include "unicode/unistr.h"
|
2018-02-06 07:52:58 +00:00
|
|
|
|
2018-05-16 22:46:40 +00:00
|
|
|
U_NAMESPACE_BEGIN
|
2018-02-06 07:52:58 +00:00
|
|
|
namespace unisets {
|
|
|
|
|
|
|
|
enum Key {
|
2018-05-16 22:46:40 +00:00
|
|
|
// NONE is used to indicate null in chooseFrom().
|
|
|
|
// EMPTY is used to get an empty UnicodeSet.
|
|
|
|
NONE = -1,
|
|
|
|
EMPTY = 0,
|
2018-02-09 02:35:02 +00:00
|
|
|
|
2018-02-06 07:52:58 +00:00
|
|
|
// Ignorables
|
|
|
|
DEFAULT_IGNORABLES,
|
|
|
|
STRICT_IGNORABLES,
|
|
|
|
|
|
|
|
// Separators
|
|
|
|
// Notes:
|
|
|
|
// - COMMA is a superset of STRICT_COMMA
|
|
|
|
// - PERIOD is a superset of SCRICT_PERIOD
|
|
|
|
// - ALL_SEPARATORS is the union of COMMA, PERIOD, and OTHER_GROUPING_SEPARATORS
|
|
|
|
// - STRICT_ALL_SEPARATORS is the union of STRICT_COMMA, STRICT_PERIOD, and OTHER_GRP_SEPARATORS
|
2018-04-12 10:59:37 +00:00
|
|
|
COMMA,
|
2018-02-06 07:52:58 +00:00
|
|
|
PERIOD,
|
|
|
|
STRICT_COMMA,
|
|
|
|
STRICT_PERIOD,
|
|
|
|
OTHER_GROUPING_SEPARATORS,
|
|
|
|
ALL_SEPARATORS,
|
|
|
|
STRICT_ALL_SEPARATORS,
|
|
|
|
|
|
|
|
// Symbols
|
2018-04-12 10:59:37 +00:00
|
|
|
MINUS_SIGN,
|
2018-02-06 07:52:58 +00:00
|
|
|
PLUS_SIGN,
|
|
|
|
PERCENT_SIGN,
|
|
|
|
PERMILLE_SIGN,
|
2018-03-14 09:15:27 +00:00
|
|
|
INFINITY_KEY, // INFINITY is defined in cmath
|
2018-02-06 07:52:58 +00:00
|
|
|
|
2018-04-12 10:59:37 +00:00
|
|
|
// Currency Symbols
|
|
|
|
DOLLAR_SIGN,
|
|
|
|
POUND_SIGN,
|
|
|
|
RUPEE_SIGN,
|
|
|
|
YEN_SIGN, // not in CLDR data, but Currency.java wants it
|
|
|
|
|
2018-02-06 07:52:58 +00:00
|
|
|
// Other
|
2018-04-12 10:59:37 +00:00
|
|
|
DIGITS,
|
2018-02-06 07:52:58 +00:00
|
|
|
|
|
|
|
// Combined Separators with Digits (for lead code points)
|
2018-04-12 10:59:37 +00:00
|
|
|
DIGITS_OR_ALL_SEPARATORS,
|
2018-02-06 07:52:58 +00:00
|
|
|
DIGITS_OR_STRICT_ALL_SEPARATORS,
|
|
|
|
|
2018-05-16 22:46:40 +00:00
|
|
|
// The number of elements in the enum.
|
2018-04-12 10:59:37 +00:00
|
|
|
COUNT
|
2018-02-06 07:52:58 +00:00
|
|
|
};
|
|
|
|
|
2018-05-16 22:46:40 +00:00
|
|
|
/**
|
|
|
|
* Gets the static-allocated UnicodeSet according to the provided key. The
|
|
|
|
* pointer will be deleted during u_cleanup(); the caller should NOT delete it.
|
|
|
|
*
|
|
|
|
* Exported as U_COMMON_API for ucurr.cpp
|
|
|
|
*
|
|
|
|
* @param key The desired UnicodeSet according to the enum in this file.
|
|
|
|
* @return The requested UnicodeSet. Guaranteed to be frozen and non-null, but
|
|
|
|
* may be empty if an error occurred during data loading.
|
|
|
|
*/
|
2018-04-25 00:39:22 +00:00
|
|
|
U_COMMON_API const UnicodeSet* get(Key key);
|
2018-02-06 07:52:58 +00:00
|
|
|
|
2018-05-16 22:46:40 +00:00
|
|
|
/**
|
|
|
|
* Checks if the UnicodeSet given by key1 contains the given string.
|
|
|
|
*
|
|
|
|
* Exported as U_COMMON_API for numparse_decimal.cpp
|
|
|
|
*
|
|
|
|
* @param str The string to check.
|
|
|
|
* @param key1 The set to check.
|
|
|
|
* @return key1 if the set contains str, or NONE if not.
|
|
|
|
*/
|
2018-04-25 00:39:22 +00:00
|
|
|
U_COMMON_API Key chooseFrom(UnicodeString str, Key key1);
|
2018-02-06 07:52:58 +00:00
|
|
|
|
2018-05-16 22:46:40 +00:00
|
|
|
/**
|
|
|
|
* Checks if the UnicodeSet given by either key1 or key2 contains the string.
|
|
|
|
*
|
|
|
|
* Exported as U_COMMON_API for numparse_decimal.cpp
|
|
|
|
*
|
|
|
|
* @param str The string to check.
|
|
|
|
* @param key1 The first set to check.
|
|
|
|
* @param key2 The second set to check.
|
|
|
|
* @return key1 if that set contains str; key2 if that set contains str; or
|
|
|
|
* NONE if neither set contains str.
|
|
|
|
*/
|
2018-04-25 00:39:22 +00:00
|
|
|
U_COMMON_API Key chooseFrom(UnicodeString str, Key key1, Key key2);
|
2018-02-06 07:52:58 +00:00
|
|
|
|
2018-04-12 10:59:37 +00:00
|
|
|
// Unused in C++:
|
|
|
|
// Key chooseCurrency(UnicodeString str);
|
|
|
|
// Used instead:
|
|
|
|
static const struct {
|
|
|
|
Key key;
|
|
|
|
UChar32 exemplar;
|
|
|
|
} kCurrencyEntries[] = {
|
|
|
|
{DOLLAR_SIGN, u'$'},
|
|
|
|
{POUND_SIGN, u'£'},
|
|
|
|
{RUPEE_SIGN, u'₨'},
|
|
|
|
{YEN_SIGN, u'¥'},
|
|
|
|
};
|
|
|
|
|
2018-02-06 07:52:58 +00:00
|
|
|
} // namespace unisets
|
|
|
|
U_NAMESPACE_END
|
|
|
|
|
2018-05-16 22:46:40 +00:00
|
|
|
#endif //__STATIC_UNICODE_SETS_H__
|
2018-02-06 07:52:58 +00:00
|
|
|
#endif /* #if !UCONFIG_NO_FORMATTING */
|