ICU-185 don't call Locale(UnicodeString..) deprecated apis

X-SVN-Rev: 1135
This commit is contained in:
Steven R. Loomis 2000-04-15 21:23:28 +00:00
parent 90d12c93b9
commit e78d6db835
16 changed files with 55 additions and 44 deletions

View file

@ -22,7 +22,7 @@
#include "unicode/brkiter.h"
#include "unicode/udata.h"
#include "unicode/resbund.h"
#include "cstring.h"
#include <string.h>
// *****************************************************************************
@ -48,7 +48,8 @@ BreakIterator::createWordInstance(const Locale& key, UErrorCode& status)
UnicodeString temp;
if (U_FAILURE(status)) return NULL;
if (key.getLanguage(temp) == UnicodeString("th", (char*)0)) {
if (!uprv_strcmp(key.getLanguage(), "th"))
{
filename = "word_th";
}
@ -58,7 +59,7 @@ BreakIterator::createWordInstance(const Locale& key, UErrorCode& status)
const void* image = udata_getMemory(file);
if (image != NULL) {
if (key.getLanguage(temp) == UnicodeString("th", (char*)0)) {
if(!uprv_strcmp(filename, "word_th")) {
const char* dataDir = u_getDataDirectory();
filename = "thaidict.brk";
char* fullPath = new char[strlen(dataDir) + strlen(filename) + 1];
@ -91,7 +92,8 @@ BreakIterator::createLineInstance(const Locale& key, UErrorCode& status)
UnicodeString temp;
if (U_FAILURE(status)) return NULL;
if (key.getLanguage(temp) == UnicodeString("th", (char*)0)) {
if (!uprv_strcmp(key.getLanguage(), "th"))
{
filename = "line_th";
}
@ -101,7 +103,7 @@ BreakIterator::createLineInstance(const Locale& key, UErrorCode& status)
const void* image = udata_getMemory(file);
if (image != NULL) {
if (key.getLanguage(temp) == UnicodeString("th", (char*)0)) {
if (!uprv_strcmp(key.getLanguage(), "th")) {
const char* dataDir = u_getDataDirectory();
filename = "thaidict.brk";
char* fullPath = new char[strlen(dataDir) + strlen(filename) + 1];

View file

@ -706,7 +706,7 @@ Calendar::setWeekCountData(const Locale& desiredLocale, UErrorCode& status)
int32_t count;
if (U_FAILURE(status)) return;
ResourceBundle resource(Locale::getDataDirectory(), desiredLocale, status);
ResourceBundle resource(u_getDataDirectory(), desiredLocale, status);
// If the resource data doesn't seem to be present at all, then use last-resort
// hard-coded data.

View file

@ -242,7 +242,7 @@ DateFormat::getAvailableLocales(int32_t& count)
for (i=0; i<localesCount; ++i)
{
UErrorCode status = U_ZERO_ERROR;
ResourceBundle resource(Locale::getDataDirectory(), locales[i], status);
ResourceBundle resource(u_getDataDirectory(), locales[i], status);
int32_t ignoredCount;
resource.getStringArray(SimpleDateFormat::fgDateTimePatternsTag, ignoredCount, status);
if (U_SUCCESS(status))

View file

@ -172,7 +172,7 @@ DecimalFormatSymbols::initialize(const Locale& locale, UErrorCode& status,
{
if (U_FAILURE(status)) return;
ResourceBundle resource(Locale::getDataDirectory(), locale, status);
ResourceBundle resource(u_getDataDirectory(), locale, status);
if (U_FAILURE(status))
{
// Initializes with last resort data if necessary.

View file

@ -197,7 +197,7 @@ DecimalFormat::construct(UErrorCode& status,
// one specified.
if (pattern == NULL)
{
ResourceBundle resource(Locale::getDataDirectory(), Locale::getDefault(), status);
ResourceBundle resource(u_getDataDirectory(), Locale::getDefault(), status);
resource.getArrayItem(fgNumberPatterns, 0, str, status);
pattern = &str;
}

View file

@ -427,7 +427,7 @@ DateFormatSymbols::initializeData(const Locale& locale, UErrorCode& status, bool
* We cast away const here, but that's okay; we won't delete any of
* these.
*/
ResourceBundle resource(Locale::getDataDirectory(), locale, status);
ResourceBundle resource(u_getDataDirectory(), locale, status);
if (U_FAILURE(status))
{
if (useLastResortData)

View file

@ -406,7 +406,7 @@ NumberFormat::createInstance(const Locale& desiredLocale,
return NULL;
}
ResourceBundle resource(Locale::getDataDirectory(), desiredLocale, status);
ResourceBundle resource(u_getDataDirectory(), desiredLocale, status);
if (U_FAILURE(status))
{
// We don't appear to have resource data available -- use the last-resort data

View file

@ -263,7 +263,7 @@ void SimpleDateFormat::construct(EStyle timeStyle,
// load up the DateTimePatters resource from the appropriate locale (throw
// an error if for some weird reason the resource is malformed)
ResourceBundle resources(Locale::getDataDirectory(), locale, status);
ResourceBundle resources(u_getDataDirectory(), locale, status);
int32_t dtCount;
const UnicodeString *dateTimePatterns = resources.getStringArray(fgDateTimePatternsTag, dtCount, status);
if (U_FAILURE(status)) return;

View file

@ -792,8 +792,7 @@ RuleBasedCollator::RuleBasedCollator( const Locale& desiredLocale,
// language
// Root: (aka DEFAULTRULES)
UnicodeString localeName;
desiredLocale.getName(localeName);
UnicodeString localeName(desiredLocale.getName(), "");
enum { eTryDefaultLocale, eTryDefaultCollation, eDone } next = eTryDefaultLocale;
for (;;)
@ -823,7 +822,7 @@ RuleBasedCollator::RuleBasedCollator( const Locale& desiredLocale,
// srl write out default.col
{
UnicodeString defLocaleName = UnicodeString(ResourceBundle::kDefaultFilename,"");
char *binaryFilePath = createPathName(UnicodeString(Locale::getDataDirectory(),""),
char *binaryFilePath = createPathName(UnicodeString(u_getDataDirectory(),""),
defLocaleName, UnicodeString(kFilenameSuffix,""));
bool_t ok = writeToFile(binaryFilePath);
delete [] binaryFilePath;
@ -833,7 +832,7 @@ RuleBasedCollator::RuleBasedCollator( const Locale& desiredLocale,
}
data->desiredLocale = desiredLocale;
desiredLocale.getName(localeName);
localeName = desiredLocale.getName();
data->realLocaleName = localeName;
addToCache(localeName);
@ -849,7 +848,7 @@ RuleBasedCollator::RuleBasedCollator( const Locale& desiredLocale,
{
case eTryDefaultLocale:
status = U_USING_DEFAULT_ERROR;
Locale::getDefault().getName(localeName);
localeName = Locale::getDefault().getName();
next = eTryDefaultCollation;
break;
@ -945,7 +944,7 @@ RuleBasedCollator::constructFromFile( const Locale& locale,
data = 0;
}
char *binaryFilePath = createPathName(UnicodeString(Locale::getDataDirectory(),""),
char *binaryFilePath = createPathName(UnicodeString(u_getDataDirectory(),""),
localeFileName, UnicodeString(kFilenameSuffix,""));
if(tryBinaryFile) {
@ -962,10 +961,16 @@ RuleBasedCollator::constructFromFile( const Locale& locale,
}
// Now try to load it up from a resource bundle text source file
UnicodeString dataDir = UnicodeString(Locale::getDataDirectory(),"");
UnicodeString dataDir = UnicodeString(u_getDataDirectory(),"");
ResourceBundle bundle(dataDir, localeFileName, status);
char *ch;
ch = new char[localeFileName.size() + 1];
ch[localeFileName.extract(0, 0x7fffffff, ch, "")] = 0;
ResourceBundle bundle(dataDir, ch, status);
delete [] ch;
// if there is no resource bundle file for the give locale, break out
if(U_FAILURE(status))
{

View file

@ -383,7 +383,7 @@ UnicodeString& Transliterator::getDisplayName(const UnicodeString& ID,
const Locale& inLocale,
UnicodeString& result) {
UErrorCode status = U_ZERO_ERROR;
ResourceBundle bundle(Locale::getDataDirectory(), inLocale, status);
ResourceBundle bundle(u_getDataDirectory(), inLocale, status);
// Suspend checking status until later...
// build the char* key
@ -572,7 +572,7 @@ const char* Transliterator::RESOURCE_SUB_DIR = "translit";
/**
* Returns the directory in which the transliterator resource bundle
* files are located. This is a subdirectory, named RESOURCE_SUB_DIR,
* under Locale::getDataDirectory(). It ends in a path separator.
* under u_getDataDirectory(). It ends in a path separator.
*/
const char* Transliterator::getDataDirectory(void) {
if (DATA_DIR == 0) {
@ -581,7 +581,7 @@ const char* Transliterator::getDataDirectory(void) {
/* Construct the transliterator data directory path. This
* is a subdirectory of the locale data directory.
*/
const char* data = Locale::getDataDirectory();
const char* data = u_getDataDirectory();
int32_t len = uprv_strlen(data);
DATA_DIR = (char*) uprv_malloc(
len + uprv_strlen(RESOURCE_SUB_DIR) + 2);
@ -642,7 +642,11 @@ Transliterator* Transliterator::_createInstance(const UnicodeString& ID,
// 2-d array at static init time, as a locale language. We're
// just using the locale mechanism to map through to a file
// name; this in no way represents an actual locale.
Locale fakeLocale(entry->rbFile);
char *ch;
ch = new char[entry->rbFile.size() + 1];
ch[entry->rbFile.extract(0, 0x7fffffff, ch, "")] = 0;
Locale fakeLocale(ch);
delete [] ch;
ResourceBundle bundle(Transliterator::getDataDirectory(),
fakeLocale, status);
@ -864,7 +868,7 @@ void Transliterator::initializeCache(void) {
* }
*/
Locale indexLoc(UNICODE_STRING("index", 5));
Locale indexLoc("index");
ResourceBundle bundle(Transliterator::getDataDirectory(),
indexLoc, status);

View file

@ -26,19 +26,19 @@ ubrk_open(UBreakIteratorType type,
switch(type) {
case UBRK_CHARACTER:
result = BreakIterator::createCharacterInstance(Locale().init(locale), *status);
result = BreakIterator::createCharacterInstance(Locale(locale), *status);
break;
case UBRK_WORD:
result = BreakIterator::createWordInstance(Locale().init(locale), *status);
result = BreakIterator::createWordInstance(Locale(locale), *status);
break;
case UBRK_LINE:
result = BreakIterator::createLineInstance(Locale().init(locale), *status);
result = BreakIterator::createLineInstance(Locale(locale), *status);
break;
case UBRK_SENTENCE:
result = BreakIterator::createSentenceInstance(Locale().init(locale), *status);
result = BreakIterator::createSentenceInstance(Locale(locale), *status);
break;
}

View file

@ -87,7 +87,7 @@ ucal_open( const UChar* zoneID,
return 0;
}
return (UCalendar*)Calendar::createInstance(zone, Locale().init(locale), *status);
return (UCalendar*)Calendar::createInstance(zone, Locale(locale), *status);
}
U_CAPI void
@ -138,19 +138,19 @@ ucal_getTimeZoneDisplayName( const UCalendar* cal,
switch(type) {
case UCAL_STANDARD:
tz.getDisplayName(FALSE, TimeZone::LONG, Locale().init(locale), id);
tz.getDisplayName(FALSE, TimeZone::LONG, Locale(locale), id);
break;
case UCAL_SHORT_STANDARD:
tz.getDisplayName(FALSE, TimeZone::SHORT, Locale().init(locale), id);
tz.getDisplayName(FALSE, TimeZone::SHORT, Locale(locale), id);
break;
case UCAL_DST:
tz.getDisplayName(TRUE, TimeZone::LONG, Locale().init(locale), id);
tz.getDisplayName(TRUE, TimeZone::LONG, Locale(locale), id);
break;
case UCAL_SHORT_DST:
tz.getDisplayName(TRUE, TimeZone::SHORT, Locale().init(locale), id);
tz.getDisplayName(TRUE, TimeZone::SHORT, Locale(locale), id);
break;
}

View file

@ -70,7 +70,7 @@ ucol_open( const char *loc,
if(loc == 0)
col = Collator::createInstance(*status);
else
col = Collator::createInstance(Locale().init(loc), *status);
col = Collator::createInstance(Locale(loc), *status);
if(col == 0) {
*status = U_MEMORY_ALLOCATION_ERROR;
@ -248,7 +248,7 @@ ucol_getDisplayName( const char *objLoc,
if(U_FAILURE(*status)) return -1;
UnicodeString dst(result, resultLength, resultLength);
Collator::getDisplayName(Locale().init(objLoc), Locale().init(dispLoc), dst);
Collator::getDisplayName(Locale(objLoc), Locale(dispLoc), dst);
int32_t actLen;
T_fillOutputParams(&dst, result, resultLength, &actLen, status);
return actLen;

View file

@ -36,7 +36,7 @@ udat_open( UDateFormatStyle timeStyle,
else
fmt = DateFormat::createDateTimeInstance((DateFormat::EStyle)dateStyle,
(DateFormat::EStyle)timeStyle,
Locale().init(locale));
Locale(locale));
if(fmt == 0) {
*status = U_MEMORY_ALLOCATION_ERROR;
@ -77,7 +77,7 @@ udat_openPattern( const UChar *pattern,
else
retVal = (UDateFormat*)new SimpleDateFormat(UnicodeString((UChar*)pattern,
len, len),
Locale().init(locale),
Locale(locale),
*status);
if(retVal == 0) {

View file

@ -411,7 +411,7 @@ u_vformatMessage( const char *locale,
// just call through to the C++ implementation
UnicodeString patString((UChar*)pattern, patLen, patLen);
MessageFormat fmt(patString, Locale().init(locale), *status);
MessageFormat fmt(patString, Locale(locale), *status);
UnicodeString res(result, 0, resultLength);
FieldPosition fp;
fmt.format(args, count, res, fp, *status);
@ -462,7 +462,7 @@ u_vparseMessage( const char *locale,
int32_t srcLen = (sourceLength == -1 ? u_strlen(source) : sourceLength);
UnicodeString patString((UChar*)pattern, patLen, patLen);
MessageFormat fmt(patString, Locale().init(locale), *status);
MessageFormat fmt(patString, Locale(locale), *status);
UnicodeString srcString((UChar*)source, srcLen, srcLen);
int32_t count = 0;
Formattable *args = fmt.parse(srcString, count, *status);

View file

@ -34,7 +34,7 @@ unum_open( UNumberFormatStyle style,
if(locale == 0)
retVal = (UNumberFormat*)NumberFormat::createInstance(*status);
else
retVal = (UNumberFormat*)NumberFormat::createInstance(Locale().init(locale),
retVal = (UNumberFormat*)NumberFormat::createInstance(Locale(locale),
*status);
break;
@ -42,7 +42,7 @@ unum_open( UNumberFormatStyle style,
if(locale == 0)
retVal = (UNumberFormat*)NumberFormat::createCurrencyInstance(*status);
else
retVal = (UNumberFormat*)NumberFormat::createCurrencyInstance(Locale().init(locale),
retVal = (UNumberFormat*)NumberFormat::createCurrencyInstance(Locale(locale),
*status);
break;
@ -50,7 +50,7 @@ unum_open( UNumberFormatStyle style,
if(locale == 0)
retVal = (UNumberFormat*)NumberFormat::createPercentInstance(*status);
else
retVal = (UNumberFormat*)NumberFormat::createPercentInstance(Locale().init(locale),
retVal = (UNumberFormat*)NumberFormat::createPercentInstance(Locale(locale),
*status);
break;
@ -85,7 +85,7 @@ unum_openPattern( const UChar* pattern,
if(locale == 0)
syms = new DecimalFormatSymbols(*status);
else
syms = new DecimalFormatSymbols(Locale().init(locale),
syms = new DecimalFormatSymbols(Locale(locale),
*status);
if(syms == 0) {