xref: /aosp_15_r20/external/icu/libicu/cts_headers/unicode/localebuilder.h (revision 0e209d3975ff4a8c132096b14b0e9364a753506e)
1*0e209d39SAndroid Build Coastguard Worker // © 2018 and later: Unicode, Inc. and others.
2*0e209d39SAndroid Build Coastguard Worker // License & terms of use: http://www.unicode.org/copyright.html
3*0e209d39SAndroid Build Coastguard Worker #ifndef __LOCALEBUILDER_H__
4*0e209d39SAndroid Build Coastguard Worker #define __LOCALEBUILDER_H__
5*0e209d39SAndroid Build Coastguard Worker 
6*0e209d39SAndroid Build Coastguard Worker #include "unicode/utypes.h"
7*0e209d39SAndroid Build Coastguard Worker 
8*0e209d39SAndroid Build Coastguard Worker #if U_SHOW_CPLUSPLUS_API
9*0e209d39SAndroid Build Coastguard Worker 
10*0e209d39SAndroid Build Coastguard Worker #include "unicode/locid.h"
11*0e209d39SAndroid Build Coastguard Worker #include "unicode/localematcher.h"
12*0e209d39SAndroid Build Coastguard Worker #include "unicode/stringpiece.h"
13*0e209d39SAndroid Build Coastguard Worker #include "unicode/uobject.h"
14*0e209d39SAndroid Build Coastguard Worker 
15*0e209d39SAndroid Build Coastguard Worker /**
16*0e209d39SAndroid Build Coastguard Worker  * \file
17*0e209d39SAndroid Build Coastguard Worker  * \brief C++ API: Builder API for Locale
18*0e209d39SAndroid Build Coastguard Worker  */
19*0e209d39SAndroid Build Coastguard Worker 
20*0e209d39SAndroid Build Coastguard Worker U_NAMESPACE_BEGIN
21*0e209d39SAndroid Build Coastguard Worker class CharString;
22*0e209d39SAndroid Build Coastguard Worker 
23*0e209d39SAndroid Build Coastguard Worker /**
24*0e209d39SAndroid Build Coastguard Worker  * <code>LocaleBuilder</code> is used to build instances of <code>Locale</code>
25*0e209d39SAndroid Build Coastguard Worker  * from values configured by the setters.  Unlike the <code>Locale</code>
26*0e209d39SAndroid Build Coastguard Worker  * constructors, the <code>LocaleBuilder</code> checks if a value configured by a
27*0e209d39SAndroid Build Coastguard Worker  * setter satisfies the syntax requirements defined by the <code>Locale</code>
28*0e209d39SAndroid Build Coastguard Worker  * class.  A <code>Locale</code> object created by a <code>LocaleBuilder</code> is
29*0e209d39SAndroid Build Coastguard Worker  * well-formed and can be transformed to a well-formed IETF BCP 47 language tag
30*0e209d39SAndroid Build Coastguard Worker  * without losing information.
31*0e209d39SAndroid Build Coastguard Worker  *
32*0e209d39SAndroid Build Coastguard Worker  * <p>The following example shows how to create a <code>Locale</code> object
33*0e209d39SAndroid Build Coastguard Worker  * with the <code>LocaleBuilder</code>.
34*0e209d39SAndroid Build Coastguard Worker  * <blockquote>
35*0e209d39SAndroid Build Coastguard Worker  * <pre>
36*0e209d39SAndroid Build Coastguard Worker  *     UErrorCode status = U_ZERO_ERROR;
37*0e209d39SAndroid Build Coastguard Worker  *     Locale aLocale = LocaleBuilder()
38*0e209d39SAndroid Build Coastguard Worker  *                          .setLanguage("sr")
39*0e209d39SAndroid Build Coastguard Worker  *                          .setScript("Latn")
40*0e209d39SAndroid Build Coastguard Worker  *                          .setRegion("RS")
41*0e209d39SAndroid Build Coastguard Worker  *                          .build(status);
42*0e209d39SAndroid Build Coastguard Worker  *     if (U_SUCCESS(status)) {
43*0e209d39SAndroid Build Coastguard Worker  *       // ...
44*0e209d39SAndroid Build Coastguard Worker  *     }
45*0e209d39SAndroid Build Coastguard Worker  * </pre>
46*0e209d39SAndroid Build Coastguard Worker  * </blockquote>
47*0e209d39SAndroid Build Coastguard Worker  *
48*0e209d39SAndroid Build Coastguard Worker  * <p>LocaleBuilders can be reused; <code>clear()</code> resets all
49*0e209d39SAndroid Build Coastguard Worker  * fields to their default values.
50*0e209d39SAndroid Build Coastguard Worker  *
51*0e209d39SAndroid Build Coastguard Worker  * <p>LocaleBuilder tracks errors in an internal UErrorCode. For all setters,
52*0e209d39SAndroid Build Coastguard Worker  * except setLanguageTag and setLocale, LocaleBuilder will return immediately
53*0e209d39SAndroid Build Coastguard Worker  * if the internal UErrorCode is in error state.
54*0e209d39SAndroid Build Coastguard Worker  * To reset internal state and error code, call clear method.
55*0e209d39SAndroid Build Coastguard Worker  * The setLanguageTag and setLocale method will first clear the internal
56*0e209d39SAndroid Build Coastguard Worker  * UErrorCode, then track the error of the validation of the input parameter
57*0e209d39SAndroid Build Coastguard Worker  * into the internal UErrorCode.
58*0e209d39SAndroid Build Coastguard Worker  *
59*0e209d39SAndroid Build Coastguard Worker  * @stable ICU 64
60*0e209d39SAndroid Build Coastguard Worker  */
61*0e209d39SAndroid Build Coastguard Worker class U_COMMON_API LocaleBuilder : public UObject {
62*0e209d39SAndroid Build Coastguard Worker public:
63*0e209d39SAndroid Build Coastguard Worker     /**
64*0e209d39SAndroid Build Coastguard Worker      * Constructs an empty LocaleBuilder. The default value of all
65*0e209d39SAndroid Build Coastguard Worker      * fields, extensions, and private use information is the
66*0e209d39SAndroid Build Coastguard Worker      * empty string.
67*0e209d39SAndroid Build Coastguard Worker      *
68*0e209d39SAndroid Build Coastguard Worker      * @stable ICU 64
69*0e209d39SAndroid Build Coastguard Worker      */
70*0e209d39SAndroid Build Coastguard Worker     LocaleBuilder();
71*0e209d39SAndroid Build Coastguard Worker 
72*0e209d39SAndroid Build Coastguard Worker     /**
73*0e209d39SAndroid Build Coastguard Worker      * Destructor
74*0e209d39SAndroid Build Coastguard Worker      * @stable ICU 64
75*0e209d39SAndroid Build Coastguard Worker      */
76*0e209d39SAndroid Build Coastguard Worker     virtual ~LocaleBuilder();
77*0e209d39SAndroid Build Coastguard Worker 
78*0e209d39SAndroid Build Coastguard Worker     /**
79*0e209d39SAndroid Build Coastguard Worker      * Resets the <code>LocaleBuilder</code> to match the provided
80*0e209d39SAndroid Build Coastguard Worker      * <code>locale</code>.  Existing state is discarded.
81*0e209d39SAndroid Build Coastguard Worker      *
82*0e209d39SAndroid Build Coastguard Worker      * <p>All fields of the locale must be well-formed.
83*0e209d39SAndroid Build Coastguard Worker      * <p>This method clears the internal UErrorCode.
84*0e209d39SAndroid Build Coastguard Worker      *
85*0e209d39SAndroid Build Coastguard Worker      * @param locale the locale
86*0e209d39SAndroid Build Coastguard Worker      * @return This builder.
87*0e209d39SAndroid Build Coastguard Worker      *
88*0e209d39SAndroid Build Coastguard Worker      * @stable ICU 64
89*0e209d39SAndroid Build Coastguard Worker      */
90*0e209d39SAndroid Build Coastguard Worker     LocaleBuilder& setLocale(const Locale& locale);
91*0e209d39SAndroid Build Coastguard Worker 
92*0e209d39SAndroid Build Coastguard Worker     /**
93*0e209d39SAndroid Build Coastguard Worker      * Resets the LocaleBuilder to match the provided IETF BCP 47 language tag.
94*0e209d39SAndroid Build Coastguard Worker      * Discards the existing state.
95*0e209d39SAndroid Build Coastguard Worker      * The empty string causes the builder to be reset, like {@link #clear}.
96*0e209d39SAndroid Build Coastguard Worker      * Legacy language tags (marked as “Type: grandfathered” in BCP 47)
97*0e209d39SAndroid Build Coastguard Worker      * are converted to their canonical form before being processed.
98*0e209d39SAndroid Build Coastguard Worker      * Otherwise, the <code>language tag</code> must be well-formed,
99*0e209d39SAndroid Build Coastguard Worker      * or else the build() method will later report an U_ILLEGAL_ARGUMENT_ERROR.
100*0e209d39SAndroid Build Coastguard Worker      *
101*0e209d39SAndroid Build Coastguard Worker      * <p>This method clears the internal UErrorCode.
102*0e209d39SAndroid Build Coastguard Worker      *
103*0e209d39SAndroid Build Coastguard Worker      * @param tag the language tag, defined as IETF BCP 47 language tag.
104*0e209d39SAndroid Build Coastguard Worker      * @return This builder.
105*0e209d39SAndroid Build Coastguard Worker      * @stable ICU 64
106*0e209d39SAndroid Build Coastguard Worker      */
107*0e209d39SAndroid Build Coastguard Worker     LocaleBuilder& setLanguageTag(StringPiece tag);
108*0e209d39SAndroid Build Coastguard Worker 
109*0e209d39SAndroid Build Coastguard Worker     /**
110*0e209d39SAndroid Build Coastguard Worker      * Sets the language.  If <code>language</code> is the empty string, the
111*0e209d39SAndroid Build Coastguard Worker      * language in this <code>LocaleBuilder</code> is removed. Otherwise, the
112*0e209d39SAndroid Build Coastguard Worker      * <code>language</code> must be well-formed, or else the build() method will
113*0e209d39SAndroid Build Coastguard Worker      * later report an U_ILLEGAL_ARGUMENT_ERROR.
114*0e209d39SAndroid Build Coastguard Worker      *
115*0e209d39SAndroid Build Coastguard Worker      * <p>The syntax of language value is defined as
116*0e209d39SAndroid Build Coastguard Worker      * [unicode_language_subtag](http://www.unicode.org/reports/tr35/tr35.html#unicode_language_subtag).
117*0e209d39SAndroid Build Coastguard Worker      *
118*0e209d39SAndroid Build Coastguard Worker      * @param language the language
119*0e209d39SAndroid Build Coastguard Worker      * @return This builder.
120*0e209d39SAndroid Build Coastguard Worker      * @stable ICU 64
121*0e209d39SAndroid Build Coastguard Worker      */
122*0e209d39SAndroid Build Coastguard Worker     LocaleBuilder& setLanguage(StringPiece language);
123*0e209d39SAndroid Build Coastguard Worker 
124*0e209d39SAndroid Build Coastguard Worker     /**
125*0e209d39SAndroid Build Coastguard Worker      * Sets the script. If <code>script</code> is the empty string, the script in
126*0e209d39SAndroid Build Coastguard Worker      * this <code>LocaleBuilder</code> is removed.
127*0e209d39SAndroid Build Coastguard Worker      * Otherwise, the <code>script</code> must be well-formed, or else the build()
128*0e209d39SAndroid Build Coastguard Worker      * method will later report an U_ILLEGAL_ARGUMENT_ERROR.
129*0e209d39SAndroid Build Coastguard Worker      *
130*0e209d39SAndroid Build Coastguard Worker      * <p>The script value is a four-letter script code as
131*0e209d39SAndroid Build Coastguard Worker      * [unicode_script_subtag](http://www.unicode.org/reports/tr35/tr35.html#unicode_script_subtag)
132*0e209d39SAndroid Build Coastguard Worker      * defined by ISO 15924
133*0e209d39SAndroid Build Coastguard Worker      *
134*0e209d39SAndroid Build Coastguard Worker      * @param script the script
135*0e209d39SAndroid Build Coastguard Worker      * @return This builder.
136*0e209d39SAndroid Build Coastguard Worker      * @stable ICU 64
137*0e209d39SAndroid Build Coastguard Worker      */
138*0e209d39SAndroid Build Coastguard Worker     LocaleBuilder& setScript(StringPiece script);
139*0e209d39SAndroid Build Coastguard Worker 
140*0e209d39SAndroid Build Coastguard Worker     /**
141*0e209d39SAndroid Build Coastguard Worker      * Sets the region.  If region is the empty string, the region in this
142*0e209d39SAndroid Build Coastguard Worker      * <code>LocaleBuilder</code> is removed. Otherwise, the <code>region</code>
143*0e209d39SAndroid Build Coastguard Worker      * must be well-formed, or else the build() method will later report an
144*0e209d39SAndroid Build Coastguard Worker      * U_ILLEGAL_ARGUMENT_ERROR.
145*0e209d39SAndroid Build Coastguard Worker      *
146*0e209d39SAndroid Build Coastguard Worker      * <p>The region value is defined by
147*0e209d39SAndroid Build Coastguard Worker      *  [unicode_region_subtag](http://www.unicode.org/reports/tr35/tr35.html#unicode_region_subtag)
148*0e209d39SAndroid Build Coastguard Worker      * as a two-letter ISO 3166 code or a three-digit UN M.49 area code.
149*0e209d39SAndroid Build Coastguard Worker      *
150*0e209d39SAndroid Build Coastguard Worker      * <p>The region value in the <code>Locale</code> created by the
151*0e209d39SAndroid Build Coastguard Worker      * <code>LocaleBuilder</code> is always normalized to upper case.
152*0e209d39SAndroid Build Coastguard Worker      *
153*0e209d39SAndroid Build Coastguard Worker      * @param region the region
154*0e209d39SAndroid Build Coastguard Worker      * @return This builder.
155*0e209d39SAndroid Build Coastguard Worker      * @stable ICU 64
156*0e209d39SAndroid Build Coastguard Worker      */
157*0e209d39SAndroid Build Coastguard Worker     LocaleBuilder& setRegion(StringPiece region);
158*0e209d39SAndroid Build Coastguard Worker 
159*0e209d39SAndroid Build Coastguard Worker     /**
160*0e209d39SAndroid Build Coastguard Worker      * Sets the variant.  If variant is the empty string, the variant in this
161*0e209d39SAndroid Build Coastguard Worker      * <code>LocaleBuilder</code> is removed.  Otherwise, the <code>variant</code>
162*0e209d39SAndroid Build Coastguard Worker      * must be well-formed, or else the build() method will later report an
163*0e209d39SAndroid Build Coastguard Worker      * U_ILLEGAL_ARGUMENT_ERROR.
164*0e209d39SAndroid Build Coastguard Worker      *
165*0e209d39SAndroid Build Coastguard Worker      * <p><b>Note:</b> This method checks if <code>variant</code>
166*0e209d39SAndroid Build Coastguard Worker      * satisfies the
167*0e209d39SAndroid Build Coastguard Worker      * [unicode_variant_subtag](http://www.unicode.org/reports/tr35/tr35.html#unicode_variant_subtag)
168*0e209d39SAndroid Build Coastguard Worker      * syntax requirements, and normalizes the value to lowercase letters. However,
169*0e209d39SAndroid Build Coastguard Worker      * the <code>Locale</code> class does not impose any syntactic
170*0e209d39SAndroid Build Coastguard Worker      * restriction on variant. To set an ill-formed variant, use a Locale constructor.
171*0e209d39SAndroid Build Coastguard Worker      * If there are multiple unicode_variant_subtag, the caller must concatenate
172*0e209d39SAndroid Build Coastguard Worker      * them with '-' as separator (ex: "foobar-fibar").
173*0e209d39SAndroid Build Coastguard Worker      *
174*0e209d39SAndroid Build Coastguard Worker      * @param variant the variant
175*0e209d39SAndroid Build Coastguard Worker      * @return This builder.
176*0e209d39SAndroid Build Coastguard Worker      * @stable ICU 64
177*0e209d39SAndroid Build Coastguard Worker      */
178*0e209d39SAndroid Build Coastguard Worker     LocaleBuilder& setVariant(StringPiece variant);
179*0e209d39SAndroid Build Coastguard Worker 
180*0e209d39SAndroid Build Coastguard Worker     /**
181*0e209d39SAndroid Build Coastguard Worker      * Sets the extension for the given key. If the value is the empty string,
182*0e209d39SAndroid Build Coastguard Worker      * the extension is removed.  Otherwise, the <code>key</code> and
183*0e209d39SAndroid Build Coastguard Worker      * <code>value</code> must be well-formed, or else the build() method will
184*0e209d39SAndroid Build Coastguard Worker      * later report an U_ILLEGAL_ARGUMENT_ERROR.
185*0e209d39SAndroid Build Coastguard Worker      *
186*0e209d39SAndroid Build Coastguard Worker      * <p><b>Note:</b> The key ('u') is used for the Unicode locale extension.
187*0e209d39SAndroid Build Coastguard Worker      * Setting a value for this key replaces any existing Unicode locale key/type
188*0e209d39SAndroid Build Coastguard Worker      * pairs with those defined in the extension.
189*0e209d39SAndroid Build Coastguard Worker      *
190*0e209d39SAndroid Build Coastguard Worker      * <p><b>Note:</b> The key ('x') is used for the private use code. To be
191*0e209d39SAndroid Build Coastguard Worker      * well-formed, the value for this key needs only to have subtags of one to
192*0e209d39SAndroid Build Coastguard Worker      * eight alphanumeric characters, not two to eight as in the general case.
193*0e209d39SAndroid Build Coastguard Worker      *
194*0e209d39SAndroid Build Coastguard Worker      * @param key the extension key
195*0e209d39SAndroid Build Coastguard Worker      * @param value the extension value
196*0e209d39SAndroid Build Coastguard Worker      * @return This builder.
197*0e209d39SAndroid Build Coastguard Worker      * @stable ICU 64
198*0e209d39SAndroid Build Coastguard Worker      */
199*0e209d39SAndroid Build Coastguard Worker     LocaleBuilder& setExtension(char key, StringPiece value);
200*0e209d39SAndroid Build Coastguard Worker 
201*0e209d39SAndroid Build Coastguard Worker     /**
202*0e209d39SAndroid Build Coastguard Worker      * Sets the Unicode locale keyword type for the given key. If the type
203*0e209d39SAndroid Build Coastguard Worker      * StringPiece is constructed with a nullptr, the keyword is removed.
204*0e209d39SAndroid Build Coastguard Worker      * If the type is the empty string, the keyword is set without type subtags.
205*0e209d39SAndroid Build Coastguard Worker      * Otherwise, the key and type must be well-formed, or else the build()
206*0e209d39SAndroid Build Coastguard Worker      * method will later report an U_ILLEGAL_ARGUMENT_ERROR.
207*0e209d39SAndroid Build Coastguard Worker      *
208*0e209d39SAndroid Build Coastguard Worker      * <p>Keys and types are converted to lower case.
209*0e209d39SAndroid Build Coastguard Worker      *
210*0e209d39SAndroid Build Coastguard Worker      * <p><b>Note</b>:Setting the 'u' extension via {@link #setExtension}
211*0e209d39SAndroid Build Coastguard Worker      * replaces all Unicode locale keywords with those defined in the
212*0e209d39SAndroid Build Coastguard Worker      * extension.
213*0e209d39SAndroid Build Coastguard Worker      *
214*0e209d39SAndroid Build Coastguard Worker      * @param key the Unicode locale key
215*0e209d39SAndroid Build Coastguard Worker      * @param type the Unicode locale type
216*0e209d39SAndroid Build Coastguard Worker      * @return This builder.
217*0e209d39SAndroid Build Coastguard Worker      * @stable ICU 64
218*0e209d39SAndroid Build Coastguard Worker      */
219*0e209d39SAndroid Build Coastguard Worker     LocaleBuilder& setUnicodeLocaleKeyword(
220*0e209d39SAndroid Build Coastguard Worker         StringPiece key, StringPiece type);
221*0e209d39SAndroid Build Coastguard Worker 
222*0e209d39SAndroid Build Coastguard Worker     /**
223*0e209d39SAndroid Build Coastguard Worker      * Adds a unicode locale attribute, if not already present, otherwise
224*0e209d39SAndroid Build Coastguard Worker      * has no effect.  The attribute must not be empty string and must be
225*0e209d39SAndroid Build Coastguard Worker      * well-formed or U_ILLEGAL_ARGUMENT_ERROR will be set to status
226*0e209d39SAndroid Build Coastguard Worker      * during the build() call.
227*0e209d39SAndroid Build Coastguard Worker      *
228*0e209d39SAndroid Build Coastguard Worker      * @param attribute the attribute
229*0e209d39SAndroid Build Coastguard Worker      * @return This builder.
230*0e209d39SAndroid Build Coastguard Worker      * @stable ICU 64
231*0e209d39SAndroid Build Coastguard Worker      */
232*0e209d39SAndroid Build Coastguard Worker     LocaleBuilder& addUnicodeLocaleAttribute(StringPiece attribute);
233*0e209d39SAndroid Build Coastguard Worker 
234*0e209d39SAndroid Build Coastguard Worker     /**
235*0e209d39SAndroid Build Coastguard Worker      * Removes a unicode locale attribute, if present, otherwise has no
236*0e209d39SAndroid Build Coastguard Worker      * effect.  The attribute must not be empty string and must be well-formed
237*0e209d39SAndroid Build Coastguard Worker      * or U_ILLEGAL_ARGUMENT_ERROR will be set to status during the build() call.
238*0e209d39SAndroid Build Coastguard Worker      *
239*0e209d39SAndroid Build Coastguard Worker      * <p>Attribute comparison for removal is case-insensitive.
240*0e209d39SAndroid Build Coastguard Worker      *
241*0e209d39SAndroid Build Coastguard Worker      * @param attribute the attribute
242*0e209d39SAndroid Build Coastguard Worker      * @return This builder.
243*0e209d39SAndroid Build Coastguard Worker      * @stable ICU 64
244*0e209d39SAndroid Build Coastguard Worker      */
245*0e209d39SAndroid Build Coastguard Worker     LocaleBuilder& removeUnicodeLocaleAttribute(StringPiece attribute);
246*0e209d39SAndroid Build Coastguard Worker 
247*0e209d39SAndroid Build Coastguard Worker     /**
248*0e209d39SAndroid Build Coastguard Worker      * Resets the builder to its initial, empty state.
249*0e209d39SAndroid Build Coastguard Worker      * <p>This method clears the internal UErrorCode.
250*0e209d39SAndroid Build Coastguard Worker      *
251*0e209d39SAndroid Build Coastguard Worker      * @return this builder
252*0e209d39SAndroid Build Coastguard Worker      * @stable ICU 64
253*0e209d39SAndroid Build Coastguard Worker      */
254*0e209d39SAndroid Build Coastguard Worker     LocaleBuilder& clear();
255*0e209d39SAndroid Build Coastguard Worker 
256*0e209d39SAndroid Build Coastguard Worker     /**
257*0e209d39SAndroid Build Coastguard Worker      * Resets the extensions to their initial, empty state.
258*0e209d39SAndroid Build Coastguard Worker      * Language, script, region and variant are unchanged.
259*0e209d39SAndroid Build Coastguard Worker      *
260*0e209d39SAndroid Build Coastguard Worker      * @return this builder
261*0e209d39SAndroid Build Coastguard Worker      * @stable ICU 64
262*0e209d39SAndroid Build Coastguard Worker      */
263*0e209d39SAndroid Build Coastguard Worker     LocaleBuilder& clearExtensions();
264*0e209d39SAndroid Build Coastguard Worker 
265*0e209d39SAndroid Build Coastguard Worker     /**
266*0e209d39SAndroid Build Coastguard Worker      * Returns an instance of <code>Locale</code> created from the fields set
267*0e209d39SAndroid Build Coastguard Worker      * on this builder.
268*0e209d39SAndroid Build Coastguard Worker      * If any set methods or during the build() call require memory allocation
269*0e209d39SAndroid Build Coastguard Worker      * but fail U_MEMORY_ALLOCATION_ERROR will be set to status.
270*0e209d39SAndroid Build Coastguard Worker      * If any of the fields set by the setters are not well-formed, the status
271*0e209d39SAndroid Build Coastguard Worker      * will be set to U_ILLEGAL_ARGUMENT_ERROR. The state of the builder will
272*0e209d39SAndroid Build Coastguard Worker      * not change after the build() call and the caller is free to keep using
273*0e209d39SAndroid Build Coastguard Worker      * the same builder to build more locales.
274*0e209d39SAndroid Build Coastguard Worker      *
275*0e209d39SAndroid Build Coastguard Worker      * @return a new Locale
276*0e209d39SAndroid Build Coastguard Worker      * @stable ICU 64
277*0e209d39SAndroid Build Coastguard Worker      */
278*0e209d39SAndroid Build Coastguard Worker     Locale build(UErrorCode& status);
279*0e209d39SAndroid Build Coastguard Worker 
280*0e209d39SAndroid Build Coastguard Worker     /**
281*0e209d39SAndroid Build Coastguard Worker      * Sets the UErrorCode if an error occurred while recording sets.
282*0e209d39SAndroid Build Coastguard Worker      * Preserves older error codes in the outErrorCode.
283*0e209d39SAndroid Build Coastguard Worker      * @param outErrorCode Set to an error code that occurred while setting subtags.
284*0e209d39SAndroid Build Coastguard Worker      *                  Unchanged if there is no such error or if outErrorCode
285*0e209d39SAndroid Build Coastguard Worker      *                  already contained an error.
286*0e209d39SAndroid Build Coastguard Worker      * @return true if U_FAILURE(outErrorCode)
287*0e209d39SAndroid Build Coastguard Worker      * @stable ICU 65
288*0e209d39SAndroid Build Coastguard Worker      */
289*0e209d39SAndroid Build Coastguard Worker     UBool copyErrorTo(UErrorCode &outErrorCode) const;
290*0e209d39SAndroid Build Coastguard Worker 
291*0e209d39SAndroid Build Coastguard Worker private:
292*0e209d39SAndroid Build Coastguard Worker     friend class LocaleMatcher::Result;
293*0e209d39SAndroid Build Coastguard Worker 
294*0e209d39SAndroid Build Coastguard Worker     void copyExtensionsFrom(const Locale& src, UErrorCode& errorCode);
295*0e209d39SAndroid Build Coastguard Worker 
296*0e209d39SAndroid Build Coastguard Worker     UErrorCode status_;
297*0e209d39SAndroid Build Coastguard Worker     char language_[9];
298*0e209d39SAndroid Build Coastguard Worker     char script_[5];
299*0e209d39SAndroid Build Coastguard Worker     char region_[4];
300*0e209d39SAndroid Build Coastguard Worker     CharString *variant_;  // Pointer not object so we need not #include internal charstr.h.
301*0e209d39SAndroid Build Coastguard Worker     icu::Locale *extensions_;  // Pointer not object. Storage for all other fields.
302*0e209d39SAndroid Build Coastguard Worker 
303*0e209d39SAndroid Build Coastguard Worker };
304*0e209d39SAndroid Build Coastguard Worker 
305*0e209d39SAndroid Build Coastguard Worker U_NAMESPACE_END
306*0e209d39SAndroid Build Coastguard Worker 
307*0e209d39SAndroid Build Coastguard Worker #endif /* U_SHOW_CPLUSPLUS_API */
308*0e209d39SAndroid Build Coastguard Worker 
309*0e209d39SAndroid Build Coastguard Worker #endif  // __LOCALEBUILDER_H__
310