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

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/intl/icu/source/i18n/unicode/uldnames.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,305 @@
     1.4 +/*
     1.5 +*******************************************************************************
     1.6 +*   Copyright (C) 2010-2012, International Business Machines Corporation and       * 
     1.7 +*   others.  All Rights Reserved.                                             *
     1.8 +*******************************************************************************
     1.9 +*/
    1.10 +
    1.11 +#ifndef __ULDNAMES_H__
    1.12 +#define __ULDNAMES_H__
    1.13 +
    1.14 +/**
    1.15 + * \file
    1.16 + * \brief C API: Provides display names of Locale ids and their components.
    1.17 + */
    1.18 +
    1.19 +#include "unicode/utypes.h"
    1.20 +#include "unicode/localpointer.h"
    1.21 +#include "unicode/uscript.h"
    1.22 +#include "unicode/udisplaycontext.h"
    1.23 +
    1.24 +/**
    1.25 + * Enum used in LocaleDisplayNames::createInstance.
    1.26 + * @stable ICU 4.4
    1.27 + */
    1.28 +typedef enum {
    1.29 +    /**
    1.30 +     * Use standard names when generating a locale name,
    1.31 +     * e.g. en_GB displays as 'English (United Kingdom)'.
    1.32 +     * @stable ICU 4.4
    1.33 +     */
    1.34 +    ULDN_STANDARD_NAMES = 0,
    1.35 +    /**
    1.36 +     * Use dialect names, when generating a locale name,
    1.37 +     * e.g. en_GB displays as 'British English'.
    1.38 +     * @stable ICU 4.4
    1.39 +     */
    1.40 +    ULDN_DIALECT_NAMES
    1.41 +} UDialectHandling;
    1.42 +
    1.43 +/**
    1.44 + * Opaque C service object type for the locale display names API
    1.45 + * @stable ICU 4.4
    1.46 + */
    1.47 +struct ULocaleDisplayNames;
    1.48 +
    1.49 +/** 
    1.50 + * C typedef for struct ULocaleDisplayNames. 
    1.51 + * @stable ICU 4.4 
    1.52 + */
    1.53 +typedef struct ULocaleDisplayNames ULocaleDisplayNames;  
    1.54 +
    1.55 +#if !UCONFIG_NO_FORMATTING
    1.56 +
    1.57 +/**
    1.58 + * Returns an instance of LocaleDisplayNames that returns names
    1.59 + * formatted for the provided locale, using the provided
    1.60 + * dialectHandling.  The usual value for dialectHandling is
    1.61 + * ULOC_STANDARD_NAMES.
    1.62 + *
    1.63 + * @param locale the display locale 
    1.64 + * @param dialectHandling how to select names for locales 
    1.65 + * @return a ULocaleDisplayNames instance 
    1.66 + * @param pErrorCode the status code
    1.67 + * @stable ICU 4.4
    1.68 + */
    1.69 +U_STABLE ULocaleDisplayNames * U_EXPORT2
    1.70 +uldn_open(const char * locale,
    1.71 +          UDialectHandling dialectHandling,
    1.72 +          UErrorCode *pErrorCode);
    1.73 +
    1.74 +/**
    1.75 + * Closes a ULocaleDisplayNames instance obtained from uldn_open().
    1.76 + * @param ldn the ULocaleDisplayNames instance to be closed
    1.77 + * @stable ICU 4.4
    1.78 + */
    1.79 +U_STABLE void U_EXPORT2
    1.80 +uldn_close(ULocaleDisplayNames *ldn);
    1.81 +
    1.82 +#if U_SHOW_CPLUSPLUS_API
    1.83 +
    1.84 +U_NAMESPACE_BEGIN
    1.85 +
    1.86 +/**
    1.87 + * \class LocalULocaleDisplayNamesPointer
    1.88 + * "Smart pointer" class, closes a ULocaleDisplayNames via uldn_close().
    1.89 + * For most methods see the LocalPointerBase base class.
    1.90 + *
    1.91 + * @see LocalPointerBase
    1.92 + * @see LocalPointer
    1.93 + * @stable ICU 4.4
    1.94 + */
    1.95 +U_DEFINE_LOCAL_OPEN_POINTER(LocalULocaleDisplayNamesPointer, ULocaleDisplayNames, uldn_close);
    1.96 +
    1.97 +U_NAMESPACE_END
    1.98 +
    1.99 +#endif
   1.100 +
   1.101 +/* getters for state */
   1.102 +
   1.103 +/**
   1.104 + * Returns the locale used to determine the display names. This is
   1.105 + * not necessarily the same locale passed to {@link #uldn_open}.
   1.106 + * @param ldn the LocaleDisplayNames instance
   1.107 + * @return the display locale 
   1.108 + * @stable ICU 4.4
   1.109 + */
   1.110 +U_STABLE const char * U_EXPORT2
   1.111 +uldn_getLocale(const ULocaleDisplayNames *ldn);
   1.112 +
   1.113 +/**
   1.114 + * Returns the dialect handling used in the display names.
   1.115 + * @param ldn the LocaleDisplayNames instance
   1.116 + * @return the dialect handling enum
   1.117 + * @stable ICU 4.4
   1.118 + */
   1.119 +U_STABLE UDialectHandling U_EXPORT2
   1.120 +uldn_getDialectHandling(const ULocaleDisplayNames *ldn);
   1.121 +
   1.122 +/* names for entire locales */
   1.123 +
   1.124 +/**
   1.125 + * Returns the display name of the provided locale.
   1.126 + * @param ldn the LocaleDisplayNames instance
   1.127 + * @param locale the locale whose display name to return
   1.128 + * @param result receives the display name
   1.129 + * @param maxResultSize the size of the result buffer
   1.130 + * @param pErrorCode the status code
   1.131 + * @return the actual buffer size needed for the display name.  If it's
   1.132 + * greater than maxResultSize, the returned name will be truncated.
   1.133 + * @stable ICU 4.4
   1.134 + */
   1.135 +U_STABLE int32_t U_EXPORT2
   1.136 +uldn_localeDisplayName(const ULocaleDisplayNames *ldn,
   1.137 +                       const char *locale,
   1.138 +                       UChar *result,
   1.139 +                       int32_t maxResultSize,
   1.140 +                       UErrorCode *pErrorCode);
   1.141 +
   1.142 +/* names for components of a locale */
   1.143 +
   1.144 +/**
   1.145 + * Returns the display name of the provided language code.
   1.146 + * @param ldn the LocaleDisplayNames instance
   1.147 + * @param lang the language code whose display name to return
   1.148 + * @param result receives the display name
   1.149 + * @param maxResultSize the size of the result buffer
   1.150 + * @param pErrorCode the status code
   1.151 + * @return the actual buffer size needed for the display name.  If it's
   1.152 + * greater than maxResultSize, the returned name will be truncated.
   1.153 + * @stable ICU 4.4
   1.154 + */
   1.155 +U_STABLE int32_t U_EXPORT2
   1.156 +uldn_languageDisplayName(const ULocaleDisplayNames *ldn,
   1.157 +                         const char *lang,
   1.158 +                         UChar *result,
   1.159 +                         int32_t maxResultSize,
   1.160 +                         UErrorCode *pErrorCode);
   1.161 +
   1.162 +/**
   1.163 + * Returns the display name of the provided script.
   1.164 + * @param ldn the LocaleDisplayNames instance
   1.165 + * @param script the script whose display name to return
   1.166 + * @param result receives the display name
   1.167 + * @param maxResultSize the size of the result buffer
   1.168 + * @param pErrorCode the status code
   1.169 + * @return the actual buffer size needed for the display name.  If it's
   1.170 + * greater than maxResultSize, the returned name will be truncated.
   1.171 + * @stable ICU 4.4
   1.172 + */
   1.173 +U_STABLE int32_t U_EXPORT2
   1.174 +uldn_scriptDisplayName(const ULocaleDisplayNames *ldn,
   1.175 +                       const char *script,
   1.176 +                       UChar *result,
   1.177 +                       int32_t maxResultSize,
   1.178 +                       UErrorCode *pErrorCode);
   1.179 +
   1.180 +/**
   1.181 + * Returns the display name of the provided script code.
   1.182 + * @param ldn the LocaleDisplayNames instance
   1.183 + * @param scriptCode the script code whose display name to return
   1.184 + * @param result receives the display name
   1.185 + * @param maxResultSize the size of the result buffer
   1.186 + * @param pErrorCode the status code
   1.187 + * @return the actual buffer size needed for the display name.  If it's
   1.188 + * greater than maxResultSize, the returned name will be truncated.
   1.189 + * @stable ICU 4.4
   1.190 + */
   1.191 +U_STABLE int32_t U_EXPORT2
   1.192 +uldn_scriptCodeDisplayName(const ULocaleDisplayNames *ldn,
   1.193 +                           UScriptCode scriptCode,
   1.194 +                           UChar *result,
   1.195 +                           int32_t maxResultSize,
   1.196 +                           UErrorCode *pErrorCode);
   1.197 +
   1.198 +/**
   1.199 + * Returns the display name of the provided region code.
   1.200 + * @param ldn the LocaleDisplayNames instance
   1.201 + * @param region the region code whose display name to return
   1.202 + * @param result receives the display name
   1.203 + * @param maxResultSize the size of the result buffer
   1.204 + * @param pErrorCode the status code
   1.205 + * @return the actual buffer size needed for the display name.  If it's
   1.206 + * greater than maxResultSize, the returned name will be truncated.
   1.207 + * @stable ICU 4.4
   1.208 + */
   1.209 +U_STABLE int32_t U_EXPORT2
   1.210 +uldn_regionDisplayName(const ULocaleDisplayNames *ldn,
   1.211 +                       const char *region,
   1.212 +                       UChar *result,
   1.213 +                       int32_t maxResultSize,
   1.214 +                       UErrorCode *pErrorCode);
   1.215 +
   1.216 +/**
   1.217 + * Returns the display name of the provided variant
   1.218 + * @param ldn the LocaleDisplayNames instance
   1.219 + * @param variant the variant whose display name to return
   1.220 + * @param result receives the display name
   1.221 + * @param maxResultSize the size of the result buffer
   1.222 + * @param pErrorCode the status code
   1.223 + * @return the actual buffer size needed for the display name.  If it's
   1.224 + * greater than maxResultSize, the returned name will be truncated.
   1.225 + * @stable ICU 4.4
   1.226 + */
   1.227 +U_STABLE int32_t U_EXPORT2
   1.228 +uldn_variantDisplayName(const ULocaleDisplayNames *ldn,
   1.229 +                        const char *variant,
   1.230 +                        UChar *result,
   1.231 +                        int32_t maxResultSize,
   1.232 +                        UErrorCode *pErrorCode);
   1.233 +
   1.234 +/**
   1.235 + * Returns the display name of the provided locale key
   1.236 + * @param ldn the LocaleDisplayNames instance
   1.237 + * @param key the locale key whose display name to return
   1.238 + * @param result receives the display name
   1.239 + * @param maxResultSize the size of the result buffer
   1.240 + * @param pErrorCode the status code
   1.241 + * @return the actual buffer size needed for the display name.  If it's
   1.242 + * greater than maxResultSize, the returned name will be truncated.
   1.243 + * @stable ICU 4.4
   1.244 + */
   1.245 +U_STABLE int32_t U_EXPORT2
   1.246 +uldn_keyDisplayName(const ULocaleDisplayNames *ldn,
   1.247 +                    const char *key,
   1.248 +                    UChar *result,
   1.249 +                    int32_t maxResultSize,
   1.250 +                    UErrorCode *pErrorCode);
   1.251 +
   1.252 +/**
   1.253 + * Returns the display name of the provided value (used with the provided key).
   1.254 + * @param ldn the LocaleDisplayNames instance
   1.255 + * @param key the locale key
   1.256 + * @param value the locale key's value
   1.257 + * @param result receives the display name
   1.258 + * @param maxResultSize the size of the result buffer
   1.259 + * @param pErrorCode the status code
   1.260 + * @return the actual buffer size needed for the display name.  If it's
   1.261 + * greater than maxResultSize, the returned name will be truncated.
   1.262 + * @stable ICU 4.4
   1.263 + */
   1.264 +U_STABLE int32_t U_EXPORT2
   1.265 +uldn_keyValueDisplayName(const ULocaleDisplayNames *ldn,
   1.266 +                         const char *key,
   1.267 +                         const char *value,
   1.268 +                         UChar *result,
   1.269 +                         int32_t maxResultSize,
   1.270 +                         UErrorCode *pErrorCode);
   1.271 +
   1.272 +#ifndef U_HIDE_DRAFT_API
   1.273 +/**
   1.274 +* Returns an instance of LocaleDisplayNames that returns names formatted
   1.275 +* for the provided locale, using the provided UDisplayContext settings.
   1.276 +*
   1.277 +* @param locale The display locale 
   1.278 +* @param contexts List of one or more context settings (e.g. for dialect
   1.279 +*               handling, capitalization, etc.
   1.280 +* @param length Number of items in the contexts list
   1.281 +* @param pErrorCode Pointer to UErrorCode input/output status. If at entry this indicates
   1.282 +*               a failure status, the function will do nothing; otherwise this will be
   1.283 +*               updated with any new status from the function. 
   1.284 +* @return a ULocaleDisplayNames instance 
   1.285 +* @draft ICU 51
   1.286 +*/
   1.287 +U_DRAFT ULocaleDisplayNames * U_EXPORT2
   1.288 +uldn_openForContext(const char * locale, UDisplayContext *contexts,
   1.289 +                    int32_t length, UErrorCode *pErrorCode);
   1.290 +
   1.291 +/**
   1.292 +* Returns the UDisplayContext value for the specified UDisplayContextType.
   1.293 +* @param ldn the ULocaleDisplayNames instance
   1.294 +* @param type the UDisplayContextType whose value to return
   1.295 +* @param pErrorCode Pointer to UErrorCode input/output status. If at entry this indicates
   1.296 +*               a failure status, the function will do nothing; otherwise this will be
   1.297 +*               updated with any new status from the function. 
   1.298 +* @return the UDisplayContextValue for the specified type.
   1.299 +* @draft ICU 51
   1.300 +*/
   1.301 +U_DRAFT UDisplayContext U_EXPORT2
   1.302 +uldn_getContext(const ULocaleDisplayNames *ldn, UDisplayContextType type,
   1.303 +                UErrorCode *pErrorCode);
   1.304 +
   1.305 +#endif  /* U_HIDE_DRAFT_API */
   1.306 +
   1.307 +#endif  /* !UCONFIG_NO_FORMATTING */
   1.308 +#endif  /* __ULDNAMES_H__ */

mercurial