ICU 4.2.1
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ures.h
Go to the documentation of this file.
1 /*
2 **********************************************************************
3 * Copyright (C) 1997-2009, 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"
28 
51 struct UResourceBundle;
52 
57 
63 typedef enum {
66 
69 
72 
75 
84 
85 #ifndef U_HIDE_INTERNAL_API
86 
94 
95 #endif /* U_HIDE_INTERNAL_API */
96 
105 
108 
115 #ifndef U_HIDE_DEPRECATED_API
116 
134 #endif /* U_HIDE_DEPRECATED_API */
135 
136  URES_LIMIT = 16
137 } UResType;
138 
139 /*
140  * Functions to create and destroy resource bundles.
141  */
142 
172 ures_open(const char* packageName,
173  const char* locale,
174  UErrorCode* status);
175 
176 
195 ures_openDirect(const char* packageName,
196  const char* locale,
197  UErrorCode* status);
198 
218 ures_openU(const UChar* packageName,
219  const char* locale,
220  UErrorCode* status);
221 
239 ures_countArrayItems(const UResourceBundle* resourceBundle,
240  const char* resourceKey,
241  UErrorCode* err);
250 U_STABLE void U_EXPORT2
251 ures_close(UResourceBundle* resourceBundle);
252 
263 U_DEPRECATED const char* U_EXPORT2
264 ures_getVersionNumber(const UResourceBundle* resourceBundle);
265 
275 U_STABLE void U_EXPORT2
276 ures_getVersion(const UResourceBundle* resB,
277  UVersionInfo versionInfo);
278 
291 U_DEPRECATED const char* U_EXPORT2
292 ures_getLocale(const UResourceBundle* resourceBundle,
293  UErrorCode* status);
294 
295 
308 U_STABLE const char* U_EXPORT2
309 ures_getLocaleByType(const UResourceBundle* resourceBundle,
310  ULocDataLocaleType type,
311  UErrorCode* status);
312 
313 
330 U_INTERNAL void U_EXPORT2
332  const char* packageName,
333  const char* localeID,
334  UErrorCode* status);
335 
353 U_STABLE const UChar* U_EXPORT2
354 ures_getString(const UResourceBundle* resourceBundle,
355  int32_t* len,
356  UErrorCode* status);
357 
405 U_STABLE const char * U_EXPORT2
407  char *dest, int32_t *length,
408  UBool forceCopy,
409  UErrorCode *status);
410 
428 U_STABLE const uint8_t* U_EXPORT2
429 ures_getBinary(const UResourceBundle* resourceBundle,
430  int32_t* len,
431  UErrorCode* status);
432 
450 U_STABLE const int32_t* U_EXPORT2
451 ures_getIntVector(const UResourceBundle* resourceBundle,
452  int32_t* len,
453  UErrorCode* status);
454 
472 ures_getUInt(const UResourceBundle* resourceBundle,
473  UErrorCode *status);
474 
492 ures_getInt(const UResourceBundle* resourceBundle,
493  UErrorCode *status);
494 
506 ures_getSize(const UResourceBundle *resourceBundle);
507 
517 ures_getType(const UResourceBundle *resourceBundle);
518 
527 U_STABLE const char * U_EXPORT2
528 ures_getKey(const UResourceBundle *resourceBundle);
529 
530 /* ITERATION API
531  This API provides means for iterating through a resource
532 */
533 
540 U_STABLE void U_EXPORT2
541 ures_resetIterator(UResourceBundle *resourceBundle);
542 
551 ures_hasNext(const UResourceBundle *resourceBundle);
552 
566 ures_getNextResource(UResourceBundle *resourceBundle,
567  UResourceBundle *fillIn,
568  UErrorCode *status);
569 
582 U_STABLE const UChar* U_EXPORT2
583 ures_getNextString(UResourceBundle *resourceBundle,
584  int32_t* len,
585  const char ** key,
586  UErrorCode *status);
587 
601 ures_getByIndex(const UResourceBundle *resourceBundle,
602  int32_t indexR,
603  UResourceBundle *fillIn,
604  UErrorCode *status);
605 
617 U_STABLE const UChar* U_EXPORT2
618 ures_getStringByIndex(const UResourceBundle *resourceBundle,
619  int32_t indexS,
620  int32_t* len,
621  UErrorCode *status);
622 
671 U_STABLE const char * U_EXPORT2
673  int32_t stringIndex,
674  char *dest, int32_t *pLength,
675  UBool forceCopy,
676  UErrorCode *status);
677 
691 ures_getByKey(const UResourceBundle *resourceBundle,
692  const char* key,
693  UResourceBundle *fillIn,
694  UErrorCode *status);
695 
708 U_STABLE const UChar* U_EXPORT2
710  const char* key,
711  int32_t* len,
712  UErrorCode *status);
713 
764 U_STABLE const char * U_EXPORT2
766  const char *key,
767  char *dest, int32_t *pLength,
768  UBool forceCopy,
769  UErrorCode *status);
770 
771 #ifdef XP_CPLUSPLUS
772 #include "unicode/unistr.h"
773 
786 inline UnicodeString
787 ures_getUnicodeString(const UResourceBundle *resB,
788  UErrorCode* status)
789 {
790  int32_t len = 0;
791  const UChar *r = ures_getString(resB, &len, status);
792  return UnicodeString(TRUE, r, len);
793 }
794 
805 inline UnicodeString
806 ures_getNextUnicodeString(UResourceBundle *resB,
807  const char ** key,
808  UErrorCode* status)
809 {
810  int32_t len = 0;
811  const UChar* r = ures_getNextString(resB, &len, key, status);
812  return UnicodeString(TRUE, r, len);
813 }
814 
824 inline UnicodeString
825 ures_getUnicodeStringByIndex(const UResourceBundle *resB,
826  int32_t indexS,
827  UErrorCode* status)
828 {
829  int32_t len = 0;
830  const UChar* r = ures_getStringByIndex(resB, indexS, &len, status);
831  return UnicodeString(TRUE, r, len);
832 }
833 
844 inline UnicodeString
845 ures_getUnicodeStringByKey(const UResourceBundle *resB,
846  const char* key,
847  UErrorCode* status)
848 {
849  int32_t len = 0;
850  const UChar* r = ures_getStringByKey(resB, key, &len, status);
851  return UnicodeString(TRUE, r, len);
852 }
853 
855 
856 #endif
857 
867 ures_openAvailableLocales(const char *packageName, UErrorCode *status);
868 
869 
870 #endif /*_URES*/
871 /*eof*/
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:124
UResourceBundle * ures_openU(const UChar *packageName, const char *locale, UErrorCode *status)
Same as ures_open() but takes a const UChar *path.
const UChar * ures_getString(const UResourceBundle *resourceBundle, int32_t *len, UErrorCode *status)
Returns a string from a string resource type.
UBool ures_hasNext(const UResourceBundle *resourceBundle)
Checks whether the given resource has another element to iterate over.
Resource type constant for binary data.
Definition: ures.h:71
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.
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.
Resource type constant for vectors of 32-bit integers.
Definition: ures.h:114
int32_t ures_getInt(const UResourceBundle *resourceBundle, UErrorCode *status)
Returns a signed integer from a resource.
Definition: ures.h:117
void ures_getVersion(const UResourceBundle *resB, UVersionInfo versionInfo)
Return the version number associated with this ResourceBundle as an UVersionInfo array.
C++ API: Unicode String.
struct UEnumeration UEnumeration
structure representing an enumeration object instance
Definition: uenum.h:38
const char * ures_getKey(const UResourceBundle *resourceBundle)
Returns the key associated with a given resource.
#define U_INTERNAL
This is used to declare a function as an internal ICU C API.
Definition: umachine.h:125
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.
UResourceBundle * ures_getByIndex(const UResourceBundle *resourceBundle, int32_t indexR, UResourceBundle *fillIn, UErrorCode *status)
Returns the resource in a given resource at the specified index.
const char * ures_getVersionNumber(const UResourceBundle *resourceBundle)
Return the version number associated with this ResourceBundle as a string.
unsigned char uint8_t
Define 64 bit limits.
Definition: pwin32.h:131
UResourceBundle * ures_openDirect(const char *packageName, const char *locale, UErrorCode *status)
This function does not care what kind of localeID is passed in.
unsigned int uint32_t
Define 64 bit limits.
Definition: pwin32.h:147
Resource type constant for "no resource".
Definition: ures.h:65
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...
#define U_DEPRECATED
This is used to declare a function as a deprecated public ICU C API.
Definition: umachine.h:121
Resource type constant for a single 28-bit integer, interpreted as signed or unsigned by the ures_get...
Definition: ures.h:104
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...
const uint8_t * ures_getBinary(const UResourceBundle *resourceBundle, int32_t *len, UErrorCode *status)
Returns a binary data from a binary resource.
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition: uversion.h:183
Internal use only.
Definition: ures.h:93
Resource type constant for tables of key-value pairs.
Definition: ures.h:74
int32_t ures_getSize(const UResourceBundle *resourceBundle)
Returns the size of a resource.
UResType
Numeric constants for types of resource items.
Definition: ures.h:63
#define TRUE
The TRUE value of a UBool.
Definition: umachine.h:212
const char * ures_getLocale(const UResourceBundle *resourceBundle, UErrorCode *status)
Return the name of the Locale associated with this ResourceBundle.
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition: unistr.h:187
void ures_resetIterator(UResourceBundle *resourceBundle)
Resets the internal context of a resource so that iteration starts from the first element...
#define U_EXPORT2
Definition: platform.h:338
Resource type constant for arrays of resources.
Definition: ures.h:107
int32_t ures_countArrayItems(const UResourceBundle *resourceBundle, const char *resourceKey, UErrorCode *err)
Returns the number of strings/arrays in resource bundles.
uint16_t UChar
Define UChar to be wchar_t if that is 16 bits wide; always assumed to be unsigned.
Definition: umachine.h:299
UResType ures_getType(const UResourceBundle *resourceBundle)
Returns the type of a resource.
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API If the compiler doesn't support namespaces...
Definition: uversion.h:184
uint32_t ures_getUInt(const UResourceBundle *resourceBundle, UErrorCode *status)
Returns an unsigned integer from a resource.
const int32_t * ures_getIntVector(const UResourceBundle *resourceBundle, int32_t *len, UErrorCode *status)
Returns a 32 bit integer array 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.
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers...
Definition: utypes.h:593
ULocDataLocaleType
Constants for *_getLocale() Allow user to select whether she wants information on requested...
Definition: uloc.h:314
Definition: ures.h:127
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.
Resource type constant for 16-bit Unicode strings.
Definition: ures.h:68
UEnumeration * ures_openAvailableLocales(const char *packageName, UErrorCode *status)
Create a string enumerator, owned by the caller, of all locales located within the specified resource...
const char * ures_getLocaleByType(const UResourceBundle *resourceBundle, ULocDataLocaleType type, UErrorCode *status)
Return the name of the Locale associated with this ResourceBundle.
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.
Basic definitions for ICU, for both C and C++ APIs.
struct UResourceBundle UResourceBundle
Definition: ures.h:56
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, if r!=NULL.
Resource type constant for aliases; internally stores a string which identifies the actual resource s...
Definition: ures.h:83
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...
signed int int32_t
Define 64 bit limits.
Definition: pwin32.h:143
void ures_close(UResourceBundle *resourceBundle)
Close a resource bundle, all pointers returned from the various ures_getXXX calls on this particular ...
#define U_STABLE
This is used to declare a function as a stable public ICU C API.
Definition: umachine.h:117
int8_t UBool
The ICU boolean type.
Definition: umachine.h:208
C API: Locale.