36 #if U_SHOW_CPLUSPLUS_API 39 #include <string_view> 59 class StringEnumeration;
280 const char* country =
nullptr,
281 const char* variant =
nullptr,
282 const char* keywordsAndValues =
nullptr);
359 #ifndef U_HIDE_SYSTEM_API 440 template<
typename StringClass>
441 inline StringClass toLanguageTag(
UErrorCode& status)
const;
454 #ifndef U_HIDE_INTERNAL_API 621 template<
typename StringClass,
typename OutputIterator>
622 inline void getKeywords(OutputIterator iterator,
UErrorCode& status)
const;
635 template<
typename StringClass,
typename OutputIterator>
636 inline void getUnicodeKeywords(OutputIterator iterator,
UErrorCode& status)
const;
654 U_COMMON_API int32_t getKeywordValue(
const char* keywordName,
656 int32_t bufferCapacity,
687 template<
typename StringClass>
720 template<
typename StringClass>
743 const char* keywordValue,
1002 U_COMMON_API static const char*
const* U_EXPORT2 getISOCountries();
1015 U_COMMON_API static const char*
const* U_EXPORT2 getISOLanguages();
1044 virtual UBool hasNext()
const = 0;
1050 virtual const Locale &next() = 0;
1057 template<
typename Iter>
1093 template<
typename Iter,
typename Conv>
1107 it_(begin), end_(end), converter_(converter) {}
1128 #ifndef U_HIDE_INTERNAL_API 1153 Locale& init(
const char* localeID,
UBool canonicalize);
1161 enum ELocaleType : uint8_t {
1166 Locale(ELocaleType);
1171 static Locale* getLocaleCache();
1181 static constexpr
size_t SIZE = 32;
1183 ELocaleType type = eNEST;
1187 uint8_t variantBegin;
1188 char baseName[SIZE -
1193 sizeof variantBegin];
1195 const char* getLanguage()
const {
return language; }
1196 const char* getScript()
const {
return script; }
1197 const char* getRegion()
const {
return region; }
1198 const char* getVariant()
const {
return variantBegin == 0 ?
"" : getBaseName() + variantBegin; }
1199 const char* getBaseName()
const {
return baseName; }
1202 static void* U_EXPORT2
operator new(size_t) noexcept =
delete;
1203 static void* U_EXPORT2
operator new[](size_t) noexcept =
delete;
1205 Nest() : language{
'\0'}, script{
'\0'}, region{
'\0'}, variantBegin{0}, baseName{
'\0'} {}
1207 void init(std::string_view language,
1208 std::string_view script,
1209 std::string_view region,
1210 uint8_t variantBegin);
1212 static bool fits(int32_t length,
1213 std::string_view language,
1214 std::string_view script,
1215 std::string_view region) {
1216 return length < static_cast<int32_t>(
sizeof Nest::baseName) &&
1217 language.size() <
sizeof Nest::language &&
1218 script.size() <
sizeof Nest::script &&
1219 region.size() <
sizeof Nest::region;
1223 friend union Payload;
1224 Nest(Heap&& heap, uint8_t variantBegin);
1226 static_assert(
sizeof(Nest) == Nest::SIZE);
1240 const char* getLanguage()
const {
return language; }
1241 const char* getScript()
const {
return script; }
1242 const char* getRegion()
const {
return region; }
1243 const char* getVariant()
const;
1244 const char* getFullName()
const;
1245 const char* getBaseName()
const;
1248 static void* U_EXPORT2
operator new(size_t) noexcept =
delete;
1249 static void* U_EXPORT2
operator new[](size_t) noexcept =
delete;
1251 Heap(std::string_view language,
1252 std::string_view script,
1253 std::string_view region,
1254 int32_t variantBegin);
1257 Heap& operator=(
const Heap& other);
1258 Heap& operator=(Heap&& other) noexcept;
1260 static_assert(
sizeof(Heap) <=
sizeof(Nest));
1272 void copy(
const Payload& other);
1273 void move(Payload&& other) noexcept;
1277 static void* U_EXPORT2
operator new(size_t) noexcept =
delete;
1278 static void* U_EXPORT2
operator new[](size_t) noexcept =
delete;
1280 Payload() : type{eBOGUS} {}
1283 Payload(
const Payload& other);
1284 Payload(Payload&& other) noexcept;
1286 Payload& operator=(
const Payload& other);
1287 Payload& operator=(Payload&& other) noexcept;
1290 bool isBogus()
const {
return type == eBOGUS; }
1292 template <
typename T,
typename... Args> T& emplace(Args&&... args);
1294 template <
typename T> T*
get();
1296 template <
typename BogusFn,
typename NestFn,
typename HeapFn,
typename... Args>
1297 auto visit(BogusFn bogusFn, NestFn nestFn, HeapFn heapFn, Args... args)
const;
1308 template <
const char* (Nest::*
const NEST)() const,
1309 const
char* (Heap::*const HEAP)() const>
1310 const
char* getField() const;
1312 static const Locale &getLocale(
int locid);
1317 friend Locale *locale_set_default_internal(const
char *,
UErrorCode& status);
1330 template<
typename StringClass>
inline StringClass
1336 toLanguageTag(sink, status);
1340 template<
typename StringClass,
typename OutputIterator>
inline void 1349 int32_t resultLength;
1350 const char* buffer = keys->next(&resultLength, status);
1351 if (
U_FAILURE(status) || buffer ==
nullptr) {
1354 *iterator++ = StringClass(buffer, resultLength);
1358 template<
typename StringClass,
typename OutputIterator>
inline void 1367 int32_t resultLength;
1368 const char* buffer = keys->next(&resultLength, status);
1369 if (
U_FAILURE(status) || buffer ==
nullptr) {
1372 *iterator++ = StringClass(buffer, resultLength);
1376 template<
typename StringClass>
inline StringClass
1382 getKeywordValue(keywordName, sink, status);
1386 template<
typename StringClass>
inline StringClass
1392 getUnicodeKeywordValue(keywordName, sink, status);
1398 return payload.isBogus();
#define U_COMMON_API_CLASS
Set to export library symbols from inside the common library, and to import them from outside...
bool operator!=(const StringPiece &x, const StringPiece &y)
Global operator != for StringPiece.
const Locale & next() override
U_COMMON_API UBool operator==(const StringPiece &x, const StringPiece &y)
Global operator == for StringPiece.
U_COMMON_API int32_t getKeywordValue(const char *keywordName, char *buffer, int32_t bufferCapacity, UErrorCode &status) const
Gets the value for a keyword.
#define U_FAILURE(x)
Does the error code indicate a failure?
#define ULOC_LANG_CAPACITY
Useful constant for the maximum size of the language part of a locale ID.
U_COMMON_API void getUnicodeKeywordValue(StringPiece keywordName, ByteSink &sink, UErrorCode &status) const
Gets the Unicode value for a Unicode keyword.
"Smart pointer" class, deletes objects via the standard C++ delete operator.
#define ULOC_COUNTRY_CAPACITY
Useful constant for the maximum size of the country part of a locale ID (including the terminating NU...
UBool hasNext() const override
void * UClassID
UClassID is used to identify classes without using the compiler's RTTI.
Base class for 'pure' C++ implementations of uenum api.
U_COMMON_API void setKeywordValue(const char *keywordName, const char *keywordValue, UErrorCode &status)
Sets or removes the value for a keyword.
#define ULOC_SCRIPT_CAPACITY
Useful constant for the maximum size of the script part of a locale ID (including the terminating NUL...
A ByteSink can be filled with bytes.
A Locale iterator interface similar to a Java Iterator<Locale>.
void locale_available_init()
U_COMMON_API void toLanguageTag(ByteSink &sink, UErrorCode &status) const
Returns a well-formed language tag for this Locale.
C++ API: StringPiece: Read-only byte string wrapper class.
void getUnicodeKeywords(OutputIterator iterator, UErrorCode &status) const
Gets the set of Unicode keywords for this Locale.
C++ API: Interface for writing bytes, and implementation classes.
A generic Locale iterator implementation over Locale input iterators.
UBool isNull() const
nullptr check.
C++ API: "Smart pointers" for use with and in ICU4C C++ code.
virtual UClassID getDynamicClassID() const
ICU4C "poor man's RTTI", returns a UClassID for the actual ICU class.
C API: Platform Utilities.
RangeIterator(Iter begin, Iter end)
Constructs an iterator from a begin/end range.
C++ API: Common ICU base class UObject.
U_COMMON_API UBool isBogus() const
Gets the bogus state.
UErrorCode
Standard ICU4C error code type, a substitute for exceptions.
C++ API: String Enumeration.
Basic definitions for ICU, for both C and C++ APIs.
void getKeywords(OutputIterator iterator, UErrorCode &status) const
Gets the set of keywords for this Locale.
Implementation of ByteSink that writes to a "string".
#define U_COMMON_API
Set to export library symbols from inside the common library, and to import them from outside...
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
A generic Locale iterator implementation over Locale input iterators.
A string-like object that points to a sized piece of memory.
UObject is the common ICU "boilerplate" class.
UMemory is the common ICU base class.
const Locale & next() override
ConvertingIterator(Iter begin, Iter end, Conv converter)
Constructs an iterator from a begin/end range.
UBool hasNext() const override
int8_t UBool
The ICU boolean type, a signed-byte integer.
C API: Locale ID functionality similar to C++ class Locale.
A Locale object represents a specific geographical, political, or cultural region.