ICU 65.1 65.1

ures.h
Go to the documentation of this file.
1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
3 /*
4 **********************************************************************
5 * Copyright (C) 1997-2016, International Business Machines
6 * Corporation and others. All Rights Reserved.
7 **********************************************************************
8 *
9 * File URES.H (formerly CRESBUND.H)
10 *
11 * Modification History:
12 *
13 * Date Name Description
14 * 04/01/97 aliu Creation.
15 * 02/22/99 damiba overhaul.
16 * 04/04/99 helena Fixed internal header inclusion.
17 * 04/15/99 Madhu Updated Javadoc
18 * 06/14/99 stephen Removed functions taking a filename suffix.
19 * 07/20/99 stephen Language-independent typedef to void*
20 * 11/09/99 weiv Added ures_getLocale()
21 * 06/24/02 weiv Added support for resource sharing
22 ******************************************************************************
23 */
24
25 #ifndef URES_H
26 #define URES_H
27
28 #include "unicode/utypes.h"
29 #include "unicode/uloc.h"
30 #include "unicode/localpointer.h"
31
54 struct UResourceBundle;
55
59 typedef struct UResourceBundle UResourceBundle;
60
66 typedef enum {
68 URES_NONE=-1,
69
71 URES_STRING=0,
72
74 URES_BINARY=1,
75
77 URES_TABLE=2,
78
86 URES_ALIAS=3,
87
95 URES_INT=7,
96
98 URES_ARRAY=8,
99
105 URES_INT_VECTOR = 14,
106 #ifndef U_HIDE_DEPRECATED_API
107
108 RES_NONE=URES_NONE,
110 RES_STRING=URES_STRING,
112 RES_BINARY=URES_BINARY,
114 RES_TABLE=URES_TABLE,
116 RES_ALIAS=URES_ALIAS,
118 RES_INT=URES_INT,
120 RES_ARRAY=URES_ARRAY,
122 RES_INT_VECTOR=URES_INT_VECTOR,
124 RES_RESERVED=15,
125
130 URES_LIMIT = 16
131 #endif // U_HIDE_DEPRECATED_API
132 } UResType;
133
134 /*
135 * Functions to create and destroy resource bundles.
136 */
137
166 U_STABLE UResourceBundle* U_EXPORT2
167 ures_open(const char* packageName,
168 const char* locale,
169 UErrorCode* status);
170
171
189 U_STABLE UResourceBundle* U_EXPORT2
190 ures_openDirect(const char* packageName,
191 const char* locale,
192 UErrorCode* status);
193
212 U_STABLE UResourceBundle* U_EXPORT2
213 ures_openU(const UChar* packageName,
214 const char* locale,
215 UErrorCode* status);
216
217 #ifndef U_HIDE_DEPRECATED_API
218
234 U_DEPRECATED int32_t U_EXPORT2
235 ures_countArrayItems(const UResourceBundle* resourceBundle,
236 const char* resourceKey,
237 UErrorCode* err);
238 #endif /* U_HIDE_DEPRECATED_API */
239
248 U_STABLE void U_EXPORT2
249 ures_close(UResourceBundle* resourceBundle);
250
251 #if U_SHOW_CPLUSPLUS_API
252
253 U_NAMESPACE_BEGIN
254
264 U_DEFINE_LOCAL_OPEN_POINTER(LocalUResourceBundlePointer, UResourceBundle, ures_close);
265
266 U_NAMESPACE_END
267
268 #endif
269
270 #ifndef U_HIDE_DEPRECATED_API
271
281 U_DEPRECATED const char* U_EXPORT2
282 ures_getVersionNumber(const UResourceBundle* resourceBundle);
283 #endif /* U_HIDE_DEPRECATED_API */
284
294 U_STABLE void U_EXPORT2
295 ures_getVersion(const UResourceBundle* resB,
296 UVersionInfo versionInfo);
297
298 #ifndef U_HIDE_DEPRECATED_API
299
311 U_DEPRECATED const char* U_EXPORT2
312 ures_getLocale(const UResourceBundle* resourceBundle,
313 UErrorCode* status);
314 #endif /* U_HIDE_DEPRECATED_API */
315
328 U_STABLE const char* U_EXPORT2
329 ures_getLocaleByType(const UResourceBundle* resourceBundle,
330 ULocDataLocaleType type,
331 UErrorCode* status);
332
333
334 #ifndef U_HIDE_INTERNAL_API
335
351 U_INTERNAL void U_EXPORT2
352 ures_openFillIn(UResourceBundle *r,
353 const char* packageName,
354 const char* localeID,
355 UErrorCode* status);
356 #endif /* U_HIDE_INTERNAL_API */
357
375 U_STABLE const UChar* U_EXPORT2
376 ures_getString(const UResourceBundle* resourceBundle,
377 int32_t* len,
378 UErrorCode* status);
379
427 U_STABLE const char * U_EXPORT2
428 ures_getUTF8String(const UResourceBundle *resB,
429 char *dest, int32_t *length,
430 UBool forceCopy,
431 UErrorCode *status);
432
450 U_STABLE const uint8_t* U_EXPORT2
451 ures_getBinary(const UResourceBundle* resourceBundle,
452 int32_t* len,
453 UErrorCode* status);
454
472 U_STABLE const int32_t* U_EXPORT2
473 ures_getIntVector(const UResourceBundle* resourceBundle,
474 int32_t* len,
475 UErrorCode* status);
476
493 U_STABLE uint32_t U_EXPORT2
494 ures_getUInt(const UResourceBundle* resourceBundle,
495 UErrorCode *status);
496
513 U_STABLE int32_t U_EXPORT2
514 ures_getInt(const UResourceBundle* resourceBundle,
515 UErrorCode *status);
516
527 U_STABLE int32_t U_EXPORT2
528 ures_getSize(const UResourceBundle *resourceBundle);
529
538 U_STABLE UResType U_EXPORT2
539 ures_getType(const UResourceBundle *resourceBundle);
540
549 U_STABLE const char * U_EXPORT2
550 ures_getKey(const UResourceBundle *resourceBundle);
551
552 /* ITERATION API
553 This API provides means for iterating through a resource
554 */
555
562 U_STABLE void U_EXPORT2
563 ures_resetIterator(UResourceBundle *resourceBundle);
564
572 U_STABLE UBool U_EXPORT2
573 ures_hasNext(const UResourceBundle *resourceBundle);
574
587 U_STABLE UResourceBundle* U_EXPORT2
588 ures_getNextResource(UResourceBundle *resourceBundle,
589 UResourceBundle *fillIn,
590 UErrorCode *status);
591
604 U_STABLE const UChar* U_EXPORT2
605 ures_getNextString(UResourceBundle *resourceBundle,
606 int32_t* len,
607 const char ** key,
608 UErrorCode *status);
609
622 U_STABLE UResourceBundle* U_EXPORT2
623 ures_getByIndex(const UResourceBundle *resourceBundle,
624 int32_t indexR,
625 UResourceBundle *fillIn,
626 UErrorCode *status);
627
639 U_STABLE const UChar* U_EXPORT2
640 ures_getStringByIndex(const UResourceBundle *resourceBundle,
641 int32_t indexS,
642 int32_t* len,
643 UErrorCode *status);
644
693 U_STABLE const char * U_EXPORT2
694 ures_getUTF8StringByIndex(const UResourceBundle *resB,
695 int32_t stringIndex,
696 char *dest, int32_t *pLength,
697 UBool forceCopy,
698 UErrorCode *status);
699
712 U_STABLE UResourceBundle* U_EXPORT2
713 ures_getByKey(const UResourceBundle *resourceBundle,
714 const char* key,
715 UResourceBundle *fillIn,
716 UErrorCode *status);
717
730 U_STABLE const UChar* U_EXPORT2
731 ures_getStringByKey(const UResourceBundle *resB,
732 const char* key,
733 int32_t* len,
734 UErrorCode *status);
735
786 U_STABLE const char * U_EXPORT2
787 ures_getUTF8StringByKey(const UResourceBundle *resB,
788 const char *key,
789 char *dest, int32_t *pLength,
790 UBool forceCopy,
791 UErrorCode *status);
792
793 #if U_SHOW_CPLUSPLUS_API
794 #include "unicode/unistr.h"
795
796 U_NAMESPACE_BEGIN
808 inline UnicodeString
809 ures_getUnicodeString(const UResourceBundle *resB, UErrorCode* status) {
810 UnicodeString result;
811 int32_t len = 0;
812 const UChar *r = ures_getString(resB, &len, status);
813 if(U_SUCCESS(*status)) {
814 result.setTo(TRUE, r, len);
815 } else {
816 result.setToBogus();
817 }
818 return result;
819 }
820
833 inline UnicodeString
834 ures_getNextUnicodeString(UResourceBundle *resB, const char ** key, UErrorCode* status) {
835 UnicodeString result;
836 int32_t len = 0;
837 const UChar* r = ures_getNextString(resB, &len, key, status);
838 if(U_SUCCESS(*status)) {
839 result.setTo(TRUE, r, len);
840 } else {
841 result.setToBogus();
842 }
843 return result;
844 }
845
855 inline UnicodeString
856 ures_getUnicodeStringByIndex(const UResourceBundle *resB, int32_t indexS, UErrorCode* status) {
857 UnicodeString result;
858 int32_t len = 0;
859 const UChar* r = ures_getStringByIndex(resB, indexS, &len, status);
860 if(U_SUCCESS(*status)) {
861 result.setTo(TRUE, r, len);
862 } else {
863 result.setToBogus();
864 }
865 return result;
866 }
867
878 inline UnicodeString
879 ures_getUnicodeStringByKey(const UResourceBundle *resB, const char* key, UErrorCode* status) {
880 UnicodeString result;
881 int32_t len = 0;
882 const UChar* r = ures_getStringByKey(resB, key, &len, status);
883 if(U_SUCCESS(*status)) {
884 result.setTo(TRUE, r, len);
885 } else {
886 result.setToBogus();
887 }
888 return result;
889 }
890
891 U_NAMESPACE_END
892
893 #endif
894
903 U_STABLE UEnumeration* U_EXPORT2
904 ures_openAvailableLocales(const char *packageName, UErrorCode *status);
905
906
907 #endif /*_URES*/
908 /*eof*/
UVersionInfo
uint8_t UVersionInfo[U_MAX_VERSION_LENGTH]
The binary form of a version on ICU APIs is an array of 4 uint8_t.
Definition: uversion.h:59
ures_openU
UResourceBundle * ures_openU(const UChar *packageName, const char *locale, UErrorCode *status)
Same as ures_open() but takes a const UChar *path.
icu::UnicodeString::setTo
UnicodeString & setTo(const UnicodeString &srcText, int32_t srcStart)
Set the text in the UnicodeString object to the characters in srcText in the range [srcStart...
Definition: unistr.h:4585
ures_getString
const UChar * ures_getString(const UResourceBundle *resourceBundle, int32_t *len, UErrorCode *status)
Returns a string from a string resource type.
ures_hasNext
UBool ures_hasNext(const UResourceBundle *resourceBundle)
Checks whether the given resource has another element to iterate over.
URES_BINARY
Resource type constant for binary data.
Definition: ures.h:74
ures_getUTF8String
const char * ures_getUTF8String(const UResourceBundle *resB, char *dest, int32_t *length, UBool forceCopy, UErrorCode *status)
Returns a UTF-8 string from a string resource.
RES_ARRAY
Definition: ures.h:120
ures_getUTF8StringByIndex
const char * ures_getUTF8StringByIndex(const UResourceBundle *resB, int32_t stringIndex, char *dest, int32_t *pLength, UBool forceCopy, UErrorCode *status)
Returns a UTF-8 string from a resource at the specified index.
U_SUCCESS
#define U_SUCCESS(x)
Does the error code indicate success?
Definition: utypes.h:704
URES_INT_VECTOR
Resource type constant for vectors of 32-bit integers.
Definition: ures.h:105
ures_getInt
int32_t ures_getInt(const UResourceBundle *resourceBundle, UErrorCode *status)
Returns a signed integer from a resource.
RES_INT_VECTOR
Definition: ures.h:122
RES_NONE
Definition: ures.h:108
ures_getVersion
void ures_getVersion(const UResourceBundle *resB, UVersionInfo versionInfo)
Return the version number associated with this ResourceBundle as an UVersionInfo array.
unistr.h
C++ API: Unicode String.
UEnumeration
struct UEnumeration UEnumeration
structure representing an enumeration object instance
Definition: uenum.h:43
URES_LIMIT
One more than the highest normal UResType value.
Definition: ures.h:130
icu::ures_getUnicodeString
UnicodeString ures_getUnicodeString(const UResourceBundle *resB, UErrorCode *status)
Returns the string value from a string resource bundle.
Definition: ures.h:809
ures_getKey
const char * ures_getKey(const UResourceBundle *resourceBundle)
Returns the key associated with a given resource.
RES_ALIAS
Definition: ures.h:116
U_INTERNAL
#define U_INTERNAL
This is used to declare a function as an internal ICU C API.
Definition: umachine.h:119
ures_getUTF8StringByKey
const char * ures_getUTF8StringByKey(const UResourceBundle *resB, const char *key, char *dest, int32_t *pLength, UBool forceCopy, UErrorCode *status)
Returns a UTF-8 string from a resource and a key.
ures_getByIndex
UResourceBundle * ures_getByIndex(const UResourceBundle *resourceBundle, int32_t indexR, UResourceBundle *fillIn, UErrorCode *status)
Returns the resource in a given resource at the specified index.
ures_getVersionNumber
const char * ures_getVersionNumber(const UResourceBundle *resourceBundle)
Return the version number associated with this ResourceBundle as a string.
ures_openDirect
UResourceBundle * ures_openDirect(const char *packageName, const char *locale, UErrorCode *status)
This function does not care what kind of localeID is passed in.
URES_NONE
Resource type constant for "no resource".
Definition: ures.h:68
ures_open
UResourceBundle * ures_open(const char *packageName, const char *locale, UErrorCode *status)
Opens a UResourceBundle, from which users can extract strings by using their corresponding keys...
U_DEPRECATED
#define U_DEPRECATED
This is used to declare a function as a deprecated public ICU C API.
Definition: umachine.h:115
URES_INT
Resource type constant for a single 28-bit integer, interpreted as signed or unsigned by the ures_get...
Definition: ures.h:95
ures_getNextString
const UChar * ures_getNextString(UResourceBundle *resourceBundle, int32_t *len, const char **key, UErrorCode *status)
Returns the next string in a given resource or NULL if there are no more resources to iterate over...
ures_getBinary
const uint8_t * ures_getBinary(const UResourceBundle *resourceBundle, int32_t *len, UErrorCode *status)
Returns a binary data from a binary resource.
icu::ures_getNextUnicodeString
UnicodeString ures_getNextUnicodeString(UResourceBundle *resB, const char **key, UErrorCode *status)
Returns the next string in a resource, or an empty string if there are no more resources to iterate o...
Definition: ures.h:834
RES_RESERVED
Definition: ures.h:124
LocalUResourceBundlePointer
"Smart pointer" class, closes a UResourceBundle via ures_close().
U_DEFINE_LOCAL_OPEN_POINTER
#define U_DEFINE_LOCAL_OPEN_POINTER(LocalPointerClassName, Type, closeFunction)
"Smart pointer" definition macro, deletes objects via the closeFunction.
Definition: localpointer.h:562
localpointer.h
C++ API: "Smart pointers" for use with and in ICU4C C++ code.
URES_TABLE
Resource type constant for tables of key-value pairs.
Definition: ures.h:77
ures_getSize
int32_t ures_getSize(const UResourceBundle *resourceBundle)
Returns the size of a resource.
UResType
UResType
Numeric constants for types of resource items.
Definition: ures.h:66
TRUE
#define TRUE
The TRUE value of a UBool.
Definition: umachine.h:265
ures_getLocale
const char * ures_getLocale(const UResourceBundle *resourceBundle, UErrorCode *status)
Return the name of the Locale associated with this ResourceBundle.
ures_resetIterator
void ures_resetIterator(UResourceBundle *resourceBundle)
Resets the internal context of a resource so that iteration starts from the first element...
URES_ARRAY
Resource type constant for arrays of resources.
Definition: ures.h:98
ures_countArrayItems
int32_t ures_countArrayItems(const UResourceBundle *resourceBundle, const char *resourceKey, UErrorCode *err)
Returns the number of strings/arrays in resource bundles.
UChar
uint16_t UChar
The base type for UTF-16 code units and pointers.
Definition: umachine.h:378
RES_BINARY
Definition: ures.h:112
ures_getType
UResType ures_getType(const UResourceBundle *resourceBundle)
Returns the type of a resource.
ures_getUInt
uint32_t ures_getUInt(const UResourceBundle *resourceBundle, UErrorCode *status)
Returns an unsigned integer from a resource.
ures_getIntVector
const int32_t * ures_getIntVector(const UResourceBundle *resourceBundle, int32_t *len, UErrorCode *status)
Returns a 32 bit integer array from a resource.
ures_getStringByIndex
const UChar * ures_getStringByIndex(const UResourceBundle *resourceBundle, int32_t indexS, int32_t *len, UErrorCode *status)
Returns the string in a given resource at the specified index.
UErrorCode
UErrorCode
Standard ICU4C error code type, a substitute for exceptions.
Definition: utypes.h:415
ULocDataLocaleType
ULocDataLocaleType
Constants for *_getLocale() Allow user to select whether she wants information on requested...
Definition: uloc.h:338
RES_INT
Definition: ures.h:118
ures_getStringByKey
const UChar * ures_getStringByKey(const UResourceBundle *resB, const char *key, int32_t *len, UErrorCode *status)
Returns a string in a given resource that has a given key.
URES_STRING
Resource type constant for 16-bit Unicode strings.
Definition: ures.h:71
ures_openAvailableLocales
UEnumeration * ures_openAvailableLocales(const char *packageName, UErrorCode *status)
Create a string enumerator, owned by the caller, of all locales located within the specified resource...
ures_getLocaleByType
const char * ures_getLocaleByType(const UResourceBundle *resourceBundle, ULocDataLocaleType type, UErrorCode *status)
Return the name of the Locale associated with this ResourceBundle.
ures_getByKey
UResourceBundle * ures_getByKey(const UResourceBundle *resourceBundle, const char *key, UResourceBundle *fillIn, UErrorCode *status)
Returns a resource in a given resource that has a given key.
utypes.h
Basic definitions for ICU, for both C and C++ APIs.
RES_STRING
Definition: ures.h:110
icu::UnicodeString::setToBogus
void setToBogus()
Make this UnicodeString object invalid.
icu::ures_getUnicodeStringByKey
UnicodeString ures_getUnicodeStringByKey(const UResourceBundle *resB, const char *key, UErrorCode *status)
Returns a string in a resource that has a given key.
Definition: ures.h:879
icu::ures_getUnicodeStringByIndex
UnicodeString ures_getUnicodeStringByIndex(const UResourceBundle *resB, int32_t indexS, UErrorCode *status)
Returns the string in a given resource array or table at the specified index.
Definition: ures.h:856
icu::UnicodeString
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition: unistr.h:294
RES_TABLE
Definition: ures.h:114
UResourceBundle
struct UResourceBundle UResourceBundle
Definition: ures.h:59
ures_openFillIn
void ures_openFillIn(UResourceBundle *r, const char *packageName, const char *localeID, UErrorCode *status)
Same as ures_open() but uses the fill-in parameter instead of allocating a new bundle.
URES_ALIAS
Resource type constant for aliases; internally stores a string which identifies the actual resource s...
Definition: ures.h:86
ures_getNextResource
UResourceBundle * ures_getNextResource(UResourceBundle *resourceBundle, UResourceBundle *fillIn, UErrorCode *status)
Returns the next resource in a given resource or NULL if there are no more resources to iterate over...
ures_close
void ures_close(UResourceBundle *resourceBundle)
Close a resource bundle, all pointers returned from the various ures_getXXX calls on this particular ...
U_STABLE
#define U_STABLE
This is used to declare a function as a stable public ICU C API.
Definition: umachine.h:111
UBool
int8_t UBool
The ICU boolean type.
Definition: umachine.h:261
uloc.h
C API: Locale.