ICU 57.1 57.1
ures.h
Go to the documentation of this file.
1/*
2**********************************************************************
3* Copyright (C) 1997-2016, International Business Machines
4* Corporation and others. All Rights Reserved.
5**********************************************************************
6*
7* File URES.H (formerly CRESBUND.H)
8*
9* Modification History:
10*
11* Date Name Description
12* 04/01/97 aliu Creation.
13* 02/22/99 damiba overhaul.
14* 04/04/99 helena Fixed internal header inclusion.
15* 04/15/99 Madhu Updated Javadoc
16* 06/14/99 stephen Removed functions taking a filename suffix.
17* 07/20/99 stephen Language-independent ypedef to void*
18* 11/09/99 weiv Added ures_getLocale()
19* 06/24/02 weiv Added support for resource sharing
20******************************************************************************
21*/
22
23#ifndef URES_H
24#define URES_H
25
26#include "unicode/utypes.h"
27#include "unicode/uloc.h"
29
52struct UResourceBundle;
53
58
127
128/*
129 * Functions to create and destroy resource bundles.
130 */
131
162 const char* locale,
164
165
185 const char* locale,
187
208 const char* locale,
210
211#ifndef U_HIDE_DEPRECATED_API
230 const char* resourceKey,
231 UErrorCode* err);
232#endif /* U_HIDE_DEPRECATED_API */
233
244
245#if U_SHOW_CPLUSPLUS_API
246
248
259
261
262#endif
263
264#ifndef U_HIDE_DEPRECATED_API
275U_DEPRECATED const char* U_EXPORT2
277#endif /* U_HIDE_DEPRECATED_API */
278
291
292#ifndef U_HIDE_DEPRECATED_API
305U_DEPRECATED const char* U_EXPORT2
308#endif /* U_HIDE_DEPRECATED_API */
309
322U_STABLE const char* U_EXPORT2
326
327
328#ifndef U_HIDE_INTERNAL_API
347 const char* packageName,
348 const char* localeID,
350#endif /* U_HIDE_INTERNAL_API */
351
371 int32_t* len,
373
421U_STABLE const char * U_EXPORT2
423 char *dest, int32_t *length,
426
444U_STABLE const uint8_t* U_EXPORT2
446 int32_t* len,
448
466U_STABLE const int32_t* U_EXPORT2
468 int32_t* len,
470
487U_STABLE uint32_t U_EXPORT2
490
507U_STABLE int32_t U_EXPORT2
510
521U_STABLE int32_t U_EXPORT2
523
534
543U_STABLE const char * U_EXPORT2
545
546/* ITERATION API
547 This API provides means for iterating through a resource
548*/
549
558
568
585
600 int32_t* len,
601 const char ** key,
603
618 int32_t indexR,
621
635 int32_t indexS,
636 int32_t* len,
638
687U_STABLE const char * U_EXPORT2
689 int32_t stringIndex,
690 char *dest, int32_t *pLength,
693
708 const char* key,
711
726 const char* key,
727 int32_t* len,
729
780U_STABLE const char * U_EXPORT2
782 const char *key,
783 char *dest, int32_t *pLength,
786
787#if U_SHOW_CPLUSPLUS_API
788#include "unicode/unistr.h"
789
802inline UnicodeString
805 int32_t len = 0;
806 const UChar *r = ures_getString(resB, &len, status);
807 if(U_SUCCESS(*status)) {
808 result.setTo(TRUE, r, len);
809 } else {
810 result.setToBogus();
811 }
812 return result;
813}
814
827inline UnicodeString
830 int32_t len = 0;
831 const UChar* r = ures_getNextString(resB, &len, key, status);
832 if(U_SUCCESS(*status)) {
833 result.setTo(TRUE, r, len);
834 } else {
835 result.setToBogus();
836 }
837 return result;
838}
839
849inline UnicodeString
852 int32_t len = 0;
853 const UChar* r = ures_getStringByIndex(resB, indexS, &len, status);
854 if(U_SUCCESS(*status)) {
855 result.setTo(TRUE, r, len);
856 } else {
857 result.setToBogus();
858 }
859 return result;
860}
861
872inline UnicodeString
875 int32_t len = 0;
876 const UChar* r = ures_getStringByKey(resB, key, &len, status);
877 if(U_SUCCESS(*status)) {
878 result.setTo(TRUE, r, len);
879 } else {
880 result.setToBogus();
881 }
882 return result;
883}
884
886
887#endif
888
899
900
901#endif /*_URES*/
902/*eof*/
"Smart pointer" base class; do not use directly: use LocalPointer etc.
"Smart pointer" class, closes a UResourceBundle via ures_close().
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition unistr.h:294
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.
struct UEnumeration UEnumeration
structure representing an enumeration object instance
Definition uenum.h:39
C API: Locale.
ULocDataLocaleType
Constants for *_getLocale() Allow user to select whether she wants information on requested,...
Definition uloc.h:336
#define U_DEPRECATED
This is used to declare a function as a deprecated public ICU C API
Definition umachine.h:113
#define U_INTERNAL
This is used to declare a function as an internal ICU C API
Definition umachine.h:117
int8_t UBool
The ICU boolean type.
Definition umachine.h:234
uint16_t UChar
Define UChar to be UCHAR_TYPE, if that is #defined (for example, to char16_t), or wchar_t if that is ...
Definition umachine.h:312
#define TRUE
The TRUE value of a UBool.
Definition umachine.h:238
#define U_STABLE
This is used to declare a function as a stable public ICU C API.
Definition umachine.h:109
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.
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:828
const char * ures_getVersionNumber(const UResourceBundle *resourceBundle)
Return the version number associated with this ResourceBundle as a string.
void ures_getVersion(const UResourceBundle *resB, UVersionInfo versionInfo)
Return the version number associated with this ResourceBundle as an UVersionInfo array.
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.
const int32_t * ures_getIntVector(const UResourceBundle *resourceBundle, int32_t *len, UErrorCode *status)
Returns a 32 bit integer array from a resource.
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.
UResType
Numeric constants for types of resource items.
Definition ures.h:64
@ RES_BINARY
Definition ures.h:110
@ URES_TABLE
Resource type constant for tables of key-value pairs.
Definition ures.h:75
@ RES_ARRAY
Definition ures.h:118
@ URES_ALIAS
Resource type constant for aliases; internally stores a string which identifies the actual resource s...
Definition ures.h:84
@ URES_INT_VECTOR
Resource type constant for vectors of 32-bit integers.
Definition ures.h:103
@ URES_BINARY
Resource type constant for binary data.
Definition ures.h:72
@ RES_NONE
Definition ures.h:106
@ URES_ARRAY
Resource type constant for arrays of resources.
Definition ures.h:96
@ URES_NONE
Resource type constant for "no resource".
Definition ures.h:66
@ RES_RESERVED
Definition ures.h:122
@ URES_STRING
Resource type constant for 16-bit Unicode strings.
Definition ures.h:69
@ RES_INT_VECTOR
Definition ures.h:120
@ URES_INT
Resource type constant for a single 28-bit integer, interpreted as signed or unsigned by the ures_get...
Definition ures.h:93
@ RES_TABLE
Definition ures.h:112
@ RES_STRING
Definition ures.h:108
@ RES_ALIAS
Definition ures.h:114
@ RES_INT
Definition ures.h:116
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 bundle,...
UResourceBundle * ures_getByIndex(const UResourceBundle *resourceBundle, int32_t indexR, UResourceBundle *fillIn, UErrorCode *status)
Returns the resource in a given resource at the specified index.
int32_t ures_getSize(const UResourceBundle *resourceBundle)
Returns the size of a resource.
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.
struct UResourceBundle UResourceBundle
Definition ures.h:57
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.
UResType ures_getType(const UResourceBundle *resourceBundle)
Returns the type of a resource.
UBool ures_hasNext(const UResourceBundle *resourceBundle)
Checks whether the given resource has another element to iterate over.
const char * ures_getLocale(const UResourceBundle *resourceBundle, UErrorCode *status)
Return the name of the Locale associated with this ResourceBundle.
const uint8_t * ures_getBinary(const UResourceBundle *resourceBundle, int32_t *len, UErrorCode *status)
Returns a binary data from a binary resource.
UResourceBundle * ures_openU(const UChar *packageName, const char *locale, UErrorCode *status)
Same as ures_open() but takes a const UChar *path.
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.
uint32_t ures_getUInt(const UResourceBundle *resourceBundle, UErrorCode *status)
Returns an unsigned integer from a resource.
const char * ures_getKey(const UResourceBundle *resourceBundle)
Returns the key associated with a given resource.
void ures_resetIterator(UResourceBundle *resourceBundle)
Resets the internal context of a resource so that iteration starts from the first element.
int32_t ures_getInt(const UResourceBundle *resourceBundle, UErrorCode *status)
Returns a signed integer from a resource.
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.
UResourceBundle * ures_openDirect(const char *packageName, const char *locale, UErrorCode *status)
This function does not care what kind of localeID is passed in.
U_NAMESPACE_BEGIN UnicodeString ures_getUnicodeString(const UResourceBundle *resB, UErrorCode *status)
Returns the string value from a string resource bundle.
Definition ures.h:803
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.
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:873
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.
UEnumeration * ures_openAvailableLocales(const char *packageName, UErrorCode *status)
Create a string enumerator, owned by the caller, of all locales located within the specified resource...
void ures_close(UResourceBundle *resourceBundle)
Close a resource bundle, all pointers returned from the various ures_getXXX calls on this particular ...
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:850
const UChar * ures_getString(const UResourceBundle *resourceBundle, int32_t *len, UErrorCode *status)
Returns a string from a string resource type.
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.
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
Error code to replace exception handling, so that the code is compatible with all C++ compilers,...
Definition utypes.h:476
#define U_SUCCESS(x)
Does the error code indicate success?
Definition utypes.h:709
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
Definition uversion.h:130
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:57
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition uversion.h:129