ICU 57.1  57.1
resbund.h
Go to the documentation of this file.
1 /*
2 ******************************************************************************
3 *
4 * Copyright (C) 1996-2013, International Business Machines Corporation
5 * and others. All Rights Reserved.
6 *
7 ******************************************************************************
8 *
9 * File resbund.h
10 *
11 * CREATED BY
12 * Richard Gillam
13 *
14 * Modification History:
15 *
16 * Date Name Description
17 * 2/5/97 aliu Added scanForLocaleInFile. Added
18 * constructor which attempts to read resource bundle
19 * from a specific file, without searching other files.
20 * 2/11/97 aliu Added UErrorCode return values to constructors. Fixed
21 * infinite loops in scanForFile and scanForLocale.
22 * Modified getRawResourceData to not delete storage
23 * in localeData and resourceData which it doesn't own.
24 * Added Mac compatibility #ifdefs for tellp() and
25 * ios::nocreate.
26 * 2/18/97 helena Updated with 100% documentation coverage.
27 * 3/13/97 aliu Rewrote to load in entire resource bundle and store
28 * it as a Hashtable of ResourceBundleData objects.
29 * Added state table to govern parsing of files.
30 * Modified to load locale index out of new file
31 * distinct from default.txt.
32 * 3/25/97 aliu Modified to support 2-d arrays, needed for timezone
33 * data. Added support for custom file suffixes. Again,
34 * needed to support timezone data.
35 * 4/7/97 aliu Cleaned up.
36 * 03/02/99 stephen Removed dependency on FILE*.
37 * 03/29/99 helena Merged Bertrand and Stephen's changes.
38 * 06/11/99 stephen Removed parsing of .txt files.
39 * Reworked to use new binary format.
40 * Cleaned up.
41 * 06/14/99 stephen Removed methods taking a filename suffix.
42 * 11/09/99 weiv Added getLocale(), fRealLocale, removed fRealLocaleID
43 ******************************************************************************
44 */
45 
46 #ifndef RESBUND_H
47 #define RESBUND_H
48 
49 #include "unicode/utypes.h"
50 #include "unicode/uobject.h"
51 #include "unicode/ures.h"
52 #include "unicode/unistr.h"
53 #include "unicode/locid.h"
54 
61 
79 public:
106  ResourceBundle(const UnicodeString& packageName,
107  const Locale& locale,
108  UErrorCode& err);
109 
121  ResourceBundle(const UnicodeString& packageName,
122  UErrorCode& err);
123 
131 
146  ResourceBundle(const char* packageName,
147  const Locale& locale,
148  UErrorCode& err);
149 
156  ResourceBundle(const ResourceBundle &original);
157 
168  UErrorCode &status);
169 
177  operator=(const ResourceBundle& other);
178 
182  virtual ~ResourceBundle();
183 
196 
207  int32_t
208  getSize(void) const;
209 
221  getString(UErrorCode& status) const;
222 
235  const uint8_t*
236  getBinary(int32_t& len, UErrorCode& status) const;
237 
238 
250  const int32_t*
251  getIntVector(int32_t& len, UErrorCode& status) const;
252 
264  uint32_t
265  getUInt(UErrorCode& status) const;
266 
278  int32_t
279  getInt(UErrorCode& status) const;
280 
287  UBool
288  hasNext(void) const;
289 
295  void
297 
305  const char*
306  getKey(void) const;
307 
315  const char*
316  getName(void) const;
317 
318 
325  UResType
326  getType(void) const;
327 
336  getNext(UErrorCode& status);
337 
348 
359  getNextString(const char ** key,
360  UErrorCode& status);
361 
371  get(int32_t index,
372  UErrorCode& status) const;
373 
383  getStringEx(int32_t index,
384  UErrorCode& status) const;
385 
396  get(const char* key,
397  UErrorCode& status) const;
398 
409  getStringEx(const char* key,
410  UErrorCode& status) const;
411 
412 #ifndef U_HIDE_DEPRECATED_API
422  const char*
423  getVersionNumber(void) const;
424 #endif /* U_HIDE_DEPRECATED_API */
425 
433  void
434  getVersion(UVersionInfo versionInfo) const;
435 
436 #ifndef U_HIDE_DEPRECATED_API
443  const Locale&
444  getLocale(void) const;
445 #endif /* U_HIDE_DEPRECATED_API */
446 
457  const Locale
459 #ifndef U_HIDE_INTERNAL_API
465  getWithFallback(const char* key, UErrorCode& status);
466 #endif /* U_HIDE_INTERNAL_API */
472  virtual UClassID getDynamicClassID() const;
473 
479  static UClassID U_EXPORT2 getStaticClassID();
480 
481 private:
482  ResourceBundle(); // default constructor not implemented
483 
484  UResourceBundle *fResource;
485  void constructForLocale(const UnicodeString& path, const Locale& locale, UErrorCode& error);
486  Locale *fLocale;
487 };
488 
490 #endif
A Locale object represents a specific geographical, political, or cultural region.
Definition: locid.h:185
A class representing a collection of resource information pertaining to a given locale.
Definition: resbund.h:78
int32_t getSize(void) const
Returns the size of a resource.
ResourceBundle getNext(UErrorCode &status)
Returns the next resource in a given resource or NULL if there are no more resources.
const Locale & getLocale(void) const
Return the Locale associated with this ResourceBundle.
UnicodeString getStringEx(int32_t index, UErrorCode &status) const
Returns the string in a given resource at the specified index.
const char * getKey(void) const
Returns the key associated with this resource.
void resetIterator(void)
Resets the internal context of a resource so that iteration starts from the first element.
const Locale getLocale(ULocDataLocaleType type, UErrorCode &status) const
Return the Locale associated with this ResourceBundle.
ResourceBundle(const UnicodeString &packageName, const Locale &locale, UErrorCode &err)
Constructor.
void getVersion(UVersionInfo versionInfo) const
Return the version number associated with this ResourceBundle as a UVersionInfo array.
UnicodeString getStringEx(const char *key, UErrorCode &status) const
Returns a string in a resource that has a given key.
const uint8_t * getBinary(int32_t &len, UErrorCode &status) const
returns a binary data from a resource.
ResourceBundle getWithFallback(const char *key, UErrorCode &status)
This API implements multilevel fallback.
uint32_t getUInt(UErrorCode &status) const
returns an unsigned integer from a resource.
static UClassID getStaticClassID()
ICU "poor man's RTTI", returns a UClassID for this class.
ResourceBundle(UErrorCode &err)
Construct a resource bundle for the ICU default bundle.
UResType getType(void) const
Returns the type of a resource.
virtual ~ResourceBundle()
Destructor.
int32_t getInt(UErrorCode &status) const
returns a signed integer from a resource.
virtual UClassID getDynamicClassID() const
ICU "poor man's RTTI", returns a UClassID for the actual class.
ResourceBundle(const char *packageName, const Locale &locale, UErrorCode &err)
Standard constructor, onstructs a resource bundle for the locale-specific bundle in the specified pac...
ResourceBundle & operator=(const ResourceBundle &other)
Assignment operator.
const char * getVersionNumber(void) const
Return the version number associated with this ResourceBundle as a string.
UnicodeString getString(UErrorCode &status) const
returns a string from a string resource type
ResourceBundle get(int32_t index, UErrorCode &status) const
Returns the resource in a resource at the specified index.
UnicodeString getNextString(const char **key, UErrorCode &status)
Returns the next string in a resource or NULL if there are no more resources to iterate over.
ResourceBundle get(const char *key, UErrorCode &status) const
Returns a resource in a resource that has a given key.
UBool hasNext(void) const
Checks whether the resource has another element to iterate over.
const char * getName(void) const
Gets the locale ID of the resource bundle as a string.
const int32_t * getIntVector(int32_t &len, UErrorCode &status) const
returns an integer vector from a resource.
ResourceBundle(UResourceBundle *res, UErrorCode &status)
Constructor from a C UResourceBundle.
ResourceBundle * clone() const
Clone this object.
ResourceBundle(const ResourceBundle &original)
Copy constructor.
ResourceBundle(const UnicodeString &packageName, UErrorCode &err)
Construct a resource bundle for the default bundle in the specified package.
UnicodeString getNextString(UErrorCode &status)
Returns the next string in a resource or NULL if there are no more resources to iterate over.
UObject is the common ICU "boilerplate" class.
Definition: uobject.h:221
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition: unistr.h:294
C++ API: Locale ID object.
ULocDataLocaleType
Constants for *_getLocale() Allow user to select whether she wants information on requested,...
Definition: uloc.h:336
int8_t UBool
The ICU boolean type.
Definition: umachine.h:234
C++ API: Unicode String.
C++ API: Common ICU base class UObject.
void * UClassID
UClassID is used to identify classes without using the compiler's RTTI.
Definition: uobject.h:91
C API: Resource Bundle.
UResType
Numeric constants for types of resource items.
Definition: ures.h:64
struct UResourceBundle UResourceBundle
Definition: ures.h:57
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_COMMON_API
Set to export library symbols from inside the common library, and to import them from outside.
Definition: utypes.h:357
#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