ICU 4.8.1.1  4.8.1.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-2010, 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 #include "unicode/localpointer.h"
29 
52 struct UResourceBundle;
53 
58 
64 typedef enum {
67 
70 
73 
76 
85 
94 
97 
104 #ifndef U_HIDE_DEPRECATED_API
105 
123 #endif /* U_HIDE_DEPRECATED_API */
124 
125  URES_LIMIT = 16
126 } UResType;
127 
128 /*
129  * Functions to create and destroy resource bundles.
130  */
131 
161 ures_open(const char* packageName,
162  const char* locale,
163  UErrorCode* status);
164 
165 
184 ures_openDirect(const char* packageName,
185  const char* locale,
186  UErrorCode* status);
187 
207 ures_openU(const UChar* packageName,
208  const char* locale,
209  UErrorCode* status);
210 
227 U_DEPRECATED int32_t U_EXPORT2
228 ures_countArrayItems(const UResourceBundle* resourceBundle,
229  const char* resourceKey,
230  UErrorCode* err);
239 U_STABLE void U_EXPORT2
240 ures_close(UResourceBundle* resourceBundle);
241 
242 #if U_SHOW_CPLUSPLUS_API
243 
245 
255 U_DEFINE_LOCAL_OPEN_POINTER(LocalUResourceBundlePointer, UResourceBundle, ures_close);
256 
258 
259 #endif
260 
271 U_DEPRECATED const char* U_EXPORT2
272 ures_getVersionNumber(const UResourceBundle* resourceBundle);
273 
283 U_STABLE void U_EXPORT2
284 ures_getVersion(const UResourceBundle* resB,
285  UVersionInfo versionInfo);
286 
299 U_DEPRECATED const char* U_EXPORT2
300 ures_getLocale(const UResourceBundle* resourceBundle,
301  UErrorCode* status);
302 
303 
316 U_STABLE const char* U_EXPORT2
317 ures_getLocaleByType(const UResourceBundle* resourceBundle,
318  ULocDataLocaleType type,
319  UErrorCode* status);
320 
321 
338 U_INTERNAL void U_EXPORT2
340  const char* packageName,
341  const char* localeID,
342  UErrorCode* status);
343 
361 U_STABLE const UChar* U_EXPORT2
362 ures_getString(const UResourceBundle* resourceBundle,
363  int32_t* len,
364  UErrorCode* status);
365 
413 U_STABLE const char * U_EXPORT2
415  char *dest, int32_t *length,
416  UBool forceCopy,
417  UErrorCode *status);
418 
436 U_STABLE const uint8_t* U_EXPORT2
437 ures_getBinary(const UResourceBundle* resourceBundle,
438  int32_t* len,
439  UErrorCode* status);
440 
458 U_STABLE const int32_t* U_EXPORT2
459 ures_getIntVector(const UResourceBundle* resourceBundle,
460  int32_t* len,
461  UErrorCode* status);
462 
479 U_STABLE uint32_t U_EXPORT2
480 ures_getUInt(const UResourceBundle* resourceBundle,
481  UErrorCode *status);
482 
499 U_STABLE int32_t U_EXPORT2
500 ures_getInt(const UResourceBundle* resourceBundle,
501  UErrorCode *status);
502 
513 U_STABLE int32_t U_EXPORT2
514 ures_getSize(const UResourceBundle *resourceBundle);
515 
525 ures_getType(const UResourceBundle *resourceBundle);
526 
535 U_STABLE const char * U_EXPORT2
536 ures_getKey(const UResourceBundle *resourceBundle);
537 
538 /* ITERATION API
539  This API provides means for iterating through a resource
540 */
541 
548 U_STABLE void U_EXPORT2
549 ures_resetIterator(UResourceBundle *resourceBundle);
550 
559 ures_hasNext(const UResourceBundle *resourceBundle);
560 
574 ures_getNextResource(UResourceBundle *resourceBundle,
575  UResourceBundle *fillIn,
576  UErrorCode *status);
577 
590 U_STABLE const UChar* U_EXPORT2
591 ures_getNextString(UResourceBundle *resourceBundle,
592  int32_t* len,
593  const char ** key,
594  UErrorCode *status);
595 
609 ures_getByIndex(const UResourceBundle *resourceBundle,
610  int32_t indexR,
611  UResourceBundle *fillIn,
612  UErrorCode *status);
613 
625 U_STABLE const UChar* U_EXPORT2
626 ures_getStringByIndex(const UResourceBundle *resourceBundle,
627  int32_t indexS,
628  int32_t* len,
629  UErrorCode *status);
630 
679 U_STABLE const char * U_EXPORT2
681  int32_t stringIndex,
682  char *dest, int32_t *pLength,
683  UBool forceCopy,
684  UErrorCode *status);
685 
699 ures_getByKey(const UResourceBundle *resourceBundle,
700  const char* key,
701  UResourceBundle *fillIn,
702  UErrorCode *status);
703 
716 U_STABLE const UChar* U_EXPORT2
718  const char* key,
719  int32_t* len,
720  UErrorCode *status);
721 
772 U_STABLE const char * U_EXPORT2
774  const char *key,
775  char *dest, int32_t *pLength,
776  UBool forceCopy,
777  UErrorCode *status);
778 
779 #if U_SHOW_CPLUSPLUS_API
780 #include "unicode/unistr.h"
781 
794 inline UnicodeString
795 ures_getUnicodeString(const UResourceBundle *resB,
796  UErrorCode* status)
797 {
798  int32_t len = 0;
799  const UChar *r = ures_getString(resB, &len, status);
800  return UnicodeString(TRUE, r, len);
801 }
802 
813 inline UnicodeString
814 ures_getNextUnicodeString(UResourceBundle *resB,
815  const char ** key,
816  UErrorCode* status)
817 {
818  int32_t len = 0;
819  const UChar* r = ures_getNextString(resB, &len, key, status);
820  return UnicodeString(TRUE, r, len);
821 }
822 
832 inline UnicodeString
833 ures_getUnicodeStringByIndex(const UResourceBundle *resB,
834  int32_t indexS,
835  UErrorCode* status)
836 {
837  int32_t len = 0;
838  const UChar* r = ures_getStringByIndex(resB, indexS, &len, status);
839  return UnicodeString(TRUE, r, len);
840 }
841 
852 inline UnicodeString
853 ures_getUnicodeStringByKey(const UResourceBundle *resB,
854  const char* key,
855  UErrorCode* status)
856 {
857  int32_t len = 0;
858  const UChar* r = ures_getStringByKey(resB, key, &len, status);
859  return UnicodeString(TRUE, r, len);
860 }
861 
863 
864 #endif
865 
875 ures_openAvailableLocales(const char *packageName, UErrorCode *status);
876 
877 
878 #endif /*_URES*/
879 /*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:57
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:72
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:103
int32_t ures_getInt(const UResourceBundle *resourceBundle, UErrorCode *status)
Returns a signed integer from a resource.
Definition: ures.h:106
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:39
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:145
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.
UResourceBundle * ures_openDirect(const char *packageName, const char *locale, UErrorCode *status)
This function does not care what kind of localeID is passed in.
Resource type constant for "no resource".
Definition: ures.h:66
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:141
Resource type constant for a single 28-bit integer, interpreted as signed or unsigned by the ures_get...
Definition: ures.h:93
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:131
C++ API: "Smart pointers" for use with and in ICU4C C++ code.
Resource type constant for tables of key-value pairs.
Definition: ures.h:75
int32_t ures_getSize(const UResourceBundle *resourceBundle)
Returns the size of a resource.
UResType
Numeric constants for types of resource items.
Definition: ures.h:64
#define TRUE
The TRUE value of a UBool.
Definition: umachine.h:232
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:188
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:314
Resource type constant for arrays of resources.
Definition: ures.h:96
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:325
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.
Definition: uversion.h:132
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:639
ULocDataLocaleType
Constants for *_getLocale() Allow user to select whether she wants information on requested...
Definition: uloc.h:336
Definition: ures.h:116
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:69
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:57
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:84
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...
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:137
int8_t UBool
The ICU boolean type.
Definition: umachine.h:228
C API: Locale.