Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/unicode/uldnames.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // © 2016 and later: Unicode, Inc. and others.
0002 // License & terms of use: http://www.unicode.org/copyright.html
0003 /*
0004 *******************************************************************************
0005 *   Copyright (C) 2010-2016, International Business Machines Corporation and
0006 *   others.  All Rights Reserved.
0007 *******************************************************************************
0008 */
0009 
0010 #ifndef __ULDNAMES_H__
0011 #define __ULDNAMES_H__
0012 
0013 /**
0014  * \file
0015  * \brief C API: Provides display names of Locale ids and their components.
0016  */
0017 
0018 #include "unicode/utypes.h"
0019 #include "unicode/uscript.h"
0020 #include "unicode/udisplaycontext.h"
0021 
0022 #if U_SHOW_CPLUSPLUS_API
0023 #include "unicode/localpointer.h"
0024 #endif   // U_SHOW_CPLUSPLUS_API
0025 
0026 /**
0027  * Enum used in LocaleDisplayNames::createInstance.
0028  * @stable ICU 4.4
0029  */
0030 typedef enum {
0031     /**
0032      * Use standard names when generating a locale name,
0033      * e.g. en_GB displays as 'English (United Kingdom)'.
0034      * @stable ICU 4.4
0035      */
0036     ULDN_STANDARD_NAMES = 0,
0037     /**
0038      * Use dialect names, when generating a locale name,
0039      * e.g. en_GB displays as 'British English'.
0040      * @stable ICU 4.4
0041      */
0042     ULDN_DIALECT_NAMES
0043 } UDialectHandling;
0044 
0045 /**
0046  * Opaque C service object type for the locale display names API
0047  * @stable ICU 4.4
0048  */
0049 struct ULocaleDisplayNames;
0050 
0051 /** 
0052  * C typedef for struct ULocaleDisplayNames. 
0053  * @stable ICU 4.4 
0054  */
0055 typedef struct ULocaleDisplayNames ULocaleDisplayNames;  
0056 
0057 #if !UCONFIG_NO_FORMATTING
0058 
0059 /**
0060  * Returns an instance of LocaleDisplayNames that returns names
0061  * formatted for the provided locale, using the provided
0062  * dialectHandling.  The usual value for dialectHandling is
0063  * ULOC_STANDARD_NAMES.
0064  *
0065  * @param locale the display locale 
0066  * @param dialectHandling how to select names for locales 
0067  * @return a ULocaleDisplayNames instance 
0068  * @param pErrorCode the status code
0069  * @stable ICU 4.4
0070  */
0071 U_CAPI ULocaleDisplayNames * U_EXPORT2
0072 uldn_open(const char * locale,
0073           UDialectHandling dialectHandling,
0074           UErrorCode *pErrorCode);
0075 
0076 /**
0077  * Closes a ULocaleDisplayNames instance obtained from uldn_open().
0078  * @param ldn the ULocaleDisplayNames instance to be closed
0079  * @stable ICU 4.4
0080  */
0081 U_CAPI void U_EXPORT2
0082 uldn_close(ULocaleDisplayNames *ldn);
0083 
0084 #if U_SHOW_CPLUSPLUS_API
0085 
0086 U_NAMESPACE_BEGIN
0087 
0088 /**
0089  * \class LocalULocaleDisplayNamesPointer
0090  * "Smart pointer" class, closes a ULocaleDisplayNames via uldn_close().
0091  * For most methods see the LocalPointerBase base class.
0092  *
0093  * @see LocalPointerBase
0094  * @see LocalPointer
0095  * @stable ICU 4.4
0096  */
0097 U_DEFINE_LOCAL_OPEN_POINTER(LocalULocaleDisplayNamesPointer, ULocaleDisplayNames, uldn_close);
0098 
0099 U_NAMESPACE_END
0100 
0101 #endif
0102 
0103 /* getters for state */
0104 
0105 /**
0106  * Returns the locale used to determine the display names. This is
0107  * not necessarily the same locale passed to {@link #uldn_open}.
0108  * @param ldn the LocaleDisplayNames instance
0109  * @return the display locale 
0110  * @stable ICU 4.4
0111  */
0112 U_CAPI const char * U_EXPORT2
0113 uldn_getLocale(const ULocaleDisplayNames *ldn);
0114 
0115 /**
0116  * Returns the dialect handling used in the display names.
0117  * @param ldn the LocaleDisplayNames instance
0118  * @return the dialect handling enum
0119  * @stable ICU 4.4
0120  */
0121 U_CAPI UDialectHandling U_EXPORT2
0122 uldn_getDialectHandling(const ULocaleDisplayNames *ldn);
0123 
0124 /* names for entire locales */
0125 
0126 /**
0127  * Returns the display name of the provided locale.
0128  * @param ldn the LocaleDisplayNames instance
0129  * @param locale the locale whose display name to return
0130  * @param result receives the display name
0131  * @param maxResultSize the size of the result buffer
0132  * @param pErrorCode the status code
0133  * @return the actual buffer size needed for the display name.  If it's
0134  * greater than maxResultSize, the returned name will be truncated.
0135  * @stable ICU 4.4
0136  */
0137 U_CAPI int32_t U_EXPORT2
0138 uldn_localeDisplayName(const ULocaleDisplayNames *ldn,
0139                        const char *locale,
0140                        UChar *result,
0141                        int32_t maxResultSize,
0142                        UErrorCode *pErrorCode);
0143 
0144 /* names for components of a locale */
0145 
0146 /**
0147  * Returns the display name of the provided language code.
0148  * @param ldn the LocaleDisplayNames instance
0149  * @param lang the language code whose display name to return
0150  * @param result receives the display name
0151  * @param maxResultSize the size of the result buffer
0152  * @param pErrorCode the status code
0153  * @return the actual buffer size needed for the display name.  If it's
0154  * greater than maxResultSize, the returned name will be truncated.
0155  * @stable ICU 4.4
0156  */
0157 U_CAPI int32_t U_EXPORT2
0158 uldn_languageDisplayName(const ULocaleDisplayNames *ldn,
0159                          const char *lang,
0160                          UChar *result,
0161                          int32_t maxResultSize,
0162                          UErrorCode *pErrorCode);
0163 
0164 /**
0165  * Returns the display name of the provided script.
0166  * @param ldn the LocaleDisplayNames instance
0167  * @param script the script whose display name to return
0168  * @param result receives the display name
0169  * @param maxResultSize the size of the result buffer
0170  * @param pErrorCode the status code
0171  * @return the actual buffer size needed for the display name.  If it's
0172  * greater than maxResultSize, the returned name will be truncated.
0173  * @stable ICU 4.4
0174  */
0175 U_CAPI int32_t U_EXPORT2
0176 uldn_scriptDisplayName(const ULocaleDisplayNames *ldn,
0177                        const char *script,
0178                        UChar *result,
0179                        int32_t maxResultSize,
0180                        UErrorCode *pErrorCode);
0181 
0182 /**
0183  * Returns the display name of the provided script code.
0184  * @param ldn the LocaleDisplayNames instance
0185  * @param scriptCode the script code whose display name to return
0186  * @param result receives the display name
0187  * @param maxResultSize the size of the result buffer
0188  * @param pErrorCode the status code
0189  * @return the actual buffer size needed for the display name.  If it's
0190  * greater than maxResultSize, the returned name will be truncated.
0191  * @stable ICU 4.4
0192  */
0193 U_CAPI int32_t U_EXPORT2
0194 uldn_scriptCodeDisplayName(const ULocaleDisplayNames *ldn,
0195                            UScriptCode scriptCode,
0196                            UChar *result,
0197                            int32_t maxResultSize,
0198                            UErrorCode *pErrorCode);
0199 
0200 /**
0201  * Returns the display name of the provided region code.
0202  * @param ldn the LocaleDisplayNames instance
0203  * @param region the region code whose display name to return
0204  * @param result receives the display name
0205  * @param maxResultSize the size of the result buffer
0206  * @param pErrorCode the status code
0207  * @return the actual buffer size needed for the display name.  If it's
0208  * greater than maxResultSize, the returned name will be truncated.
0209  * @stable ICU 4.4
0210  */
0211 U_CAPI int32_t U_EXPORT2
0212 uldn_regionDisplayName(const ULocaleDisplayNames *ldn,
0213                        const char *region,
0214                        UChar *result,
0215                        int32_t maxResultSize,
0216                        UErrorCode *pErrorCode);
0217 
0218 /**
0219  * Returns the display name of the provided variant
0220  * @param ldn the LocaleDisplayNames instance
0221  * @param variant the variant whose display name to return
0222  * @param result receives the display name
0223  * @param maxResultSize the size of the result buffer
0224  * @param pErrorCode the status code
0225  * @return the actual buffer size needed for the display name.  If it's
0226  * greater than maxResultSize, the returned name will be truncated.
0227  * @stable ICU 4.4
0228  */
0229 U_CAPI int32_t U_EXPORT2
0230 uldn_variantDisplayName(const ULocaleDisplayNames *ldn,
0231                         const char *variant,
0232                         UChar *result,
0233                         int32_t maxResultSize,
0234                         UErrorCode *pErrorCode);
0235 
0236 /**
0237  * Returns the display name of the provided locale key
0238  * @param ldn the LocaleDisplayNames instance
0239  * @param key the locale key whose display name to return
0240  * @param result receives the display name
0241  * @param maxResultSize the size of the result buffer
0242  * @param pErrorCode the status code
0243  * @return the actual buffer size needed for the display name.  If it's
0244  * greater than maxResultSize, the returned name will be truncated.
0245  * @stable ICU 4.4
0246  */
0247 U_CAPI int32_t U_EXPORT2
0248 uldn_keyDisplayName(const ULocaleDisplayNames *ldn,
0249                     const char *key,
0250                     UChar *result,
0251                     int32_t maxResultSize,
0252                     UErrorCode *pErrorCode);
0253 
0254 /**
0255  * Returns the display name of the provided value (used with the provided key).
0256  * @param ldn the LocaleDisplayNames instance
0257  * @param key the locale key
0258  * @param value the locale key's value
0259  * @param result receives the display name
0260  * @param maxResultSize the size of the result buffer
0261  * @param pErrorCode the status code
0262  * @return the actual buffer size needed for the display name.  If it's
0263  * greater than maxResultSize, the returned name will be truncated.
0264  * @stable ICU 4.4
0265  */
0266 U_CAPI int32_t U_EXPORT2
0267 uldn_keyValueDisplayName(const ULocaleDisplayNames *ldn,
0268                          const char *key,
0269                          const char *value,
0270                          UChar *result,
0271                          int32_t maxResultSize,
0272                          UErrorCode *pErrorCode);
0273 
0274 /**
0275 * Returns an instance of LocaleDisplayNames that returns names formatted
0276 * for the provided locale, using the provided UDisplayContext settings.
0277 *
0278 * @param locale The display locale 
0279 * @param contexts List of one or more context settings (e.g. for dialect
0280 *               handling, capitalization, etc.
0281 * @param length Number of items in the contexts list
0282 * @param pErrorCode Pointer to UErrorCode input/output status. If at entry this indicates
0283 *               a failure status, the function will do nothing; otherwise this will be
0284 *               updated with any new status from the function. 
0285 * @return a ULocaleDisplayNames instance 
0286 * @stable ICU 51
0287 */
0288 U_CAPI ULocaleDisplayNames * U_EXPORT2
0289 uldn_openForContext(const char * locale, UDisplayContext *contexts,
0290                     int32_t length, UErrorCode *pErrorCode);
0291 
0292 /**
0293 * Returns the UDisplayContext value for the specified UDisplayContextType.
0294 * @param ldn the ULocaleDisplayNames instance
0295 * @param type the UDisplayContextType whose value to return
0296 * @param pErrorCode Pointer to UErrorCode input/output status. If at entry this indicates
0297 *               a failure status, the function will do nothing; otherwise this will be
0298 *               updated with any new status from the function. 
0299 * @return the UDisplayContextValue for the specified type.
0300 * @stable ICU 51
0301 */
0302 U_CAPI UDisplayContext U_EXPORT2
0303 uldn_getContext(const ULocaleDisplayNames *ldn, UDisplayContextType type,
0304                 UErrorCode *pErrorCode);
0305 
0306 #endif  /* !UCONFIG_NO_FORMATTING */
0307 #endif  /* __ULDNAMES_H__ */