]>
git.saurik.com Git - apple/icu.git/blob - icuSources/common/locbased.h
1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
4 **********************************************************************
5 * Copyright (c) 2004-2014, International Business Machines
6 * Corporation and others. All Rights Reserved.
7 **********************************************************************
9 * Created: January 16 2004
11 **********************************************************************
16 #include "unicode/locid.h"
17 #include "unicode/uobject.h"
20 * Macro to declare a locale LocaleBased wrapper object for the given
21 * object, which must have two members named `validLocale' and
22 * `actualLocale' of size ULOC_FULLNAME_CAPACITY
24 #define U_LOCALE_BASED(varname, objname) \
25 LocaleBased varname((objname).validLocale, (objname).actualLocale);
30 * A utility class that unifies the implementation of getLocale() by
31 * various ICU services. This class is likely to be removed in the
32 * ICU 3.0 time frame in favor of an integrated approach with the
36 class U_COMMON_API LocaleBased
: public UMemory
{
41 * Construct a LocaleBased wrapper around the two pointers. These
42 * will be aliased for the lifetime of this object.
44 inline LocaleBased(char* validAlias
, char* actualAlias
);
47 * Construct a LocaleBased wrapper around the two const pointers.
48 * These will be aliased for the lifetime of this object.
50 inline LocaleBased(const char* validAlias
, const char* actualAlias
);
53 * Return locale meta-data for the service object wrapped by this
54 * object. Either the valid or the actual locale may be
56 * @param type either ULOC_VALID_LOCALE or ULOC_ACTUAL_LOCALE
57 * @param status input-output error code
58 * @return the indicated locale
60 Locale
getLocale(ULocDataLocaleType type
, UErrorCode
& status
) const;
63 * Return the locale ID for the service object wrapped by this
64 * object. Either the valid or the actual locale may be
66 * @param type either ULOC_VALID_LOCALE or ULOC_ACTUAL_LOCALE
67 * @param status input-output error code
68 * @return the indicated locale ID
70 const char* getLocaleID(ULocDataLocaleType type
, UErrorCode
& status
) const;
73 * Set the locale meta-data for the service object wrapped by this
74 * object. If either parameter is zero, it is ignored.
75 * @param valid the ID of the valid locale
76 * @param actual the ID of the actual locale
78 void setLocaleIDs(const char* valid
, const char* actual
);
81 * Set the locale meta-data for the service object wrapped by this
83 * @param valid the ID of the valid locale
84 * @param actual the ID of the actual locale
86 void setLocaleIDs(const Locale
& valid
, const Locale
& actual
);
95 inline LocaleBased::LocaleBased(char* validAlias
, char* actualAlias
) :
96 valid(validAlias
), actual(actualAlias
) {
99 inline LocaleBased::LocaleBased(const char* validAlias
,
100 const char* actualAlias
) :
101 // ugh: cast away const
102 valid((char*)validAlias
), actual((char*)actualAlias
) {