// © 2016 and later: Unicode, Inc. and others. // License & terms of use: http://www.unicode.org/copyright.html /* ********************************************************************** * Copyright (C) 1997-2016, International Business Machines * Corporation and others. All Rights Reserved. ********************************************************************** * * File locid.cpp * * Created by: Richard Gillam * * Modification History: * * Date Name Description * 02/11/97 aliu Changed gLocPath to fgDataDirectory and added * methods to get and set it. * 04/02/97 aliu Made operator!= inline; fixed return value * of getName(). * 04/15/97 aliu Cleanup for AIX/Win32. * 04/24/97 aliu Numerous changes per code review. * 08/18/98 stephen Changed getDisplayName() * Added SIMPLIFIED_CHINESE, TRADITIONAL_CHINESE * Added getISOCountries(), getISOLanguages(), * getLanguagesForCountry() * 03/16/99 bertrand rehaul. * 07/21/99 stephen Added U_CFUNC setDefault * 11/09/99 weiv Added const char * getName() const; * 04/12/00 srl removing unicodestring api's and cached hash code * 08/10/01 grhoten Change the static Locales to accessor functions ****************************************************************************** */ #include <utility> #include "unicode/bytestream.h" #include "unicode/locid.h" #include "unicode/localebuilder.h" #include "unicode/strenum.h" #include "unicode/stringpiece.h" #include "unicode/uloc.h" #include "unicode/ures.h" #include "bytesinkutil.h" #include "charstr.h" #include "charstrmap.h" #include "cmemory.h" #include "cstring.h" #include "mutex.h" #include "putilimp.h" #include "uassert.h" #include "ucln_cmn.h" #include "uhash.h" #include "ulocimp.h" #include "umutex.h" #include "uniquecharstr.h" #include "ustr_imp.h" #include "uvector.h" U_CDECL_BEGIN static UBool U_CALLCONV locale_cleanup(); U_CDECL_END U_NAMESPACE_BEGIN static Locale *gLocaleCache = …; static UInitOnce gLocaleCacheInitOnce { … }; // gDefaultLocaleMutex protects all access to gDefaultLocalesHashT and gDefaultLocale. static UMutex gDefaultLocaleMutex; static UHashtable *gDefaultLocalesHashT = …; static Locale *gDefaultLocale = …; /** * \def ULOC_STRING_LIMIT * strings beyond this value crash in CharString */ #define ULOC_STRING_LIMIT … U_NAMESPACE_END ELocalePos; U_CDECL_BEGIN // // Deleter function for Locales owned by the default Locale hash table/ // static void U_CALLCONV deleteLocale(void *obj) { … } static UBool U_CALLCONV locale_cleanup() { … } static void U_CALLCONV locale_init(UErrorCode &status) { … } U_CDECL_END U_NAMESPACE_BEGIN Locale *locale_set_default_internal(const char *id, UErrorCode& status) { … } U_NAMESPACE_END /* sfb 07/21/99 */ U_CFUNC void locale_set_default(const char *id) { … } /* end */ U_CFUNC const char * locale_get_default() { … } U_NAMESPACE_BEGIN