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 
19 class CharString;
20 
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 
290 
291 #endif // U_HIDE_DRAFT_API
292 #endif // __LOCALEBUILDER_H__
LocaleBuilder is used to build instances of Locale from values configured by the setters.
Definition: localebuilder.h:59
C++ API: StringPiece: Read-only byte string wrapper class.
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition: uversion.h:137
C++ API: Common ICU base class UObject.
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
Definition: uversion.h:138
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers...
Definition: utypes.h:401
C++ API: Locale ID object.
Basic definitions for ICU, for both C and C++ APIs.
#define U_COMMON_API
Set to export library symbols from inside the common library, and to import them from outside...
Definition: utypes.h:300
A string-like object that points to a sized piece of memory.
Definition: stringpiece.h:54
UObject is the common ICU "boilerplate" class.
Definition: uobject.h:223
A Locale object represents a specific geographical, political, or cultural region.
Definition: locid.h:192