]>
git.saurik.com Git - apple/icu.git/blob - icuSources/common/locbased.h
2 **********************************************************************
3 * Copyright (c) 2004, International Business Machines
4 * Corporation and others. All Rights Reserved.
5 **********************************************************************
7 * Created: January 16 2004
9 **********************************************************************
14 #include "unicode/locid.h"
15 #include "unicode/uobject.h"
18 * Macro to declare a locale LocaleBased wrapper object for the given
19 * object, which must have two members named `validLocale' and
22 #define U_LOCALE_BASED(varname, objname) \
23 LocaleBased varname((objname).validLocale, (objname).actualLocale);
28 * A utility class that unifies the implementation of getLocale() by
29 * various ICU services. This class is likely to be removed in the
30 * ICU 3.0 time frame in favor of an integrated approach with the
34 class U_COMMON_API LocaleBased
: public UMemory
{
39 * Construct a LocaleBased wrapper around the two pointers. These
40 * will be aliased for the lifetime of this object.
42 inline LocaleBased(char* validAlias
, char* actualAlias
);
45 * Construct a LocaleBased wrapper around the two const pointers.
46 * These will be aliased for the lifetime of this object.
48 inline LocaleBased(const char* validAlias
, const char* actualAlias
);
51 * Return locale meta-data for the service object wrapped by this
52 * object. Either the valid or the actual locale may be
54 * @param type either ULOC_VALID_LOCALE or ULOC_ACTUAL_LOCALE
55 * @param status input-output error code
56 * @return the indicated locale
58 Locale
getLocale(ULocDataLocaleType type
, UErrorCode
& status
) const;
61 * Return the locale ID for the service object wrapped by this
62 * object. Either the valid or the actual locale may be
64 * @param type either ULOC_VALID_LOCALE or ULOC_ACTUAL_LOCALE
65 * @param status input-output error code
66 * @return the indicated locale ID
68 const char* getLocaleID(ULocDataLocaleType type
, UErrorCode
& status
) const;
71 * Set the locale meta-data for the service object wrapped by this
72 * object. If either parameter is zero, it is ignored.
73 * @param valid the ID of the valid locale
74 * @param actual the ID of the actual locale
76 void setLocaleIDs(const char* valid
, const char* actual
);
85 inline LocaleBased::LocaleBased(char* validAlias
, char* actualAlias
) :
86 valid(validAlias
), actual(actualAlias
) {
89 inline LocaleBased::LocaleBased(const char* validAlias
,
90 const char* actualAlias
) :
91 // ugh: cast away const
92 valid((char*)validAlias
), actual((char*)actualAlias
) {