ICU 66.1 66.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#License
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
15#ifndef U_HIDE_DRAFT_API
21U_NAMESPACE_BEGIN
22class CharString;
23
63public:
72
77 virtual ~LocaleBuilder();
78
92
110
125
141
160
181
202
222 StringPiece key, StringPiece type);
223
235
248
257
266
281
282#ifndef U_HIDE_DRAFT_API
292 UBool copyErrorTo(UErrorCode &outErrorCode) const;
293#endif /* U_HIDE_DRAFT_API */
294
295private:
296 friend class LocaleMatcher::Result;
297
298 void copyExtensionsFrom(const Locale& src, UErrorCode& errorCode);
299
300 UErrorCode status_;
301 char language_[9];
302 char script_[5];
303 char region_[4];
304 CharString *variant_; // Pointer not object so we need not #include internal charstr.h.
305 icu::Locale *extensions_; // Pointer not object. Storage for all other fields.
306
307};
308
309U_NAMESPACE_END
310
311#endif // U_HIDE_DRAFT_API
312
313#endif /* U_SHOW_CPLUSPLUS_API */
314
315#endif // __LOCALEBUILDER_H__
LocaleBuilder is used to build instances of Locale from values configured by the setters.
Definition: localebuilder.h:62
LocaleBuilder & setLanguageTag(StringPiece tag)
Resets the LocaleBuilder to match the provided Unicode Locale Identifier .
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.
Definition: umachine.h:261
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