ICU 72.1 72.1
localebuilder.h
Go to the documentation of this file.
1// © 2018 and later: Unicode, Inc. and others.
2// License & terms of use: http://www.unicode.org/copyright.html
3#ifndef __LOCALEBUILDER_H__
4#define __LOCALEBUILDER_H__
5
6#include "unicode/utypes.h"
7
8#if U_SHOW_CPLUSPLUS_API
9
10#include "unicode/locid.h"
12#include "unicode/stringpiece.h"
13#include "unicode/uobject.h"
14
20U_NAMESPACE_BEGIN
21class CharString;
22
62public:
71
76 virtual ~LocaleBuilder();
77
91
108
123
139
158
179
200
220 StringPiece key, StringPiece type);
221
233
246
255
264
279
289 UBool copyErrorTo(UErrorCode &outErrorCode) const;
290
291private:
292 friend class LocaleMatcher::Result;
293
294 void copyExtensionsFrom(const Locale& src, UErrorCode& errorCode);
295
296 UErrorCode status_;
297 char language_[9];
298 char script_[5];
299 char region_[4];
300 CharString *variant_; // Pointer not object so we need not #include internal charstr.h.
301 icu::Locale *extensions_; // Pointer not object. Storage for all other fields.
302
303};
304
305U_NAMESPACE_END
306
307#endif /* U_SHOW_CPLUSPLUS_API */
308
309#endif // __LOCALEBUILDER_H__
LocaleBuilder is used to build instances of Locale from values configured by the setters.
Definition: localebuilder.h:61
LocaleBuilder & setLanguageTag(StringPiece tag)
Resets the LocaleBuilder to match the provided IETF BCP 47 language tag.
LocaleBuilder & setScript(StringPiece script)
Sets the script.
LocaleBuilder & setUnicodeLocaleKeyword(StringPiece key, StringPiece type)
Sets the Unicode locale keyword type for the given key.
LocaleBuilder & setExtension(char key, StringPiece value)
Sets the extension for the given key.
Locale build(UErrorCode &status)
Returns an instance of Locale created from the fields set on this builder.
LocaleBuilder & clear()
Resets the builder to its initial, empty state.
LocaleBuilder & setLocale(const Locale &locale)
Resets the LocaleBuilder to match the provided locale.
UBool copyErrorTo(UErrorCode &outErrorCode) const
Sets the UErrorCode if an error occurred while recording sets.
virtual ~LocaleBuilder()
Destructor.
LocaleBuilder & addUnicodeLocaleAttribute(StringPiece attribute)
Adds a unicode locale attribute, if not already present, otherwise has no effect.
LocaleBuilder()
Constructs an empty LocaleBuilder.
LocaleBuilder & removeUnicodeLocaleAttribute(StringPiece attribute)
Removes a unicode locale attribute, if present, otherwise has no effect.
LocaleBuilder & setVariant(StringPiece variant)
Sets the variant.
LocaleBuilder & setLanguage(StringPiece language)
Sets the language.
LocaleBuilder & clearExtensions()
Resets the extensions to their initial, empty state.
LocaleBuilder & setRegion(StringPiece region)
Sets the region.
Data for the best-matching pair of a desired and a supported locale.
A Locale object represents a specific geographical, political, or cultural region.
Definition: locid.h:195
A string-like object that points to a sized piece of memory.
Definition: stringpiece.h:60
UObject is the common ICU "boilerplate" class.
Definition: uobject.h:223
C++ API: Locale matcher: User's desired locales vs.
C++ API: Locale ID object.
C++ API: StringPiece: Read-only byte string wrapper class.
int8_t UBool
The ICU boolean type, a signed-byte integer.
Definition: umachine.h:269
C++ API: Common ICU base class UObject.
Basic definitions for ICU, for both C and C++ APIs.
UErrorCode
Standard ICU4C error code type, a substitute for exceptions.
Definition: utypes.h:415
#define U_COMMON_API
Set to export library symbols from inside the common library, and to import them from outside.
Definition: utypes.h:300