ICU 62.1 62.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#include "unicode/uobject.h"
53#include "unicode/ures.h"
54#include "unicode/unistr.h"
55#include "unicode/locid.h"
56
63
81public:
109 const Locale& locale,
110 UErrorCode& err);
111
124 UErrorCode& err);
125
133
149 const Locale& locale,
150 UErrorCode& err);
151
159
171
180
185
198
209 int32_t
210 getSize(void) const;
211
224
237 const uint8_t*
238 getBinary(int32_t& len, UErrorCode& status) const;
239
240
252 const int32_t*
253 getIntVector(int32_t& len, UErrorCode& status) const;
254
266 uint32_t
268
280 int32_t
282
289 UBool
290 hasNext(void) const;
291
297 void
299
307 const char*
308 getKey(void) const;
309
317 const char*
318 getName(void) const;
319
320
328 getType(void) const;
329
339
350
361 getNextString(const char ** key,
363
373 get(int32_t index,
374 UErrorCode& status) const;
375
385 getStringEx(int32_t index,
386 UErrorCode& status) const;
387
398 get(const char* key,
399 UErrorCode& status) const;
400
411 getStringEx(const char* key,
412 UErrorCode& status) const;
413
414#ifndef U_HIDE_DEPRECATED_API
424 const char*
425 getVersionNumber(void) const;
426#endif /* U_HIDE_DEPRECATED_API */
427
435 void
437
438#ifndef U_HIDE_DEPRECATED_API
445 const Locale&
446 getLocale(void) const;
447#endif /* U_HIDE_DEPRECATED_API */
448
459 const Locale
461#ifndef U_HIDE_INTERNAL_API
468#endif /* U_HIDE_INTERNAL_API */
475
482
483private:
484 ResourceBundle(); // default constructor not implemented
485
486 UResourceBundle *fResource;
487 void constructForLocale(const UnicodeString& path, const Locale& locale, UErrorCode& error);
488 Locale *fLocale;
489};
490
492#endif
"Smart pointer" base class; do not use directly: use LocalPointer etc.
A Locale object represents a specific geographical, political, or cultural region.
Definition locid.h:188
A class representing a collection of resource information pertaining to a given locale.
Definition resbund.h:80
ResourceBundle(UResourceBundle *res, UErrorCode &status)
Constructor from a C UResourceBundle.
ResourceBundle(const ResourceBundle &original)
Copy constructor.
ResourceBundle * clone() const
Clone this object.
const char * getVersionNumber(void) const
Return the version number associated with this ResourceBundle as a string.
const char * getName(void) const
Gets the locale ID of the resource bundle as a string.
ResourceBundle(const char *packageName, const Locale &locale, UErrorCode &err)
Standard constructor, constructs a resource bundle for the locale-specific bundle in the specified pa...
ResourceBundle get(int32_t index, UErrorCode &status) const
Returns the resource in a resource at the specified index.
ResourceBundle(const UnicodeString &packageName, UErrorCode &err)
Construct a resource bundle for the default bundle in the specified package.
int32_t getInt(UErrorCode &status) const
returns a signed integer from a resource.
const int32_t * getIntVector(int32_t &len, UErrorCode &status) const
returns an integer vector from a resource.
ResourceBundle get(const char *key, UErrorCode &status) const
Returns a resource in a resource that has a given key.
ResourceBundle & operator=(const ResourceBundle &other)
Assignment operator.
void getVersion(UVersionInfo versionInfo) const
Return the version number associated with this ResourceBundle as a UVersionInfo array.
ResourceBundle getNext(UErrorCode &status)
Returns the next resource in a given resource or NULL if there are no more resources.
virtual UClassID getDynamicClassID() const
ICU "poor man's RTTI", returns a UClassID for the actual class.
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.
void resetIterator(void)
Resets the internal context of a resource so that iteration starts from the first element.
UnicodeString getStringEx(int32_t index, UErrorCode &status) const
Returns the string in a given resource at the specified index.
ResourceBundle getWithFallback(const char *key, UErrorCode &status)
This API implements multilevel fallback.
const Locale & getLocale(void) const
Return the Locale associated with this ResourceBundle.
UnicodeString getNextString(UErrorCode &status)
Returns the next string in a resource or NULL if there are no more resources to iterate over.
const Locale getLocale(ULocDataLocaleType type, UErrorCode &status) const
Return the Locale associated with this ResourceBundle.
UResType getType(void) const
Returns the type of a resource.
const uint8_t * getBinary(int32_t &len, UErrorCode &status) const
returns a binary data from a resource.
uint32_t getUInt(UErrorCode &status) const
returns an unsigned integer from a resource.
const char * getKey(void) const
Returns the key associated with this resource.
int32_t getSize(void) const
Returns the size of a resource.
virtual ~ResourceBundle()
Destructor.
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(const UnicodeString &packageName, const Locale &locale, UErrorCode &err)
Constructor.
UnicodeString getString(UErrorCode &status) const
returns a string from a string resource type
UBool hasNext(void) const
Checks whether the resource has another element to iterate over.
UnicodeString getStringEx(const char *key, UErrorCode &status) const
Returns a string in a resource that has a given key.
UObject is the common ICU "boilerplate" class.
Definition uobject.h:223
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition unistr.h:287
C++ API: Locale ID object.
ULocDataLocaleType
Constants for *_getLocale() Allow user to select whether she wants information on requested,...
Definition uloc.h:338
int8_t UBool
The ICU boolean type.
Definition umachine.h:236
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:93
C API: Resource Bundle.
UResType
Numeric constants for types of resource items.
Definition ures.h:66
struct UResourceBundle UResourceBundle
Definition ures.h:59
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:396
#define U_COMMON_API
Set to export library symbols from inside the common library, and to import them from outside.
Definition utypes.h:359
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
Definition uversion.h:138
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
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition uversion.h:137