00001 // © 2018 and later: Unicode, Inc. and others. 00002 // License & terms of use: http://www.unicode.org/copyright.html#License 00003 #ifndef __LOCALEBUILDER_H__ 00004 #define __LOCALEBUILDER_H__ 00005 00006 #include "unicode/utypes.h" 00007 00008 #if U_SHOW_CPLUSPLUS_API 00009 00010 #include "unicode/locid.h" 00011 #include "unicode/localematcher.h" 00012 #include "unicode/stringpiece.h" 00013 #include "unicode/uobject.h" 00014 00015 #ifndef U_HIDE_DRAFT_API 00016 00021 U_NAMESPACE_BEGIN 00022 class CharString; 00023 00062 class U_COMMON_API LocaleBuilder : public UObject { 00063 public: 00071 LocaleBuilder(); 00072 00077 virtual ~LocaleBuilder(); 00078 00091 LocaleBuilder& setLocale(const Locale& locale); 00092 00109 LocaleBuilder& setLanguageTag(StringPiece tag); 00110 00124 LocaleBuilder& setLanguage(StringPiece language); 00125 00140 LocaleBuilder& setScript(StringPiece script); 00141 00159 LocaleBuilder& setRegion(StringPiece region); 00160 00180 LocaleBuilder& setVariant(StringPiece variant); 00181 00201 LocaleBuilder& setExtension(char key, StringPiece value); 00202 00221 LocaleBuilder& setUnicodeLocaleKeyword( 00222 StringPiece key, StringPiece type); 00223 00234 LocaleBuilder& addUnicodeLocaleAttribute(StringPiece attribute); 00235 00247 LocaleBuilder& removeUnicodeLocaleAttribute(StringPiece attribute); 00248 00256 LocaleBuilder& clear(); 00257 00265 LocaleBuilder& clearExtensions(); 00266 00280 Locale build(UErrorCode& status); 00281 00282 #ifndef U_HIDE_DRAFT_API 00283 00292 UBool copyErrorTo(UErrorCode &outErrorCode) const; 00293 #endif /* U_HIDE_DRAFT_API */ 00294 00295 private: 00296 friend class LocaleMatcher::Result; 00297 00298 void copyExtensionsFrom(const Locale& src, UErrorCode& errorCode); 00299 00300 UErrorCode status_; 00301 char language_[9]; 00302 char script_[5]; 00303 char region_[4]; 00304 CharString *variant_; // Pointer not object so we need not #include internal charstr.h. 00305 icu::Locale *extensions_; // Pointer not object. Storage for all other fields. 00306 00307 }; 00308 00309 U_NAMESPACE_END 00310 00311 #endif // U_HIDE_DRAFT_API 00312 00313 #endif /* U_SHOW_CPLUSPLUS_API */ 00314 00315 #endif // __LOCALEBUILDER_H__
1.6.1