ICU 76.1 76.1
Loading...
Searching...
No Matches
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/char16ptr.h"
29#include "unicode/utypes.h"
30#include "unicode/uloc.h"
31
32#if U_SHOW_CPLUSPLUS_API
34#endif // U_SHOW_CPLUSPLUS_API
35
58struct UResourceBundle;
59
64
137
138/*
139 * Functions to create and destroy resource bundles.
140 */
141
170U_CAPI UResourceBundle* U_EXPORT2
171ures_open(const char* packageName,
172 const char* locale,
173 UErrorCode* status);
174
175
193U_CAPI UResourceBundle* U_EXPORT2
194ures_openDirect(const char* packageName,
195 const char* locale,
196 UErrorCode* status);
197
216U_CAPI UResourceBundle* U_EXPORT2
217ures_openU(const UChar* packageName,
218 const char* locale,
219 UErrorCode* status);
220
221#ifndef U_HIDE_DEPRECATED_API
238U_DEPRECATED int32_t U_EXPORT2
240 const char* resourceKey,
241 UErrorCode* err);
242#endif /* U_HIDE_DEPRECATED_API */
243
252U_CAPI void U_EXPORT2
254
255#if U_SHOW_CPLUSPLUS_API
256
257U_NAMESPACE_BEGIN
258
269
270U_NAMESPACE_END
271
272#endif
273
274#ifndef U_HIDE_DEPRECATED_API
285U_DEPRECATED const char* U_EXPORT2
287#endif /* U_HIDE_DEPRECATED_API */
288
298U_CAPI void U_EXPORT2
300 UVersionInfo versionInfo);
301
302#ifndef U_HIDE_DEPRECATED_API
315U_DEPRECATED const char* U_EXPORT2
316ures_getLocale(const UResourceBundle* resourceBundle,
317 UErrorCode* status);
318#endif /* U_HIDE_DEPRECATED_API */
319
332U_CAPI const char* U_EXPORT2
335 UErrorCode* status);
336
337
338#ifndef U_HIDE_INTERNAL_API
355U_CAPI void U_EXPORT2
357 const char* packageName,
358 const char* localeID,
359 UErrorCode* status);
360#endif /* U_HIDE_INTERNAL_API */
361
379U_CAPI const UChar* U_EXPORT2
380ures_getString(const UResourceBundle* resourceBundle,
381 int32_t* len,
382 UErrorCode* status);
383
431U_CAPI const char * U_EXPORT2
433 char *dest, int32_t *length,
434 UBool forceCopy,
435 UErrorCode *status);
436
454U_CAPI const uint8_t* U_EXPORT2
455ures_getBinary(const UResourceBundle* resourceBundle,
456 int32_t* len,
457 UErrorCode* status);
458
476U_CAPI const int32_t* U_EXPORT2
477ures_getIntVector(const UResourceBundle* resourceBundle,
478 int32_t* len,
479 UErrorCode* status);
480
497U_CAPI uint32_t U_EXPORT2
498ures_getUInt(const UResourceBundle* resourceBundle,
499 UErrorCode *status);
500
517U_CAPI int32_t U_EXPORT2
518ures_getInt(const UResourceBundle* resourceBundle,
519 UErrorCode *status);
520
531U_CAPI int32_t U_EXPORT2
532ures_getSize(const UResourceBundle *resourceBundle);
533
542U_CAPI UResType U_EXPORT2
543ures_getType(const UResourceBundle *resourceBundle);
544
553U_CAPI const char * U_EXPORT2
554ures_getKey(const UResourceBundle *resourceBundle);
555
556/* ITERATION API
557 This API provides means for iterating through a resource
558*/
559
566U_CAPI void U_EXPORT2
568
576U_CAPI UBool U_EXPORT2
577ures_hasNext(const UResourceBundle *resourceBundle);
578
591U_CAPI UResourceBundle* U_EXPORT2
593 UResourceBundle *fillIn,
594 UErrorCode *status);
595
608U_CAPI const UChar* U_EXPORT2
610 int32_t* len,
611 const char ** key,
612 UErrorCode *status);
613
626U_CAPI UResourceBundle* U_EXPORT2
627ures_getByIndex(const UResourceBundle *resourceBundle,
628 int32_t indexR,
629 UResourceBundle *fillIn,
630 UErrorCode *status);
631
643U_CAPI const UChar* U_EXPORT2
645 int32_t indexS,
646 int32_t* len,
647 UErrorCode *status);
648
697U_CAPI const char * U_EXPORT2
699 int32_t stringIndex,
700 char *dest, int32_t *pLength,
701 UBool forceCopy,
702 UErrorCode *status);
703
716U_CAPI UResourceBundle* U_EXPORT2
717ures_getByKey(const UResourceBundle *resourceBundle,
718 const char* key,
719 UResourceBundle *fillIn,
720 UErrorCode *status);
721
734U_CAPI const UChar* U_EXPORT2
736 const char* key,
737 int32_t* len,
738 UErrorCode *status);
739
790U_CAPI const char * U_EXPORT2
792 const char *key,
793 char *dest, int32_t *pLength,
794 UBool forceCopy,
795 UErrorCode *status);
796
797#if U_SHOW_CPLUSPLUS_API
798#include "unicode/unistr.h"
799
800U_NAMESPACE_BEGIN
812inline UnicodeString
815 int32_t len = 0;
816 const char16_t *r = ConstChar16Ptr(ures_getString(resB, &len, status));
817 if(U_SUCCESS(*status)) {
818 result.setTo(true, r, len);
819 } else {
820 result.setToBogus();
821 }
822 return result;
823}
824
837inline UnicodeString
840 int32_t len = 0;
841 const char16_t* r = ConstChar16Ptr(ures_getNextString(resB, &len, key, status));
842 if(U_SUCCESS(*status)) {
843 result.setTo(true, r, len);
844 } else {
845 result.setToBogus();
846 }
847 return result;
848}
849
859inline UnicodeString
862 int32_t len = 0;
863 const char16_t* r = ConstChar16Ptr(ures_getStringByIndex(resB, indexS, &len, status));
864 if(U_SUCCESS(*status)) {
865 result.setTo(true, r, len);
866 } else {
867 result.setToBogus();
868 }
869 return result;
870}
871
882inline UnicodeString
885 int32_t len = 0;
886 const char16_t* r = ConstChar16Ptr(ures_getStringByKey(resB, key, &len, status));
887 if(U_SUCCESS(*status)) {
888 result.setTo(true, r, len);
889 } else {
890 result.setToBogus();
891 }
892 return result;
893}
894
895U_NAMESPACE_END
896
897#endif
898
907U_CAPI UEnumeration* U_EXPORT2
908ures_openAvailableLocales(const char *packageName, UErrorCode *status);
909
910
911#endif /*_URES*/
912/*eof*/
C++ API: char16_t pointer wrappers with implicit conversion from bit-compatible raw pointer types.
"Smart pointer" class, closes a UResourceBundle via ures_close().
const char16_t * wrapper with implicit conversion from distinct but bit-compatible pointer types.
Definition char16ptr.h:150
"Smart pointer" base class; do not use directly: use LocalPointer etc.
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition unistr.h:296
C++ API: "Smart pointers" for use with and in ICU4C C++ code.
#define U_DEFINE_LOCAL_OPEN_POINTER(LocalPointerClassName, Type, closeFunction)
"Smart pointer" definition macro, deletes objects via the closeFunction.
UnicodeString ures_getUnicodeString(const UResourceBundle *resB, UErrorCode *status)
Returns the string value from a string resource bundle.
Definition ures.h:813
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:860
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:838
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:883
struct UEnumeration UEnumeration
structure representing an enumeration object instance
Definition uenum.h:44
C API: Locale ID functionality similar to C++ class Locale.
ULocDataLocaleType
Constants for *_getLocale() Allow user to select whether she wants information on requested,...
Definition uloc.h:338
#define U_DEPRECATED
This is used to declare a function as a deprecated public ICU C API
Definition umachine.h:116
int8_t UBool
The ICU boolean type, a signed-byte integer.
Definition umachine.h:247
#define U_CAPI
This is used to declare a function as a public ICU C API.
Definition umachine.h:110
char16_t UChar
The base type for UTF-16 code units and pointers.
Definition umachine.h:378
C++ API: Unicode String.
int32_t ures_countArrayItems(const UResourceBundle *resourceBundle, const char *resourceKey, UErrorCode *err)
Returns the number of strings/arrays in resource bundles.
U_CAPI int32_t ures_getInt(const UResourceBundle *resourceBundle, UErrorCode *status)
Returns a signed integer from a resource.
U_CAPI 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.
U_CAPI int32_t ures_getSize(const UResourceBundle *resourceBundle)
Returns the size of a resource.
U_CAPI const UChar * ures_getString(const UResourceBundle *resourceBundle, int32_t *len, UErrorCode *status)
Returns a string from a string resource type.
U_CAPI 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_CAPI 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.
const char * ures_getVersionNumber(const UResourceBundle *resourceBundle)
Return the version number associated with this ResourceBundle as a string.
U_CAPI UResourceBundle * ures_openDirect(const char *packageName, const char *locale, UErrorCode *status)
This function does not care what kind of localeID is passed in.
U_CAPI 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.
U_CAPI 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_CAPI void ures_resetIterator(UResourceBundle *resourceBundle)
Resets the internal context of a resource so that iteration starts from the first element.
UResType
Numeric constants for types of resource items.
Definition ures.h:70
@ RES_BINARY
Definition ures.h:116
@ URES_TABLE
Resource type constant for tables of key-value pairs.
Definition ures.h:81
@ RES_ARRAY
Definition ures.h:124
@ URES_ALIAS
Resource type constant for aliases; internally stores a string which identifies the actual resource s...
Definition ures.h:90
@ URES_INT_VECTOR
Resource type constant for vectors of 32-bit integers.
Definition ures.h:109
@ URES_BINARY
Resource type constant for binary data.
Definition ures.h:78
@ RES_NONE
Definition ures.h:112
@ URES_ARRAY
Resource type constant for arrays of resources.
Definition ures.h:102
@ URES_NONE
Resource type constant for "no resource".
Definition ures.h:72
@ RES_RESERVED
Definition ures.h:128
@ URES_STRING
Resource type constant for 16-bit Unicode strings.
Definition ures.h:75
@ RES_INT_VECTOR
Definition ures.h:126
@ URES_INT
Resource type constant for a single 28-bit integer, interpreted as signed or unsigned by the ures_get...
Definition ures.h:99
@ RES_TABLE
Definition ures.h:118
@ RES_STRING
Definition ures.h:114
@ RES_ALIAS
Definition ures.h:120
@ RES_INT
Definition ures.h:122
@ URES_LIMIT
One more than the highest normal UResType value.
Definition ures.h:134
U_CAPI UResType ures_getType(const UResourceBundle *resourceBundle)
Returns the type of a resource.
U_CAPI UBool ures_hasNext(const UResourceBundle *resourceBundle)
Checks whether the given resource has another element to iterate over.
U_CAPI void ures_close(UResourceBundle *resourceBundle)
Close a resource bundle, all pointers returned from the various ures_getXXX calls on this particular ...
struct UResourceBundle UResourceBundle
Definition ures.h:63
const char * ures_getLocale(const UResourceBundle *resourceBundle, UErrorCode *status)
Return the name of the Locale associated with this ResourceBundle.
U_CAPI const char * ures_getKey(const UResourceBundle *resourceBundle)
Returns the key associated with a given resource.
U_CAPI 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.
U_CAPI 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.
U_CAPI UResourceBundle * ures_getByIndex(const UResourceBundle *resourceBundle, int32_t indexR, UResourceBundle *fillIn, UErrorCode *status)
Returns the resource in a given resource at the specified index.
U_CAPI 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.
U_CAPI UEnumeration * ures_openAvailableLocales(const char *packageName, UErrorCode *status)
Create a string enumerator, owned by the caller, of all locales located within the specified resource...
U_CAPI uint32_t ures_getUInt(const UResourceBundle *resourceBundle, UErrorCode *status)
Returns an unsigned integer from a resource.
U_CAPI const uint8_t * ures_getBinary(const UResourceBundle *resourceBundle, int32_t *len, UErrorCode *status)
Returns a binary data from a binary resource.
U_CAPI UResourceBundle * ures_openU(const UChar *packageName, const char *locale, UErrorCode *status)
Same as ures_open() but takes a const UChar *path.
U_CAPI 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.
U_CAPI const int32_t * ures_getIntVector(const UResourceBundle *resourceBundle, int32_t *len, UErrorCode *status)
Returns a 32 bit integer array from a resource.
U_CAPI void ures_getVersion(const UResourceBundle *resB, UVersionInfo versionInfo)
Return the version number associated with this ResourceBundle as an UVersionInfo array.
U_CAPI 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.
U_CAPI const char * ures_getLocaleByType(const UResourceBundle *resourceBundle, ULocDataLocaleType type, UErrorCode *status)
Return the name of the Locale associated with this ResourceBundle.
Basic definitions for ICU, for both C and C++ APIs.
UErrorCode
Standard ICU4C error code type, a substitute for exceptions.
Definition utypes.h:430
#define U_SUCCESS(x)
Does the error code indicate success?
Definition utypes.h:742
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