ICU-96 support for collation data

X-SVN-Rev: 2897
This commit is contained in:
Vladimir Weinstein 2000-11-09 21:58:19 +00:00
parent 6bae01e8bc
commit 9398f17d9d
4 changed files with 13 additions and 14 deletions

View File

@ -85,7 +85,7 @@ class RuleBasedCollatorStreamer
public:
static void streamIn(RuleBasedCollator* collator, FileStream* is);
static void streamOut(const RuleBasedCollator* collator, FileStream* os);
static void streamIn(RuleBasedCollator* collator, UMemoryStream* is);
static void streamIn(RuleBasedCollator* collator, UMemoryStream* is, UErrorCode& status);
static void streamOut(const RuleBasedCollator* collator, UMemoryStream* os);
};
@ -807,7 +807,7 @@ RuleBasedCollator::constructFromBundle(const Locale & name,
}
// The streamIn function does the actual work here...
RuleBasedCollatorStreamer::streamIn(this, ifs);
RuleBasedCollatorStreamer::streamIn(this, ifs, status);
if (!uprv_mstrm_error(ifs)) {
}
@ -2492,10 +2492,9 @@ VectorOfInt *RuleBasedCollator::getExpandValueList(int32_t order) const
void RuleBasedCollatorStreamer::streamIn(RuleBasedCollator* collator, UMemoryStream* is)
void RuleBasedCollatorStreamer::streamIn(RuleBasedCollator* collator, UMemoryStream* is, UErrorCode& status)
{
if (!uprv_mstrm_error(is))
{
if (!uprv_mstrm_error(is) && U_SUCCESS(status)) {
// Check that this is the correct file type
int16_t id;
@ -2516,6 +2515,7 @@ void RuleBasedCollatorStreamer::streamIn(RuleBasedCollator* collator, UMemoryStr
{
delete collator->data;
collator->data = NULL;
status = U_MISSING_RESOURCE_ERROR;
}
else
{
@ -2524,9 +2524,10 @@ void RuleBasedCollatorStreamer::streamIn(RuleBasedCollator* collator, UMemoryStr
collator->data = new TableCollationData;
}
collator->data->streamIn(is);
collator->data->streamIn(is, status);
if (collator->data->isBogus()) {
uprv_mstrm_setError(is); // force the stream to set its error flag
status = U_MISSING_RESOURCE_ERROR;
return;
}
}
@ -2538,6 +2539,7 @@ void RuleBasedCollatorStreamer::streamIn(RuleBasedCollator* collator, UMemoryStr
// This isn't the right type of file. Mark the ios
// as failing and return.
uprv_mstrm_setError(is); // force the stream to set its error flag
status = U_MISSING_RESOURCE_ERROR;
return;
}

View File

@ -75,7 +75,7 @@ void TableCollationData::streamIn(FileStream* is)
// Slight ugliness: We are a friend of TableCollation solely so
// we can access the constant UNMAPPED here. In fact, this code
// path shouldn't really happen, because mapping should always != 0.
if (mapping == 0) mapping = ucmp32_open(RuleBasedCollator::UNMAPPED);
// if (mapping == 0) mapping = ucmp32_open(RuleBasedCollator::UNMAPPED);
if (mapping->fBogus ){
fBogus = TRUE;
return;
@ -179,9 +179,9 @@ void TableCollationData::streamOut(FileStream* os) const
}
}
void TableCollationData::streamIn(UMemoryStream* is)
void TableCollationData::streamIn(UMemoryStream* is, UErrorCode &status)
{
if (!uprv_mstrm_error(is))
if (!uprv_mstrm_error(is) && U_SUCCESS(status))
{
// Stream in large objects
char isNull;
@ -203,7 +203,6 @@ void TableCollationData::streamIn(UMemoryStream* is)
}
int32_t len = 0;
const uint8_t *map = uprv_mstrm_getCurrentBuffer(is, &len);
UErrorCode status = U_ZERO_ERROR;
ucmp32_initFromData(mapping, &map, &status);
uprv_mstrm_jump(is, map);
// ucmp32_streamMemIn(mapping, is);
@ -211,6 +210,7 @@ void TableCollationData::streamIn(UMemoryStream* is)
fBogus = TRUE;
ucmp32_close(mapping);
mapping = 0;
status = U_MISSING_RESOURCE_ERROR;
return;
}
}

View File

@ -100,7 +100,7 @@ public:
/**
* For internal use only - streaming to memory
*/
void streamIn(UMemoryStream* is);
void streamIn(UMemoryStream* is, UErrorCode& status);
void streamOut(UMemoryStream* os) const;
/**

View File

@ -589,9 +589,6 @@ private:
// Collator ONLY needs access to RuleBasedCollator(const Locale&, UErrorCode&)
friend class Collator;
// TableCollationData ONLY needs access to UNMAPPED
friend class TableCollationData;
// This is just temporary, for prototyping.
friend int32_t ucol_getNextCE(const UCollator *coll, collIterate *source, UErrorCode *status);
friend int32_t ucol_getSortKey(const UCollator *coll, const UChar *source,