intl/icu/source/common/servrbf.cpp

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /**
     2  *******************************************************************************
     3  * Copyright (C) 2001-2005, International Business Machines Corporation and    *
     4  * others. All Rights Reserved.                                                *
     5  *******************************************************************************
     6  *
     7  *******************************************************************************
     8  */
     9 #include "unicode/utypes.h"
    11 #if !UCONFIG_NO_SERVICE
    13 #include "unicode/resbund.h"
    14 #include "uresimp.h"
    15 #include "cmemory.h"
    16 #include "servloc.h"
    17 #include "ustrfmt.h"
    18 #include "uhash.h"
    19 #include "charstr.h"
    20 #include "ucln_cmn.h"
    21 #include "uassert.h"
    23 #define UNDERSCORE_CHAR ((UChar)0x005f)
    24 #define AT_SIGN_CHAR    ((UChar)64)
    25 #define PERIOD_CHAR     ((UChar)46)
    27 U_NAMESPACE_BEGIN
    29 ICUResourceBundleFactory::ICUResourceBundleFactory()
    30   : LocaleKeyFactory(VISIBLE)
    31   , _bundleName()
    32 {
    33 }
    35 ICUResourceBundleFactory::ICUResourceBundleFactory(const UnicodeString& bundleName)
    36   : LocaleKeyFactory(VISIBLE)
    37   , _bundleName(bundleName)
    38 {
    39 }
    41 ICUResourceBundleFactory::~ICUResourceBundleFactory() {}
    43 const Hashtable*
    44 ICUResourceBundleFactory::getSupportedIDs(UErrorCode& status) const
    45 {
    46     if (U_SUCCESS(status)) {
    47         return LocaleUtility::getAvailableLocaleNames(_bundleName);
    48     }
    49     return NULL;
    50 }
    52 UObject*
    53 ICUResourceBundleFactory::handleCreate(const Locale& loc, int32_t /* kind */, const ICUService* /* service */, UErrorCode& status) const
    54 {
    55     if (U_SUCCESS(status)) {
    56         // _bundleName is a package name
    57         // and should only contain invariant characters
    58                 // ??? is it always true that the max length of the bundle name is 19?
    59                 // who made this change? -- dlf
    60         char pkg[20];
    61         int32_t length;
    62         length=_bundleName.extract(0, INT32_MAX, pkg, (int32_t)sizeof(pkg), US_INV);
    63         if(length>=(int32_t)sizeof(pkg)) {
    64             return NULL;
    65         }
    66         return new ResourceBundle(pkg, loc, status);
    67     }
    68     return NULL;
    69 }
    71 #ifdef SERVICE_DEBUG
    72 UnicodeString&
    73 ICUResourceBundleFactory::debug(UnicodeString& result) const
    74 {
    75     LocaleKeyFactory::debug(result);
    76     result.append(", bundle: ");
    77     return result.append(_bundleName);
    78 }
    80 UnicodeString&
    81 ICUResourceBundleFactory::debugClass(UnicodeString& result) const
    82 {
    83     return result.append("ICUResourceBundleFactory");
    84 }
    85 #endif
    87 UOBJECT_DEFINE_RTTI_IMPLEMENTATION(ICUResourceBundleFactory)
    89 U_NAMESPACE_END
    91 /* !UCONFIG_NO_SERVICE */
    92 #endif

mercurial