diff --git a/icu4c/source/common/Makefile.in b/icu4c/source/common/Makefile.in index a17dfc00cff..2f1eca0c62b 100644 --- a/icu4c/source/common/Makefile.in +++ b/icu4c/source/common/Makefile.in @@ -70,7 +70,7 @@ CPPFLAGS += @DATA_PACKAGING_CPPFLAGS@ OBJECTS = compdata.o dcmpdata.o normlzr.o unorm.o bidi.o ubidi.o \ ubidiwrt.o ubidiln.o chariter.o compitr.o cwchar.o schriter.o uchriter.o \ cpputils.o digitlst.o filestrm.o ushape.o umemstrm.o locid.o locmap.o uloc.o \ -mutex.o umutex.o putil.o udata.o uresbund.o uresdata.o rbdata.o resbund.o \ +mutex.o umutex.o putil.o udata.o uresbund.o uresdata.o resbund.o \ uchar.o ucmp8.o ucmp16.o ucmp32.o uvector.o uhash.o uhash_us.o \ unames.o unicode.o unistr.o ustring.o cstring.o utf_impl.o \ scsu.o ucnv.o ucnv_bld.o ucnv_cb.o ucnv_cnv.o ucnv_err.o ucnv_io.o convert.o \ diff --git a/icu4c/source/common/common.dsp b/icu4c/source/common/common.dsp index 202a35d12de..41f05165194 100644 --- a/icu4c/source/common/common.dsp +++ b/icu4c/source/common/common.dsp @@ -175,11 +175,6 @@ SOURCE=.\putil.c # End Source File # Begin Source File -SOURCE=.\rbdata.cpp -# ADD CPP /Za -# End Source File -# Begin Source File - SOURCE=.\resbund.cpp # ADD CPP /Za # End Source File @@ -634,10 +629,6 @@ InputPath=.\unicode\pwin32.h # End Source File # Begin Source File -SOURCE=.\rbdata.h -# End Source File -# Begin Source File - SOURCE=.\unicode\rep.h !IF "$(CFG)" == "common - Win32 Release" diff --git a/icu4c/source/common/rbdata.cpp b/icu4c/source/common/rbdata.cpp deleted file mode 100644 index 6a5a0ea8991..00000000000 --- a/icu4c/source/common/rbdata.cpp +++ /dev/null @@ -1,128 +0,0 @@ -/* - *************************************************************************** - * Copyright (C) 1998-2001, International Business Machines - * Corporation and others. All Rights Reserved. - *************************************************************************** -* -* File rbdata.cpp -* -* Modification History: -* -* Date Name Description -* 06/11/99 stephen Creation. (Moved here from resbund.cpp) -****************************************************************************** -*/ - -#include "rbdata.h" - -UClassID StringList::fgClassID = 0; // Value is irrelevant -UClassID String2dList::fgClassID = 0; // Value is irrelevant -UClassID TaggedList::fgClassID = 0; // Value is irrelevant - -//---------------------------------------------------------------------------- - -StringList::StringList() - : fCount(0), fStrings(0) -{} - -StringList::StringList(UnicodeString *adopted, - int32_t count) - : fCount(count), fStrings(adopted) -{} - -StringList::~StringList() -{ delete [] fStrings; } - -const UnicodeString& -StringList::operator[](int32_t i) const -{ return fStrings[i]; } - -UClassID -StringList::getDynamicClassID() const -{ return getStaticClassID(); } - -UClassID -StringList::getStaticClassID() -{ return (UClassID)&fgClassID; } - -//----------------------------------------------------------------------------- - -String2dList::String2dList() - : fRowCount(0), fColCount(0), fStrings(0) -{} - -String2dList::String2dList(UnicodeString **adopted, - int32_t rowCount, - int32_t colCount) - : fRowCount(rowCount), fColCount(colCount), fStrings(adopted) -{} - -String2dList::~String2dList() -{ - for(int32_t i = 0; i < fRowCount; ++i) { - delete[] fStrings[i]; - } - delete[] fStrings; -} - -const UnicodeString& -String2dList::getString(int32_t rowIndex, - int32_t colIndex) -{ return fStrings[rowIndex][colIndex]; } - -UClassID -String2dList::getDynamicClassID() const -{ return getStaticClassID(); } - -UClassID -String2dList::getStaticClassID() -{ return (UClassID)&fgClassID; } - -//----------------------------------------------------------------------------- - -TaggedList::TaggedList() { - UErrorCode status = U_ZERO_ERROR; - hash = new Hashtable(FALSE, status); - hash->setValueDeleter(uhash_deleteUnicodeString); -} - -TaggedList::~TaggedList() { - delete hash; -} - -int32_t TaggedList::count() const { - return hash->count(); -} - -void -TaggedList::put(const UnicodeString& tag, - const UnicodeString& data) { - UErrorCode status = U_ZERO_ERROR; - hash->put(tag, new UnicodeString(data), status); -} - -const UnicodeString* -TaggedList::get(const UnicodeString& tag) const { - return (const UnicodeString*) hash->get(tag); -} - -UBool TaggedList::nextElement(const UnicodeString*& key, - const UnicodeString*& value, - int32_t& pos) const { - const UHashElement *e = hash->nextElement(pos); - if (e != NULL) { - key = (const UnicodeString*) e->key.pointer; - value = (const UnicodeString*) e->value; - return TRUE; - } else { - return FALSE; - } -} - -UClassID -TaggedList::getDynamicClassID() const -{ return getStaticClassID(); } - -UClassID -TaggedList::getStaticClassID() -{ return (UClassID)&fgClassID; } diff --git a/icu4c/source/common/rbdata.h b/icu4c/source/common/rbdata.h deleted file mode 100644 index 5ecd35d3c9c..00000000000 --- a/icu4c/source/common/rbdata.h +++ /dev/null @@ -1,97 +0,0 @@ -/* -****************************************************************************** -* -* Copyright (C) 1998-2001, International Business Machines -* Corporation and others. All Rights Reserved. -* -****************************************************************************** -* -* File rbdata.h -* -* Modification History: -* -* Date Name Description -* 06/11/99 stephen Creation. (Moved here from resbund.cpp) -****************************************************************************** -*/ - -#ifndef RBDATA_H -#define RBDATA_H 1 - -#include "unicode/utypes.h" -#include "hash.h" -#include "unicode/unistr.h" - -/** - * Abstract base class for data stored in resource bundles. These - * objects are kept in hashtables, indexed by strings. We never need - * to copy or clone these objects, since they are created once and - * never deleted. - */ -class ResourceBundleData -{ -public: - virtual ~ResourceBundleData() {} - virtual UClassID getDynamicClassID(void) const = 0; - UErrorCode fCreationStatus; -}; - -/** Concrete data class representing a list of strings. */ -class StringList : public ResourceBundleData -{ -public: - StringList(); - StringList(UnicodeString* adopted, int32_t count); - virtual ~StringList(); - const UnicodeString& operator[](int32_t i) const; - virtual UClassID getDynamicClassID(void) const; - static UClassID getStaticClassID(void); - - static UClassID fgClassID; - int32_t fCount; - UnicodeString *fStrings; -}; - -/** Concrete data class representing a 2-dimensional list of strings. */ -class String2dList : public ResourceBundleData -{ -public: - String2dList(); - String2dList(UnicodeString** adopted, int32_t rowCount, int32_t colCount); - virtual ~String2dList(); - const UnicodeString& getString(int32_t rowIndex, int32_t colIndex); - virtual UClassID getDynamicClassID(void) const; - static UClassID getStaticClassID(void); - - static UClassID fgClassID; - int32_t fRowCount; - int32_t fColCount; - UnicodeString **fStrings; -}; - -/** - * Concrete data class representing a tagged list of strings. This is - * implemented using a hash table. - */ -class TaggedList : public ResourceBundleData -{ - Hashtable *hash; - -public: - TaggedList(); - virtual ~TaggedList(); - - void put(const UnicodeString& tag, const UnicodeString& data); - const UnicodeString* get(const UnicodeString& tag) const; - UBool nextElement(const UnicodeString*& key, - const UnicodeString*& value, - int32_t& pos) const; - int32_t count() const; - - virtual UClassID getDynamicClassID(void) const; - static UClassID getStaticClassID(void); - - static UClassID fgClassID; -}; - -#endif diff --git a/icu4c/source/common/resbund.cpp b/icu4c/source/common/resbund.cpp index b887ae84b79..e9de1c41c16 100644 --- a/icu4c/source/common/resbund.cpp +++ b/icu4c/source/common/resbund.cpp @@ -49,7 +49,6 @@ #include "unicode/utypes.h" #include "unicode/resbund.h" -#include "rbdata.h" #include "uresimp.h" /*----------------------------------------------------------------------------- @@ -166,10 +165,6 @@ */ //----------------------------------------------------------------------------- -const char* ResourceBundle::kDefaultFilename = "root"; - -//----------------------------------------------------------------------------- - ResourceBundle::ResourceBundle( const UnicodeString& path, const Locale& locale, UErrorCode& error) @@ -190,33 +185,6 @@ ResourceBundle::ResourceBundle( const UnicodeString& path, constructForLocale(path, Locale::getDefault(), error); } -/** - * This constructor is used by TableCollation to load a resource - * bundle from a specific file, without trying other files. This is - * used by the TableCollation caching mechanism. This is not a public - * API constructor. - */ -ResourceBundle::ResourceBundle( const UnicodeString& path, - const char *localeName, - UErrorCode& status) - : fRealLocale(localeName) -{ - int32_t patlen = path.length(); - - if(patlen > 0) { - char pathName[128]; - path.extract(0, patlen, pathName, ""); - pathName[patlen] = '\0'; - resource = ures_openNoFallback(pathName, localeName, &status); - } else { - resource = ures_openNoFallback(0, localeName, &status); - } - - if(U_SUCCESS(status)) { - fRealLocale = Locale(localeName); - } -} - ResourceBundle::ResourceBundle(const wchar_t* path, const Locale& locale, UErrorCode& err) diff --git a/icu4c/source/common/unicode/resbund.h b/icu4c/source/common/unicode/resbund.h index c315331c7a9..4ade23bd3fe 100644 --- a/icu4c/source/common/unicode/resbund.h +++ b/icu4c/source/common/unicode/resbund.h @@ -379,22 +379,7 @@ private: UResourceBundle *resource; void constructForLocale(const UnicodeString& path, const Locale& locale, UErrorCode& error); void constructForLocale(const wchar_t* path, const Locale& locale, UErrorCode& error); - - friend class RuleBasedCollator; - - /** - * This constructor is used by Collation to load a resource bundle from a specific - * file, without trying other files. This is used by the Collation caching - * mechanism. - */ - ResourceBundle( const UnicodeString& path, - const char *localeName, - UErrorCode& status); - -private: Locale fRealLocale; - - static const char* kDefaultFilename; }; #endif diff --git a/icu4c/source/common/uresbund.c b/icu4c/source/common/uresbund.c index 9401537777c..eea10ab1210 100644 --- a/icu4c/source/common/uresbund.c +++ b/icu4c/source/common/uresbund.c @@ -395,44 +395,6 @@ static UResourceDataEntry *entryOpen(const char* path, const char* localeID, UEr * Functions to create and destroy resource bundles. */ -/** - * INTERNAL: This function is used to open a resource bundle - * without initializing fallback data. It is exclusively used - * for initing Collation data at this point. - */ -U_CFUNC UResourceBundle* ures_openNoFallback(const char* path, const char* localeID, UErrorCode* status) { - UResourceBundle *r = (UResourceBundle *)uprv_malloc(sizeof(UResourceBundle)); - if(r == NULL) { - *status = U_MEMORY_ALLOCATION_ERROR; - return NULL; - } - - r->fHasFallback = FALSE; - r->fIsTopLevel = TRUE; - ures_setIsStackObject(r, FALSE); - r->fIndex = -1; - r->fData = entryOpen(path, localeID, status); - if(U_FAILURE(*status)) { - uprv_free(r); - return NULL; - } - if(r->fData->fBogus != U_ZERO_ERROR) { - entryClose(r->fData); - uprv_free(r); - *status = U_MISSING_RESOURCE_ERROR; - return NULL; - } - - r->fKey = NULL; - r->fVersion = NULL; - r->fResData.data = r->fData->fData.data; - r->fResData.pRoot = r->fData->fData.pRoot; - r->fResData.rootRes = r->fData->fData.rootRes; - r->fRes = r->fResData.rootRes; - r->fSize = res_countArrayItems(&(r->fResData), r->fRes); - return r; -} - /* INTERNAL: */ static UResourceBundle *init_resb_result(const ResourceData *rdata, const Resource r, const char *key, UResourceDataEntry *realData, UResourceBundle *resB, UErrorCode *status) { if(status == NULL || U_FAILURE(*status)) { diff --git a/icu4c/source/common/uresimp.h b/icu4c/source/common/uresimp.h index 256a46efda3..be39a189975 100644 --- a/icu4c/source/common/uresimp.h +++ b/icu4c/source/common/uresimp.h @@ -73,7 +73,6 @@ struct UResourceBundle { Resource fRes; }; -U_CFUNC UResourceBundle* ures_openNoFallback(const char* path, const char* localeID, UErrorCode* status); U_CFUNC const char* ures_getRealLocale(const UResourceBundle* resourceBundle, UErrorCode* status); U_CAPI void ures_setIsStackObject( UResourceBundle* resB, UBool state); U_CAPI UBool ures_isStackObject( UResourceBundle* resB, UErrorCode *status); diff --git a/icu4c/source/i18n/tblcoll.cpp b/icu4c/source/i18n/tblcoll.cpp index 02020f90acc..0df41750850 100644 --- a/icu4c/source/i18n/tblcoll.cpp +++ b/icu4c/source/i18n/tblcoll.cpp @@ -55,6 +55,7 @@ */ #include "ucol_imp.h" +#include "uresimp.h" #include "unicode/tblcoll.h" #include "unicode/coleitr.h" #include "uhash.h" @@ -724,7 +725,8 @@ RuleBasedCollator::RuleBasedCollator(const Locale& desiredLocale, { status = U_ZERO_ERROR; - setUCollator(ResourceBundle::kDefaultFilename, status); + // TODO: + setUCollator(kRootLocaleName, status); if (U_FAILURE(status)) { status = U_ZERO_ERROR; diff --git a/icu4c/source/test/intltest/restsnew.cpp b/icu4c/source/test/intltest/restsnew.cpp index 346207b2737..64519e21ff4 100644 --- a/icu4c/source/test/intltest/restsnew.cpp +++ b/icu4c/source/test/intltest/restsnew.cpp @@ -490,6 +490,24 @@ NewResourceBundleTest::TestOtherAPI(){ errln("copy construction failed\n"); } + ResourceBundle defaultSub = defaultresource.get(1, err); + ResourceBundle defSubCopy(defaultSub); + if(strcmp(defSubCopy.getName(), defaultSub.getName() ) !=0 || + strcmp(defSubCopy.getLocale().getName(), defaultSub.getLocale().getName() ) !=0 ){ + errln("copy construction for subresource failed\n"); + } + + + + UVersionInfo ver; + copyRes.getVersion(ver); + + logln("Version returned: [%d.%d.%d.%d]\n", ver[0], ver[1], ver[2], ver[3]); + + + + + } @@ -803,6 +821,19 @@ NewResourceBundleTest::testTag(const char* frag, } } + + for(index=0; index