This commit is contained in:
sman%netscape.com 1998-09-11 23:44:36 +00:00
Родитель 0f218db562
Коммит 1af7f64344
2 изменённых файлов: 40 добавлений и 7 удалений

Просмотреть файл

@ -95,6 +95,12 @@ private:
*/ */
nsresult DestroyEntry(PRInt32 aIndex); nsresult DestroyEntry(PRInt32 aIndex);
/**
* Destroy all key/value pairs
* @return NS_OK on success
*/
nsresult DestroyAllEntries();
/** /**
* @return the current number of key/value pairs. * @return the current number of key/value pairs.
*/ */
@ -126,6 +132,13 @@ public:
*/ */
nsresult GetValue(char** aStr); nsresult GetValue(char** aStr);
/**
* Get the newly assembled string
* @param aStr reference to the string object.
* @return NS_OK on success
*/
nsresult GetValue(JulianString& aStr);
/** /**
* Set the supplied key to have the supplied value. Add the key * Set the supplied key to have the supplied value. Add the key
* and value pair if they do not yet exist. Update the value * and value pair if they do not yet exist. Update the value

Просмотреть файл

@ -64,10 +64,14 @@ nsX400Parser::nsX400Parser(const char* psValue)
nsX400Parser::~nsX400Parser() nsX400Parser::~nsX400Parser()
{ {
DestroyAllEntries();
if (mppKeys)
{
delete [] mppKeys;
}
if (mppVals) if (mppVals)
delete [] mppVals; delete [] mppVals;
if (mppKeys)
delete [] mppKeys;
} }
nsresult nsX400Parser::Init() nsresult nsX400Parser::Init()
@ -92,6 +96,13 @@ nsresult nsX400Parser::GetValue(char** aStr)
return NS_OK; return NS_OK;
} }
nsresult nsX400Parser::GetValue(JulianString& aStr)
{
Assemble();
aStr = msValue;
return NS_OK;
}
nsresult nsX400Parser::EnsureSize(PRInt32 aSize) nsresult nsX400Parser::EnsureSize(PRInt32 aSize)
{ {
if (aSize > miSize) if (aSize > miSize)
@ -239,6 +250,19 @@ nsresult nsX400Parser::DestroyEntry(PRInt32 i)
return NS_OK; return NS_OK;
} }
nsresult nsX400Parser::DestroyAllEntries()
{
/*
* delete anything in the old arrays...
*/
if (0 != mppKeys && 0 != mppVals)
{
for (size_t i = 0; i < (size_t)miLength; i++)
DestroyEntry((PRInt32)i);
}
return NS_OK;
}
/** /**
* Delete an entry. * Delete an entry.
*/ */
@ -302,11 +326,7 @@ nsresult nsX400Parser::Parse()
/* /*
* delete anything in the old arrays... * delete anything in the old arrays...
*/ */
if (0 != mppKeys) DestroyAllEntries();
{
for (i = 0; i < (size_t)miLength; i++)
DestroyEntry((PRInt32)i);
}
/* /*
* Parse off parts until done... * Parse off parts until done...