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

129 lines
3.2 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()
: fCount(0), fStrings(0)
1999-08-16 21:50:52 +00:00
{}
StringList::StringList(UnicodeString *adopted,
int32_t count)
: fCount(count), fStrings(adopted)
1999-08-16 21:50:52 +00:00
{}
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()
: fRowCount(0), fColCount(0), fStrings(0)
1999-08-16 21:50:52 +00:00
{}
String2dList::String2dList(UnicodeString **adopted,
int32_t rowCount,
int32_t colCount)
: fRowCount(rowCount), fColCount(colCount), fStrings(adopted)
1999-08-16 21:50:52 +00:00
{}
String2dList::~String2dList()
{
for(int32_t i = 0; i < fRowCount; ++i) {
delete[] fStrings[i];
}
2000-06-26 22:46:15 +00:00
delete[] fStrings;
1999-08-16 21:50:52 +00:00
}
const UnicodeString&
String2dList::getString(int32_t rowIndex,
int32_t colIndex)
1999-08-16 21:50:52 +00:00
{ 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
}
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;
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; }