ResultSet Class Reference

#include <ResultSet.h>

Inheritance diagram for ResultSet:

UtlSList UtlList UtlContainer UtlChain UtlContainable

List of all members.


Detailed Description

A set of rows from a conceptual table; each row is name/value pairs.

A ResultSet is a list of hash tables, used primarily in the interfaces to the sipdb in-memory databases.

Care should be taken in managing memory - all objects inserted in the set must be dynamically allocated (using new) and should be considered owned by the set; see addValue.

Public Member Functions

 ResultSet ()
 Construct a container for rows.
virtual ~ResultSet ()
 Destroy a set - implicitly destroys all contents.
int getSize () const
 Get the number of rows in the set.
OsStatus getIndex (const int &index, UtlHashMap &rRecord) const
 Retrieve the Nth row in a set.
void addValue (const UtlHashMap &record)
 Add a row to the set.
void clear ()
void destroyAll ()
 Deletes all objects in the set.

Private Member Functions

 ResultSet (const ResultSet &rhs)
 No copy constructor.
ResultSet operator= (const ResultSet &rhs)
 No assignment operator.


Constructor & Destructor Documentation

ResultSet (  ) 

Construct a container for rows.

~ResultSet (  )  [virtual]

Destroy a set - implicitly destroys all contents.

ResultSet ( const ResultSet rhs  )  [private]

No copy constructor.


Member Function Documentation

int getSize (  )  const

Get the number of rows in the set.

OsStatus getIndex ( const int &  index,
UtlHashMap rRecord 
) const

Retrieve the Nth row in a set.

This makes a shallow copy, so the elements in the returned rRecord must not be deleted (the values are still owned by the ResultSet).

Parameters:
index  the row to return.
rRecord  the returned row (must be empty when passed)

void addValue ( const UtlHashMap record  ) 

Add a row to the set.

This makes a shallow copy, so the elements in the record must not be deleted (consider them owned by the ResultSet following the copy).

 ResultSet registrations;
 UtlHashMap regRow;

 UtlString* uriKey = new UtlString("uri");
 UtlString* uriValue = new UtlString(regdata[row].uri);
 regRow.insertKeyAndValue(uriKey, uriValue);

 UtlString* callidKey = new UtlString("callid");
 UtlString* callidValue = new UtlString(regdata[row].callid);
 regRow.insertKeyAndValue(callidKey, callidValue);

 UtlString* contactKey = new UtlString("contact");
 UtlString* contactValue = new UtlString(regdata[row].contact);
 regRow.insertKeyAndValue(contactKey, contactValue);

 registrations.addValue(regRow);
Note that the UtlHashMap record object is not dynamic; a new UtlHashMap is created in and owned by the set, but the objects contained in record are not copied, so they are now owned by the set.

void clear (  ) 

Note:
Do not create any additional use. This was originally defined to remove all entries. It was probably a memory leak if there was anything in the set. This is now used in only a few places where the set should already be empty, and has been redefined to be just a check for emptiness.

void destroyAll (  )  [virtual]

Deletes all objects in the set.

Reimplemented from UtlList.

ResultSet operator= ( const ResultSet rhs  )  [private]

No assignment operator.


Online Library Docs

sipXecs home page

Version 4.2.1-018930 2010-07-31T01:13:23 build16 abuild