scuffed-code/icu4c/source/common/rbdata.cpp

128 lines
3.1 KiB
C++
Raw Normal View History

1999-08-16 21:50:52 +00:00
/*
**********************************************************************
* Copyright (C) 1998-1999, International Business Machines
* Corporation and others. All Rights Reserved.
**********************************************************************
1999-08-16 21:50:52 +00:00
*
* 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
1999-08-16 21:50:52 +00:00
//-----------------------------------------------------------------------------
StringList::StringList()
: fStrings(0), fCount(0)
{}
StringList::StringList(UnicodeString *adopted,
int32_t count)
: fStrings(adopted), fCount(count)
{}
StringList::~StringList()
{ delete [] fStrings; }
const UnicodeString&
StringList::operator[](int32_t i) const
{ return fStrings[i]; }
UClassID
1999-08-16 21:50:52 +00:00
StringList::getDynamicClassID() const
{ return getStaticClassID(); }
UClassID
1999-08-16 21:50:52 +00:00
StringList::getStaticClassID()
{ return (UClassID)&fgClassID; }
1999-08-16 21:50:52 +00:00
//-----------------------------------------------------------------------------
String2dList::String2dList()
: fStrings(0), fRowCount(0), fColCount(0)
{}
String2dList::String2dList(UnicodeString **adopted,
int32_t rowCount,
int32_t colCount)
: fStrings(adopted), fRowCount(rowCount), fColCount(colCount)
{}
String2dList::~String2dList()
{
for(int32_t i = 0; i < fRowCount; ++i) {
delete[] fStrings[i];
}
}
const UnicodeString&
String2dList::getString(int32_t rowIndex,
int32_t colIndex)
{ return fStrings[rowIndex][colIndex]; }
UClassID
1999-08-16 21:50:52 +00:00
String2dList::getDynamicClassID() const
{ return getStaticClassID(); }
UClassID
1999-08-16 21:50:52 +00:00
String2dList::getStaticClassID()
{ return (UClassID)&fgClassID; }
1999-08-16 21:50:52 +00:00
//-----------------------------------------------------------------------------
TaggedList::TaggedList() {
UErrorCode status = U_ZERO_ERROR;
hash = new Hashtable(status);
hash->setValueDeleter(uhash_deleteUnicodeString);
1999-08-16 21:50:52 +00:00
}
TaggedList::~TaggedList() {
delete hash;
}
int32_t TaggedList::count() const {
return hash->count();
1999-08-16 21:50:52 +00:00
}
void
TaggedList::put(const UnicodeString& tag,
const UnicodeString& data) {
UErrorCode status = U_ZERO_ERROR;
hash->put(tag, new UnicodeString(data), status);
1999-08-16 21:50:52 +00:00
}
const UnicodeString*
TaggedList::get(const UnicodeString& tag) const {
return (const UnicodeString*) hash->get(tag);
1999-08-16 21:50:52 +00:00
}
bool_t 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;
value = (const UnicodeString*) e->value;
return TRUE;
} else {
return FALSE;
}
1999-08-16 21:50:52 +00:00
}
UClassID
1999-08-16 21:50:52 +00:00
TaggedList::getDynamicClassID() const
{ return getStaticClassID(); }
UClassID
1999-08-16 21:50:52 +00:00
TaggedList::getStaticClassID()
{ return (UClassID)&fgClassID; }