Loading...
Searching...
No Matches
ures.h
Go to the documentation of this file.
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
**********************************************************************
* Copyright (C) 1997-2016, International Business Machines
* Corporation and others. All Rights Reserved.
**********************************************************************
*
* File URES.H (formerly CRESBUND.H)
*
* Modification History:
*
* Date Name Description
* 04/01/97 aliu Creation.
* 02/22/99 damiba overhaul.
* 04/04/99 helena Fixed internal header inclusion.
* 04/15/99 Madhu Updated Javadoc
* 06/14/99 stephen Removed functions taking a filename suffix.
* 07/20/99 stephen Language-independent typedef to void*
* 11/09/99 weiv Added ures_getLocale()
* 06/24/02 weiv Added support for resource sharing
******************************************************************************
*/
#ifndef URES_H
#define URES_H
#include "unicode/char16ptr.h"
#include "unicode/utypes.h"
#include "unicode/uloc.h"
#if U_SHOW_CPLUSPLUS_API
#include "unicode/localpointer.h"
#endif // U_SHOW_CPLUSPLUS_API
struct UResourceBundle;
typedef struct UResourceBundle UResourceBundle;
typedef enum {
URES_NONE=-1,
URES_STRING=0,
URES_BINARY=1,
URES_TABLE=2,
URES_ALIAS=3,
URES_INT=7,
URES_ARRAY=8,
URES_INT_VECTOR = 14,
#ifndef U_HIDE_DEPRECATED_API
RES_NONE=URES_NONE,
RES_STRING=URES_STRING,
RES_BINARY=URES_BINARY,
RES_TABLE=URES_TABLE,
RES_ALIAS=URES_ALIAS,
RES_INT=URES_INT,
RES_ARRAY=URES_ARRAY,
RES_INT_VECTOR=URES_INT_VECTOR,
RES_RESERVED=15,
URES_LIMIT = 16
#endif // U_HIDE_DEPRECATED_API
} UResType;
/*
* Functions to create and destroy resource bundles.
*/
U_CAPI UResourceBundle* U_EXPORT2
ures_open(const char* packageName,
const char* locale,
UErrorCode* status);
U_CAPI UResourceBundle* U_EXPORT2
ures_openDirect(const char* packageName,
const char* locale,
UErrorCode* status);
U_CAPI UResourceBundle* U_EXPORT2
ures_openU(const UChar* packageName,
const char* locale,
UErrorCode* status);
#ifndef U_HIDE_DEPRECATED_API
U_DEPRECATED int32_t U_EXPORT2
ures_countArrayItems(const UResourceBundle* resourceBundle,
const char* resourceKey,
UErrorCode* err);
#endif /* U_HIDE_DEPRECATED_API */
U_CAPI void U_EXPORT2
ures_close(UResourceBundle* resourceBundle);
#if U_SHOW_CPLUSPLUS_API
U_NAMESPACE_BEGIN
U_DEFINE_LOCAL_OPEN_POINTER(LocalUResourceBundlePointer, UResourceBundle, ures_close);
U_NAMESPACE_END
#endif
#ifndef U_HIDE_DEPRECATED_API
U_DEPRECATED const char* U_EXPORT2
ures_getVersionNumber(const UResourceBundle* resourceBundle);
#endif /* U_HIDE_DEPRECATED_API */
U_CAPI void U_EXPORT2
ures_getVersion(const UResourceBundle* resB,
UVersionInfo versionInfo);
#ifndef U_HIDE_DEPRECATED_API
U_DEPRECATED const char* U_EXPORT2
ures_getLocale(const UResourceBundle* resourceBundle,
UErrorCode* status);
#endif /* U_HIDE_DEPRECATED_API */
U_CAPI const char* U_EXPORT2
ures_getLocaleByType(const UResourceBundle* resourceBundle,
ULocDataLocaleType type,
UErrorCode* status);
#ifndef U_HIDE_INTERNAL_API
U_CAPI void U_EXPORT2
ures_openFillIn(UResourceBundle *r,
const char* packageName,
const char* localeID,
UErrorCode* status);
#endif /* U_HIDE_INTERNAL_API */
U_CAPI const UChar* U_EXPORT2
ures_getString(const UResourceBundle* resourceBundle,
int32_t* len,
UErrorCode* status);
U_CAPI const char * U_EXPORT2
ures_getUTF8String(const UResourceBundle *resB,
char *dest, int32_t *length,
UBool forceCopy,
UErrorCode *status);
U_CAPI const uint8_t* U_EXPORT2
ures_getBinary(const UResourceBundle* resourceBundle,
int32_t* len,
UErrorCode* status);
U_CAPI const int32_t* U_EXPORT2
ures_getIntVector(const UResourceBundle* resourceBundle,
int32_t* len,
UErrorCode* status);
U_CAPI uint32_t U_EXPORT2
ures_getUInt(const UResourceBundle* resourceBundle,
UErrorCode *status);
U_CAPI int32_t U_EXPORT2
ures_getInt(const UResourceBundle* resourceBundle,
UErrorCode *status);
U_CAPI int32_t U_EXPORT2
ures_getSize(const UResourceBundle *resourceBundle);
U_CAPI UResType U_EXPORT2
ures_getType(const UResourceBundle *resourceBundle);
U_CAPI const char * U_EXPORT2
ures_getKey(const UResourceBundle *resourceBundle);
/* ITERATION API
This API provides means for iterating through a resource
*/
U_CAPI void U_EXPORT2
ures_resetIterator(UResourceBundle *resourceBundle);
U_CAPI UBool U_EXPORT2
ures_hasNext(const UResourceBundle *resourceBundle);
U_CAPI UResourceBundle* U_EXPORT2
ures_getNextResource(UResourceBundle *resourceBundle,
UResourceBundle *fillIn,
UErrorCode *status);
U_CAPI const UChar* U_EXPORT2
ures_getNextString(UResourceBundle *resourceBundle,
int32_t* len,
const char ** key,
UErrorCode *status);
U_CAPI UResourceBundle* U_EXPORT2
ures_getByIndex(const UResourceBundle *resourceBundle,
int32_t indexR,
UResourceBundle *fillIn,
UErrorCode *status);
U_CAPI const UChar* U_EXPORT2
ures_getStringByIndex(const UResourceBundle *resourceBundle,
int32_t indexS,
int32_t* len,
UErrorCode *status);
U_CAPI const char * U_EXPORT2
ures_getUTF8StringByIndex(const UResourceBundle *resB,
int32_t stringIndex,
char *dest, int32_t *pLength,
UBool forceCopy,
UErrorCode *status);
U_CAPI UResourceBundle* U_EXPORT2
ures_getByKey(const UResourceBundle *resourceBundle,
const char* key,
UResourceBundle *fillIn,
UErrorCode *status);
U_CAPI const UChar* U_EXPORT2
ures_getStringByKey(const UResourceBundle *resB,
const char* key,
int32_t* len,
UErrorCode *status);
U_CAPI const char * U_EXPORT2
ures_getUTF8StringByKey(const UResourceBundle *resB,
const char *key,
char *dest, int32_t *pLength,
UBool forceCopy,
UErrorCode *status);
#if U_SHOW_CPLUSPLUS_API
#include "unicode/unistr.h"
U_NAMESPACE_BEGIN
inline UnicodeString
ures_getUnicodeString(const UResourceBundle *resB, UErrorCode* status) {
UnicodeString result;
int32_t len = 0;
const char16_t *r = ConstChar16Ptr(ures_getString(resB, &len, status));
if(U_SUCCESS(*status)) {
result.setTo(true, r, len);
} else {
result.setToBogus();
}
return result;
}
inline UnicodeString
ures_getNextUnicodeString(UResourceBundle *resB, const char ** key, UErrorCode* status) {
UnicodeString result;
int32_t len = 0;
const char16_t* r = ConstChar16Ptr(ures_getNextString(resB, &len, key, status));
if(U_SUCCESS(*status)) {
result.setTo(true, r, len);
} else {
result.setToBogus();
}
return result;
}
inline UnicodeString
ures_getUnicodeStringByIndex(const UResourceBundle *resB, int32_t indexS, UErrorCode* status) {
UnicodeString result;
int32_t len = 0;
const char16_t* r = ConstChar16Ptr(ures_getStringByIndex(resB, indexS, &len, status));
if(U_SUCCESS(*status)) {
result.setTo(true, r, len);
} else {
result.setToBogus();
}
return result;
}
inline UnicodeString
ures_getUnicodeStringByKey(const UResourceBundle *resB, const char* key, UErrorCode* status) {
UnicodeString result;
int32_t len = 0;
const char16_t* r = ConstChar16Ptr(ures_getStringByKey(resB, key, &len, status));
if(U_SUCCESS(*status)) {
result.setTo(true, r, len);
} else {
result.setToBogus();
}
return result;
}
U_NAMESPACE_END
#endif
U_CAPI UEnumeration* U_EXPORT2
ures_openAvailableLocales(const char *packageName, UErrorCode *status);
#endif /*_URES*/
/*eof*/
char16ptr.h
C++ API: char16_t pointer wrappers with implicit conversion from bit-compatible raw pointer types.
LocalUResourceBundlePointer
"Smart pointer" class, closes a UResourceBundle via ures_close().
icu::ConstChar16Ptr
const char16_t * wrapper with implicit conversion from distinct but bit-compatible pointer types.
Definition char16ptr.h:156
icu::UnicodeString
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition unistr.h:303
icu::UnicodeString::setToBogus
void setToBogus()
Make this UnicodeString object invalid.
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:4984
localpointer.h
C++ API: "Smart pointers" for use with and in ICU4C C++ code.
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:548
icu::ures_getUnicodeString
UnicodeString ures_getUnicodeString(const UResourceBundle *resB, UErrorCode *status)
Returns the string value from a string resource bundle.
Definition ures.h:813
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:860
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:838
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:883
UEnumeration
struct UEnumeration UEnumeration
structure representing an enumeration object instance
Definition uenum.h:44
uloc.h
C API: Locale ID functionality similar to C++ class Locale.
ULocDataLocaleType
ULocDataLocaleType
Constants for *_getLocale() Allow user to select whether she wants information on requested,...
Definition uloc.h:338
UChar
char16_t UChar
The base type for UTF-16 code units and pointers.
Definition umachine.h:400
U_DEPRECATED
#define U_DEPRECATED
This is used to declare a function as a deprecated public ICU C API.
Definition umachine.h:116
UBool
int8_t UBool
The ICU boolean type, a signed-byte integer.
Definition umachine.h:269
U_CAPI
#define U_CAPI
This is used to declare a function as a public ICU C API.
Definition umachine.h:110
unistr.h
C++ API: Unicode String.
ures_countArrayItems
int32_t ures_countArrayItems(const UResourceBundle *resourceBundle, const char *resourceKey, UErrorCode *err)
Returns the number of strings/arrays in resource bundles.
ures_getInt
U_CAPI int32_t ures_getInt(const UResourceBundle *resourceBundle, UErrorCode *status)
Returns a signed integer from a resource.
ures_getNextResource
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.
ures_getSize
U_CAPI int32_t ures_getSize(const UResourceBundle *resourceBundle)
Returns the size of a resource.
ures_getString
U_CAPI const UChar * ures_getString(const UResourceBundle *resourceBundle, int32_t *len, UErrorCode *status)
Returns a string from a string resource type.
ures_open
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.
ures_getByKey
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.
ures_getVersionNumber
const char * ures_getVersionNumber(const UResourceBundle *resourceBundle)
Return the version number associated with this ResourceBundle as a string.
ures_openDirect
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.
ures_getStringByIndex
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.
ures_getUTF8StringByIndex
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.
ures_resetIterator
U_CAPI void ures_resetIterator(UResourceBundle *resourceBundle)
Resets the internal context of a resource so that iteration starts from the first element.
UResType
UResType
Numeric constants for types of resource items.
Definition ures.h:70
RES_BINARY
@ RES_BINARY
Definition ures.h:116
URES_TABLE
@ URES_TABLE
Resource type constant for tables of key-value pairs.
Definition ures.h:81
RES_ARRAY
@ RES_ARRAY
Definition ures.h:124
URES_ALIAS
@ URES_ALIAS
Resource type constant for aliases; internally stores a string which identifies the actual resource s...
Definition ures.h:90
URES_INT_VECTOR
@ URES_INT_VECTOR
Resource type constant for vectors of 32-bit integers.
Definition ures.h:109
URES_BINARY
@ URES_BINARY
Resource type constant for binary data.
Definition ures.h:78
RES_NONE
@ RES_NONE
Definition ures.h:112
URES_ARRAY
@ URES_ARRAY
Resource type constant for arrays of resources.
Definition ures.h:102
URES_NONE
@ URES_NONE
Resource type constant for "no resource".
Definition ures.h:72
RES_RESERVED
@ RES_RESERVED
Definition ures.h:128
URES_STRING
@ URES_STRING
Resource type constant for 16-bit Unicode strings.
Definition ures.h:75
RES_INT_VECTOR
@ RES_INT_VECTOR
Definition ures.h:126
URES_INT
@ 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
@ RES_TABLE
Definition ures.h:118
RES_STRING
@ RES_STRING
Definition ures.h:114
RES_ALIAS
@ RES_ALIAS
Definition ures.h:120
RES_INT
@ RES_INT
Definition ures.h:122
URES_LIMIT
@ URES_LIMIT
One more than the highest normal UResType value.
Definition ures.h:134
ures_getType
U_CAPI UResType ures_getType(const UResourceBundle *resourceBundle)
Returns the type of a resource.
ures_hasNext
U_CAPI UBool ures_hasNext(const UResourceBundle *resourceBundle)
Checks whether the given resource has another element to iterate over.
ures_close
U_CAPI void ures_close(UResourceBundle *resourceBundle)
Close a resource bundle, all pointers returned from the various ures_getXXX calls on this particular ...
UResourceBundle
struct UResourceBundle UResourceBundle
Definition ures.h:63
ures_getLocale
const char * ures_getLocale(const UResourceBundle *resourceBundle, UErrorCode *status)
Return the name of the Locale associated with this ResourceBundle.
ures_getKey
U_CAPI const char * ures_getKey(const UResourceBundle *resourceBundle)
Returns the key associated with a given resource.
ures_getUTF8String
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.
ures_getStringByKey
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.
ures_getByIndex
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.
ures_openFillIn
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.
ures_openAvailableLocales
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...
ures_getUInt
U_CAPI uint32_t ures_getUInt(const UResourceBundle *resourceBundle, UErrorCode *status)
Returns an unsigned integer from a resource.
ures_getBinary
U_CAPI const uint8_t * ures_getBinary(const UResourceBundle *resourceBundle, int32_t *len, UErrorCode *status)
Returns a binary data from a binary resource.
ures_openU
U_CAPI UResourceBundle * ures_openU(const UChar *packageName, const char *locale, UErrorCode *status)
Same as ures_open() but takes a const UChar *path.
ures_getUTF8StringByKey
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.
ures_getIntVector
U_CAPI const int32_t * ures_getIntVector(const UResourceBundle *resourceBundle, int32_t *len, UErrorCode *status)
Returns a 32 bit integer array from a resource.
ures_getVersion
U_CAPI void ures_getVersion(const UResourceBundle *resB, UVersionInfo versionInfo)
Return the version number associated with this ResourceBundle as an UVersionInfo array.
ures_getNextString
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.
ures_getLocaleByType
U_CAPI const char * ures_getLocaleByType(const UResourceBundle *resourceBundle, ULocDataLocaleType type, UErrorCode *status)
Return the name of the Locale associated with this ResourceBundle.
utypes.h
Basic definitions for ICU, for both C and C++ APIs.
UErrorCode
UErrorCode
Standard ICU4C error code type, a substitute for exceptions.
Definition utypes.h:509
U_SUCCESS
#define U_SUCCESS(x)
Does the error code indicate success?
Definition utypes.h:822
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