intl/icu/source/i18n/unicode/locdspnm.h

Wed, 31 Dec 2014 07:22:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 07:22:50 +0100
branch
TOR_BUG_3246
changeset 4
fc2d59ddac77
permissions
-rw-r--r--

Correct previous dual key logic pending first delivery installment.

michael@0 1 /*
michael@0 2 ******************************************************************************
michael@0 3 * Copyright (C) 2010-2012, International Business Machines Corporation and
michael@0 4 * others. All Rights Reserved.
michael@0 5 ******************************************************************************
michael@0 6 */
michael@0 7
michael@0 8 #ifndef LOCDSPNM_H
michael@0 9 #define LOCDSPNM_H
michael@0 10
michael@0 11 #include "unicode/utypes.h"
michael@0 12
michael@0 13 /**
michael@0 14 * \file
michael@0 15 * \brief C++ API: Provides display names of Locale and its components.
michael@0 16 */
michael@0 17
michael@0 18 #if !UCONFIG_NO_FORMATTING
michael@0 19
michael@0 20 #include "unicode/locid.h"
michael@0 21 #include "unicode/uscript.h"
michael@0 22 #include "unicode/uldnames.h"
michael@0 23 #include "unicode/udisplaycontext.h"
michael@0 24
michael@0 25 U_NAMESPACE_BEGIN
michael@0 26
michael@0 27 /**
michael@0 28 * Returns display names of Locales and components of Locales. For
michael@0 29 * more information on language, script, region, variant, key, and
michael@0 30 * values, see Locale.
michael@0 31 * @stable ICU 4.4
michael@0 32 */
michael@0 33 class U_I18N_API LocaleDisplayNames : public UObject {
michael@0 34 public:
michael@0 35 /**
michael@0 36 * Destructor.
michael@0 37 * @stable ICU 4.4
michael@0 38 */
michael@0 39 virtual ~LocaleDisplayNames();
michael@0 40
michael@0 41 /**
michael@0 42 * Convenience overload of
michael@0 43 * {@link #createInstance(const Locale& locale, UDialectHandling dialectHandling)}
michael@0 44 * that specifies STANDARD dialect handling.
michael@0 45 * @param locale the display locale
michael@0 46 * @return a LocaleDisplayNames instance
michael@0 47 * @stable ICU 4.4
michael@0 48 */
michael@0 49 static LocaleDisplayNames* U_EXPORT2 createInstance(const Locale& locale);
michael@0 50
michael@0 51 /**
michael@0 52 * Returns an instance of LocaleDisplayNames that returns names
michael@0 53 * formatted for the provided locale, using the provided
michael@0 54 * dialectHandling.
michael@0 55 *
michael@0 56 * @param locale the display locale
michael@0 57 * @param dialectHandling how to select names for locales
michael@0 58 * @return a LocaleDisplayNames instance
michael@0 59 * @stable ICU 4.4
michael@0 60 */
michael@0 61 static LocaleDisplayNames* U_EXPORT2 createInstance(const Locale& locale,
michael@0 62 UDialectHandling dialectHandling);
michael@0 63
michael@0 64 #ifndef U_HIDE_DRAFT_API
michael@0 65 /**
michael@0 66 * Returns an instance of LocaleDisplayNames that returns names formatted
michael@0 67 * for the provided locale, using the provided UDisplayContext settings.
michael@0 68 *
michael@0 69 * @param locale the display locale
michael@0 70 * @param contexts List of one or more context settings (e.g. for dialect
michael@0 71 * handling, capitalization, etc.
michael@0 72 * @param length Number of items in the contexts list
michael@0 73 * @return a LocaleDisplayNames instance
michael@0 74 * @draft ICU 51
michael@0 75 */
michael@0 76 static LocaleDisplayNames* U_EXPORT2 createInstance(const Locale& locale,
michael@0 77 UDisplayContext *contexts, int32_t length);
michael@0 78 #endif /* U_HIDE_DRAFT_API */
michael@0 79
michael@0 80 // getters for state
michael@0 81 /**
michael@0 82 * Returns the locale used to determine the display names. This is
michael@0 83 * not necessarily the same locale passed to {@link #createInstance}.
michael@0 84 * @return the display locale
michael@0 85 * @stable ICU 4.4
michael@0 86 */
michael@0 87 virtual const Locale& getLocale() const = 0;
michael@0 88
michael@0 89 /**
michael@0 90 * Returns the dialect handling used in the display names.
michael@0 91 * @return the dialect handling enum
michael@0 92 * @stable ICU 4.4
michael@0 93 */
michael@0 94 virtual UDialectHandling getDialectHandling() const = 0;
michael@0 95
michael@0 96 /**
michael@0 97 * Returns the UDisplayContext value for the specified UDisplayContextType.
michael@0 98 * @param type the UDisplayContextType whose value to return
michael@0 99 * @return the UDisplayContext for the specified type.
michael@0 100 * @draft ICU 51
michael@0 101 */
michael@0 102 virtual UDisplayContext getContext(UDisplayContextType type) const = 0;
michael@0 103
michael@0 104 // names for entire locales
michael@0 105 /**
michael@0 106 * Returns the display name of the provided locale.
michael@0 107 * @param locale the locale whose display name to return
michael@0 108 * @param result receives the locale's display name
michael@0 109 * @return the display name of the provided locale
michael@0 110 * @stable ICU 4.4
michael@0 111 */
michael@0 112 virtual UnicodeString& localeDisplayName(const Locale& locale,
michael@0 113 UnicodeString& result) const = 0;
michael@0 114
michael@0 115 /**
michael@0 116 * Returns the display name of the provided locale id.
michael@0 117 * @param localeId the id of the locale whose display name to return
michael@0 118 * @param result receives the locale's display name
michael@0 119 * @return the display name of the provided locale
michael@0 120 * @stable ICU 4.4
michael@0 121 */
michael@0 122 virtual UnicodeString& localeDisplayName(const char* localeId,
michael@0 123 UnicodeString& result) const = 0;
michael@0 124
michael@0 125 // names for components of a locale id
michael@0 126 /**
michael@0 127 * Returns the display name of the provided language code.
michael@0 128 * @param lang the language code
michael@0 129 * @param result receives the language code's display name
michael@0 130 * @return the display name of the provided language code
michael@0 131 * @stable ICU 4.4
michael@0 132 */
michael@0 133 virtual UnicodeString& languageDisplayName(const char* lang,
michael@0 134 UnicodeString& result) const = 0;
michael@0 135
michael@0 136 /**
michael@0 137 * Returns the display name of the provided script code.
michael@0 138 * @param script the script code
michael@0 139 * @param result receives the script code's display name
michael@0 140 * @return the display name of the provided script code
michael@0 141 * @stable ICU 4.4
michael@0 142 */
michael@0 143 virtual UnicodeString& scriptDisplayName(const char* script,
michael@0 144 UnicodeString& result) const = 0;
michael@0 145
michael@0 146 /**
michael@0 147 * Returns the display name of the provided script code.
michael@0 148 * @param scriptCode the script code number
michael@0 149 * @param result receives the script code's display name
michael@0 150 * @return the display name of the provided script code
michael@0 151 * @stable ICU 4.4
michael@0 152 */
michael@0 153 virtual UnicodeString& scriptDisplayName(UScriptCode scriptCode,
michael@0 154 UnicodeString& result) const = 0;
michael@0 155
michael@0 156 /**
michael@0 157 * Returns the display name of the provided region code.
michael@0 158 * @param region the region code
michael@0 159 * @param result receives the region code's display name
michael@0 160 * @return the display name of the provided region code
michael@0 161 * @stable ICU 4.4
michael@0 162 */
michael@0 163 virtual UnicodeString& regionDisplayName(const char* region,
michael@0 164 UnicodeString& result) const = 0;
michael@0 165
michael@0 166 /**
michael@0 167 * Returns the display name of the provided variant.
michael@0 168 * @param variant the variant string
michael@0 169 * @param result receives the variant's display name
michael@0 170 * @return the display name of the provided variant
michael@0 171 * @stable ICU 4.4
michael@0 172 */
michael@0 173 virtual UnicodeString& variantDisplayName(const char* variant,
michael@0 174 UnicodeString& result) const = 0;
michael@0 175
michael@0 176 /**
michael@0 177 * Returns the display name of the provided locale key.
michael@0 178 * @param key the locale key name
michael@0 179 * @param result receives the locale key's display name
michael@0 180 * @return the display name of the provided locale key
michael@0 181 * @stable ICU 4.4
michael@0 182 */
michael@0 183 virtual UnicodeString& keyDisplayName(const char* key,
michael@0 184 UnicodeString& result) const = 0;
michael@0 185
michael@0 186 /**
michael@0 187 * Returns the display name of the provided value (used with the provided key).
michael@0 188 * @param key the locale key name
michael@0 189 * @param value the locale key's value
michael@0 190 * @param result receives the value's display name
michael@0 191 * @return the display name of the provided value
michael@0 192 * @stable ICU 4.4
michael@0 193 */
michael@0 194 virtual UnicodeString& keyValueDisplayName(const char* key, const char* value,
michael@0 195 UnicodeString& result) const = 0;
michael@0 196 };
michael@0 197
michael@0 198 inline LocaleDisplayNames* LocaleDisplayNames::createInstance(const Locale& locale) {
michael@0 199 return LocaleDisplayNames::createInstance(locale, ULDN_STANDARD_NAMES);
michael@0 200 }
michael@0 201
michael@0 202 U_NAMESPACE_END
michael@0 203
michael@0 204 #endif
michael@0 205
michael@0 206 #endif

mercurial