ICU 64.2 64.2

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/locid.h"
7 #include "unicode/stringpiece.h"
8 #include "unicode/uobject.h"
9 #include "unicode/utypes.h"
10
11
12 #ifndef U_HIDE_DRAFT_API
13
18 U_NAMESPACE_BEGIN
19 class CharString;
20
59 class U_COMMON_API LocaleBuilder : public UObject {
60 public:
68 LocaleBuilder();
69
74 virtual ~LocaleBuilder();
75
88 LocaleBuilder& setLocale(const Locale& locale);
89
106 LocaleBuilder& setLanguageTag(StringPiece tag);
107
121 LocaleBuilder& setLanguage(StringPiece language);
122
137 LocaleBuilder& setScript(StringPiece script);
138
156 LocaleBuilder& setRegion(StringPiece region);
157
177 LocaleBuilder& setVariant(StringPiece variant);
178
198 LocaleBuilder& setExtension(char key, StringPiece value);
199
218 LocaleBuilder& setUnicodeLocaleKeyword(
219 StringPiece key, StringPiece type);
220
231 LocaleBuilder& addUnicodeLocaleAttribute(StringPiece attribute);
232
244 LocaleBuilder& removeUnicodeLocaleAttribute(StringPiece attribute);
245
253 LocaleBuilder& clear();
254
262 LocaleBuilder& clearExtensions();
263
277 Locale build(UErrorCode& status);
278
279 private:
280 UErrorCode status_;
281 char language_[9];
282 char script_[5];
283 char region_[4];
284 CharString *variant_; // Pointer not object so we need not #include internal charstr.h.
285 icu::Locale *extensions_; // Pointer not object. Storage for all other fields.
286
287 };
288
289 U_NAMESPACE_END
290
291 #endif // U_HIDE_DRAFT_API
292 #endif // __LOCALEBUILDER_H__
icu::LocaleBuilder
LocaleBuilder is used to build instances of Locale from values configured by the setters.
Definition: localebuilder.h:59
stringpiece.h
C++ API: StringPiece: Read-only byte string wrapper class.
U_NAMESPACE_BEGIN
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition: uversion.h:137
uobject.h
C++ API: Common ICU base class UObject.
U_NAMESPACE_END
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
Definition: uversion.h:138
UErrorCode
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers,...
Definition: utypes.h:401
locid.h
C++ API: Locale ID object.
utypes.h
Basic definitions for ICU, for both C and C++ APIs.
U_COMMON_API
#define U_COMMON_API
Set to export library symbols from inside the common library, and to import them from outside.
Definition: utypes.h:300
icu::StringPiece
A string-like object that points to a sized piece of memory.
Definition: stringpiece.h:54
icu::UObject
UObject is the common ICU "boilerplate" class.
Definition: uobject.h:223
icu::Locale
A Locale object represents a specific geographical, political, or cultural region.
Definition: locid.h:192