This commit is contained in:
sman%netscape.com 1998-09-11 18:23:31 +00:00
Родитель a511360848
Коммит 99dd5a7339
2 изменённых файлов: 50 добавлений и 2 удалений

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

@ -94,7 +94,7 @@ private:
nsresult DestroyEntry(PRInt32 aIndex);
/**
* @return the current number of keys and values.
* @return the current number of key/value pairs.
*/
PRInt32 GetLength() { return miLength; }
@ -104,8 +104,26 @@ public:
nsX400Parser(const JulianString& sVal);
virtual ~nsX400Parser();
/**
* Supply a new value for the parser. It should be of the form:
* /S=Steve/G=Mansour/Nd=10000/
* After this call, the values associated with keys can be accessed
* or modified. New key/value pairs can be added. Existing key/value
* pairs can be deleted.
* @param aKey the key
* @return NS_OK on success.
*/
nsresult SetValue(const char* psVal);
/**
* Get the newly assembled string
* @param aStr pointer to the character string. It refers
* back to the internal string maintained by this
* object. Do not modify this string.
* @return NS_OK on success
*/
nsresult GetValue(char** aStr);
/**
* Set the supplied key to have the supplied value. Add the key
* and value pair if they do not yet exist. Update the value
@ -116,8 +134,20 @@ public:
*/
nsresult Set(const char* aKey, const char* aVal);
nsresult Get(const char* psKey, char **ppsVal );
/**
* Retrieve the value associated with the supplied key.
* @param aKey the key
* @param aValue the returned value associated with the key.
* *aValue will be 0 if the key was not found
* @return NS_OK on success.
*/
nsresult Get(const char* aKey, char **aVal );
/**
* Delete the key and value for the supplied key.
* @param aKey the key
* @return NS_OK on success.
*/
nsresult Delete(const char* psKey);
};

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

@ -47,6 +47,7 @@
nsX400Parser::nsX400Parser()
{
Init();
msValue = "";
}
nsX400Parser::nsX400Parser(const JulianString& sValue)
@ -84,6 +85,13 @@ nsresult nsX400Parser::Init()
return NS_OK;
}
nsresult nsX400Parser::GetValue(char** aStr)
{
Assemble();
*aStr = msValue.GetBuffer();
return NS_OK;
}
nsresult nsX400Parser::EnsureSize(PRInt32 aSize)
{
if (aSize > miSize)
@ -210,6 +218,11 @@ nsresult nsX400Parser::Get(const char* aKey, char **ppsVal )
}
/**
* Destroy the strings associated with the entry at the supplied index.
* @param aIndex the index where we want to delete the entry
* @return NS_OK on success
*/
nsresult nsX400Parser::DestroyEntry(PRInt32 i)
{
if (0 != mppKeys[i])
@ -324,6 +337,11 @@ nsresult nsX400Parser::Parse()
return NS_OK;
}
/**
* Assembles a new internal value string based on the contents of
* the keys and vals arrays.
* @return NS_OK on success.
*/
nsresult nsX400Parser::Assemble()
{
msValue = "/";