]>
git.saurik.com Git - apple/icu.git/blob - icuSources/common/locbased.h
2 **********************************************************************
3 * Copyright (c) 2004-2014, 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
20 * `actualLocale' of size ULOC_FULLNAME_CAPACITY
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
);
79 * Set the locale meta-data for the service object wrapped by this
81 * @param valid the ID of the valid locale
82 * @param actual the ID of the actual locale
84 void setLocaleIDs(const Locale
& valid
, const Locale
& actual
);
93 inline LocaleBased::LocaleBased(char* validAlias
, char* actualAlias
) :
94 valid(validAlias
), actual(actualAlias
) {
97 inline LocaleBased::LocaleBased(const char* validAlias
,
98 const char* actualAlias
) :
99 // ugh: cast away const
100 valid((char*)validAlias
), actual((char*)actualAlias
) {