Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/native/common/unicode/ucat.h
38827 views
/*1**********************************************************************2* Copyright (c) 2003-2004, International Business Machines3* Corporation and others. All Rights Reserved.4**********************************************************************5* Author: Alan Liu6* Created: March 19 20037* Since: ICU 2.68**********************************************************************9*/10#ifndef UCAT_H11#define UCAT_H1213#include "unicode/utypes.h"14#include "unicode/ures.h"1516/**17* \file18* \brief C API: Message Catalog Wrappers19*20* This C API provides look-alike functions that deliberately resemble21* the POSIX catopen, catclose, and catgets functions. The underlying22* implementation is in terms of ICU resource bundles, rather than23* POSIX message catalogs.24*25* The ICU resource bundles obey standard ICU inheritance policies.26* To facilitate this, sets and messages are flattened into one tier.27* This is done by creating resource bundle keys of the form28* <set_num>%<msg_num> where set_num is the set number and msg_num is29* the message number, formatted as decimal strings.30*31* Example: Consider a message catalog containing two sets:32*33* Set 1: Message 4 = "Good morning."34* Message 5 = "Good afternoon."35* Message 7 = "Good evening."36* Message 8 = "Good night."37* Set 4: Message 14 = "Please "38* Message 19 = "Thank you."39* Message 20 = "Sincerely,"40*41* The ICU resource bundle source file would, assuming it is named42* "greet.txt", would look like this:43*44* greet45* {46* 1%4 { "Good morning." }47* 1%5 { "Good afternoon." }48* 1%7 { "Good evening." }49* 1%8 { "Good night." }50*51* 4%14 { "Please " }52* 4%19 { "Thank you." }53* 4%20 { "Sincerely," }54* }55*56* The catgets function is commonly used in combination with functions57* like printf and strftime. ICU components like message format can58* be used instead, although they use a different format syntax.59* There is an ICU package, icuio, that provides some of60* the POSIX-style formatting API.61*/6263U_CDECL_BEGIN6465/**66* An ICU message catalog descriptor, analogous to nl_catd.67*68* @stable ICU 2.669*/70typedef UResourceBundle* u_nl_catd;7172/**73* Open and return an ICU message catalog descriptor. The descriptor74* may be passed to u_catgets() to retrieve localized strings.75*76* @param name string containing the full path pointing to the77* directory where the resources reside followed by the package name78* e.g. "/usr/resource/my_app/resources/guimessages" on a Unix system.79* If NULL, ICU default data files will be used.80*81* Unlike POSIX, environment variables are not interpolated within the82* name.83*84* @param locale the locale for which we want to open the resource. If85* NULL, the default ICU locale will be used (see uloc_getDefault). If86* strlen(locale) == 0, the root locale will be used.87*88* @param ec input/output error code. Upon output,89* U_USING_FALLBACK_WARNING indicates that a fallback locale was90* used. For example, 'de_CH' was requested, but nothing was found91* there, so 'de' was used. U_USING_DEFAULT_WARNING indicates that the92* default locale data or root locale data was used; neither the93* requested locale nor any of its fallback locales were found.94*95* @return a message catalog descriptor that may be passed to96* u_catgets(). If the ec parameter indicates success, then the caller97* is responsible for calling u_catclose() to close the message98* catalog. If the ec parameter indicates failure, then NULL will be99* returned.100*101* @stable ICU 2.6102*/103U_STABLE u_nl_catd U_EXPORT2104u_catopen(const char* name, const char* locale, UErrorCode* ec);105106/**107* Close an ICU message catalog, given its descriptor.108*109* @param catd a message catalog descriptor to be closed. May be NULL,110* in which case no action is taken.111*112* @stable ICU 2.6113*/114U_STABLE void U_EXPORT2115u_catclose(u_nl_catd catd);116117/**118* Retrieve a localized string from an ICU message catalog.119*120* @param catd a message catalog descriptor returned by u_catopen.121*122* @param set_num the message catalog set number. Sets need not be123* numbered consecutively.124*125* @param msg_num the message catalog message number within the126* set. Messages need not be numbered consecutively.127*128* @param s the default string. This is returned if the string129* specified by the set_num and msg_num is not found. It must be130* zero-terminated.131*132* @param len fill-in parameter to receive the length of the result.133* May be NULL, in which case it is ignored.134*135* @param ec input/output error code. May be U_USING_FALLBACK_WARNING136* or U_USING_DEFAULT_WARNING. U_MISSING_RESOURCE_ERROR indicates that137* the set_num/msg_num tuple does not specify a valid message string138* in this catalog.139*140* @return a pointer to a zero-terminated UChar array which lives in141* an internal buffer area, typically a memory mapped/DLL file. The142* caller must NOT delete this pointer. If the call is unsuccessful143* for any reason, then s is returned. This includes the situation in144* which ec indicates a failing error code upon entry to this145* function.146*147* @stable ICU 2.6148*/149U_STABLE const UChar* U_EXPORT2150u_catgets(u_nl_catd catd, int32_t set_num, int32_t msg_num,151const UChar* s,152int32_t* len, UErrorCode* ec);153154U_CDECL_END155156#endif /*UCAT_H*/157/*eof*/158159160