ICU 71.1 71.1

resbund.h
Go to the documentation of this file.
1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
3 /*
4 ******************************************************************************
5 *
6 * Copyright (C) 1996-2013, International Business Machines Corporation
7 * and others. All Rights Reserved.
8 *
9 ******************************************************************************
10 *
11 * File resbund.h
12 *
13 * CREATED BY
14 * Richard Gillam
15 *
16 * Modification History:
17 *
18 * Date Name Description
19 * 2/5/97 aliu Added scanForLocaleInFile. Added
20 * constructor which attempts to read resource bundle
21 * from a specific file, without searching other files.
22 * 2/11/97 aliu Added UErrorCode return values to constructors. Fixed
23 * infinite loops in scanForFile and scanForLocale.
24 * Modified getRawResourceData to not delete storage
25 * in localeData and resourceData which it doesn't own.
26 * Added Mac compatibility #ifdefs for tellp() and
27 * ios::nocreate.
28 * 2/18/97 helena Updated with 100% documentation coverage.
29 * 3/13/97 aliu Rewrote to load in entire resource bundle and store
30 * it as a Hashtable of ResourceBundleData objects.
31 * Added state table to govern parsing of files.
32 * Modified to load locale index out of new file
33 * distinct from default.txt.
34 * 3/25/97 aliu Modified to support 2-d arrays, needed for timezone
35 * data. Added support for custom file suffixes. Again,
36 * needed to support timezone data.
37 * 4/7/97 aliu Cleaned up.
38 * 03/02/99 stephen Removed dependency on FILE*.
39 * 03/29/99 helena Merged Bertrand and Stephen's changes.
40 * 06/11/99 stephen Removed parsing of .txt files.
41 * Reworked to use new binary format.
42 * Cleaned up.
43 * 06/14/99 stephen Removed methods taking a filename suffix.
44 * 11/09/99 weiv Added getLocale(), fRealLocale, removed fRealLocaleID
45 ******************************************************************************
46 */
47
48 #ifndef RESBUND_H
49 #define RESBUND_H
50
51 #include "unicode/utypes.h"
52
53 #if U_SHOW_CPLUSPLUS_API
54
55 #include "unicode/uobject.h"
56 #include "unicode/ures.h"
57 #include "unicode/unistr.h"
58 #include "unicode/locid.h"
59
65 U_NAMESPACE_BEGIN
66
83 class U_COMMON_API ResourceBundle : public UObject {
84 public:
111 ResourceBundle(const UnicodeString& packageName,
112 const Locale& locale,
113 UErrorCode& err);
114
126 ResourceBundle(const UnicodeString& packageName,
127 UErrorCode& err);
128
135 ResourceBundle(UErrorCode &err);
136
151 ResourceBundle(const char* packageName,
152 const Locale& locale,
153 UErrorCode& err);
154
161 ResourceBundle(const ResourceBundle &original);
162
172 ResourceBundle(UResourceBundle *res,
173 UErrorCode &status);
174
181 ResourceBundle&
182 operator=(const ResourceBundle& other);
183
187 virtual ~ResourceBundle();
188
200 ResourceBundle *clone() const;
201
212 int32_t
213 getSize(void) const;
214
225 UnicodeString
226 getString(UErrorCode& status) const;
227
240 const uint8_t*
241 getBinary(int32_t& len, UErrorCode& status) const;
242
243
255 const int32_t*
256 getIntVector(int32_t& len, UErrorCode& status) const;
257
269 uint32_t
270 getUInt(UErrorCode& status) const;
271
283 int32_t
284 getInt(UErrorCode& status) const;
285
292 UBool
293 hasNext(void) const;
294
300 void
301 resetIterator(void);
302
310 const char*
311 getKey(void) const;
312
320 const char*
321 getName(void) const;
322
323
330 UResType
331 getType(void) const;
332
340 ResourceBundle
341 getNext(UErrorCode& status);
342
351 UnicodeString
352 getNextString(UErrorCode& status);
353
363 UnicodeString
364 getNextString(const char ** key,
365 UErrorCode& status);
366
375 ResourceBundle
376 get(int32_t index,
377 UErrorCode& status) const;
378
387 UnicodeString
388 getStringEx(int32_t index,
389 UErrorCode& status) const;
390
400 ResourceBundle
401 get(const char* key,
402 UErrorCode& status) const;
403
413 UnicodeString
414 getStringEx(const char* key,
415 UErrorCode& status) const;
416
417 #ifndef U_HIDE_DEPRECATED_API
418
427 const char*
428 getVersionNumber(void) const;
429 #endif /* U_HIDE_DEPRECATED_API */
430
438 void
439 getVersion(UVersionInfo versionInfo) const;
440
441 #ifndef U_HIDE_DEPRECATED_API
442
448 const Locale&
449 getLocale(void) const;
450 #endif /* U_HIDE_DEPRECATED_API */
451
462 const Locale
463 getLocale(ULocDataLocaleType type, UErrorCode &status) const;
464 #ifndef U_HIDE_INTERNAL_API
465
469 ResourceBundle
470 getWithFallback(const char* key, UErrorCode& status);
471 #endif /* U_HIDE_INTERNAL_API */
472
477 virtual UClassID getDynamicClassID() const override;
478
484 static UClassID U_EXPORT2 getStaticClassID();
485
486 private:
487 ResourceBundle(); // default constructor not implemented
488
489 UResourceBundle *fResource;
490 void constructForLocale(const UnicodeString& path, const Locale& locale, UErrorCode& error);
491 Locale *fLocale;
492 };
493
494 U_NAMESPACE_END
495
496 #endif /* U_SHOW_CPLUSPLUS_API */
497
498 #endif
utypes.h
Basic definitions for ICU, for both C and C++ APIs.
UBool
int8_t UBool
The ICU boolean type, a signed-byte integer.
Definition: umachine.h:269
UResourceBundle
struct UResourceBundle UResourceBundle
Definition: ures.h:62
ULocDataLocaleType
ULocDataLocaleType
Constants for *_getLocale() Allow user to select whether she wants information on requested,...
Definition: uloc.h:338
UResType
UResType
Numeric constants for types of resource items.
Definition: ures.h:69
U_COMMON_API
#define U_COMMON_API
Definition: utypes.h:300
ures.h
C API: Resource Bundle.
icu::UnicodeString
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition: unistr.h:295
icu::UObject
UObject is the common ICU "boilerplate" class.
Definition: uobject.h:223
UClassID
void * UClassID
UClassID is used to identify classes without using the compiler's RTTI.
Definition: uobject.h:96
UErrorCode
UErrorCode
Standard ICU4C error code type, a substitute for exceptions.
Definition: utypes.h:415
icu::UObject::getDynamicClassID
virtual UClassID getDynamicClassID() const
ICU4C "poor man's RTTI", returns a UClassID for the actual ICU class.
icu::ResourceBundle
A class representing a collection of resource information pertaining to a given locale.
Definition: resbund.h:83
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
locid.h
C++ API: Locale ID object.
uobject.h
C++ API: Common ICU base class UObject.
icu::Locale
A Locale object represents a specific geographical, political, or cultural region.
Definition: locid.h:195
unistr.h
C++ API: Unicode String.