Back to index

lightning-sunbird  0.9+nobinonly
Classes | Public Member Functions | Public Attributes | Protected Types | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Static Protected Attributes
nsCommandParams Class Reference

#include <nsCommandParams.h>

Inheritance diagram for nsCommandParams:
Inheritance graph
[legend]
Collaboration diagram for nsCommandParams:
Collaboration graph
[legend]

List of all members.

Classes

struct  HashEntry
union  HashEntry.mData

Public Member Functions

 nsCommandParams ()
virtual ~nsCommandParams ()
NS_DECL_ISUPPORTS
NS_DECL_NSICOMMANDPARAMS
nsresult 
Init ()
short getValueType (in string name)
boolean getBooleanValue (in string name)
long getLongValue (in string name)
double getDoubleValue (in string name)
AString getStringValue (in string name)
string getCStringValue (in string name)
nsISupports getISupportsValue (in string name)
void setBooleanValue (in string name, in boolean value)
void setLongValue (in string name, in long value)
void setDoubleValue (in string name, in double value)
void setStringValue (in string name, in AString value)
void setCStringValue (in string name, in string value)
void setISupportsValue (in string name, in nsISupports value)
void removeValue (in string name)
boolean hasMoreElements ()
void first ()
string getNext ()
 GetNext()

Public Attributes

const short eNoType = 0
const short eBooleanType = 1
const short eLongType = 2
const short eDoubleType = 3
const short eWStringType = 4
const short eISupportsType = 5
const short eStringType = 6

Protected Types

enum  { eNumEntriesUnknown = -1 }

Protected Member Functions

HashEntryGetNamedEntry (const char *name)
HashEntryGetIndexedEntry (PRInt32 index)
PRUint32 GetNumEntries ()
nsresult GetOrMakeEntry (const char *name, PRUint8 entryType, HashEntry *&outEntry)

Static Protected Member Functions

static const void *PR_CALLBACK HashGetKey (PLDHashTable *table, PLDHashEntryHdr *entry)
static PLDHashNumber PR_CALLBACK HashKey (PLDHashTable *table, const void *key)
static PRBool PR_CALLBACK HashMatchEntry (PLDHashTable *table, const PLDHashEntryHdr *entry, const void *key)
static void PR_CALLBACK HashMoveEntry (PLDHashTable *table, const PLDHashEntryHdr *from, PLDHashEntryHdr *to)
static void PR_CALLBACK HashClearEntry (PLDHashTable *table, PLDHashEntryHdr *entry)

Protected Attributes

PLDHashTable mValuesHash
PRInt32 mCurEntry
PRInt32 mNumEntries

Static Protected Attributes

static PLDHashTableOps sHashOps

Detailed Description

Definition at line 53 of file nsCommandParams.h.


Class Documentation

union nsCommandParams::HashEntry.mData

Definition at line 73 of file nsCommandParams.h.

Class Members
PRBool mBoolean
nsCString * mCString
double mDouble
PRInt32 mLong
nsString * mString

Member Enumeration Documentation

anonymous enum [protected]
Enumerator:
eNumEntriesUnknown 

Definition at line 169 of file nsCommandParams.h.

       {
    eNumEntriesUnknown      = -1
  };

Constructor & Destructor Documentation

Definition at line 61 of file nsCommandParams.cpp.

: mCurEntry(0)
, mNumEntries(eNumEntriesUnknown)
{
  // init the hash table later
}

Definition at line 68 of file nsCommandParams.cpp.

Here is the call graph for this function:


Member Function Documentation

void nsICommandParams::first ( ) [inherited]
double nsICommandParams::getDoubleValue ( in string  name) [inherited]

Definition at line 295 of file nsCommandParams.cpp.

{
  HashEntry*  entry = NS_REINTERPRET_CAST(HashEntry*, mValuesHash.entryStore);
  HashEntry*  limit = entry + PL_DHASH_TABLE_SIZE(&mValuesHash);
  PRUint32    entryCount = 0;
  
  do
  {  
    if (!PL_DHASH_ENTRY_IS_LIVE(entry))
      continue;

    if ((PRInt32)entryCount == index)
      return entry;
    
    entryCount ++;
  } while (++entry < limit);

  return nsnull;
}
nsISupports nsICommandParams::getISupportsValue ( in string  name) [inherited]

Definition at line 283 of file nsCommandParams.cpp.

{
  HashEntry *foundEntry = (HashEntry *)PL_DHashTableOperate(&mValuesHash, (void *)name, PL_DHASH_LOOKUP);

  if (PL_DHASH_ENTRY_IS_BUSY(foundEntry))
    return foundEntry;
   
  return nsnull;
}

Here is the call graph for this function:

GetNext()

Returns:
string pointer that will be allocated and is up to the caller to free

Definition at line 317 of file nsCommandParams.cpp.

{
  HashEntry*  entry = NS_REINTERPRET_CAST(HashEntry*, mValuesHash.entryStore);
  HashEntry*  limit = entry + PL_DHASH_TABLE_SIZE(&mValuesHash);
  PRUint32    entryCount = 0;
  
  do
  {  
    if (PL_DHASH_ENTRY_IS_LIVE(entry))
      entryCount ++;
  } while (++entry < limit);

  return entryCount;
}
nsresult nsCommandParams::GetOrMakeEntry ( const char *  name,
PRUint8  entryType,
HashEntry *&  outEntry 
) [protected]

Definition at line 333 of file nsCommandParams.cpp.

{

  HashEntry *foundEntry = (HashEntry *)PL_DHashTableOperate(&mValuesHash, (void *)name, PL_DHASH_LOOKUP);
  if (PL_DHASH_ENTRY_IS_BUSY(foundEntry))   // reuse existing entry  
  {
    foundEntry->Reset(entryType);
    foundEntry->mEntryName.Assign(name);
    outEntry = foundEntry;
    return NS_OK;
  }

  foundEntry = (HashEntry *)PL_DHashTableOperate(&mValuesHash, (void *)name, PL_DHASH_ADD);
  if (!foundEntry) return NS_ERROR_OUT_OF_MEMORY;
  
  // placement new that sucker. Our ctor does not clobber keyHash, which is important.
  outEntry = new (foundEntry) HashEntry(entryType, name);  
  return NS_OK;
}

Here is the call graph for this function:

AString nsICommandParams::getStringValue ( in string  name) [inherited]
short nsICommandParams::getValueType ( in string  name) [inherited]
void nsCommandParams::HashClearEntry ( PLDHashTable table,
PLDHashEntryHdr entry 
) [static, protected]

Definition at line 393 of file nsCommandParams.cpp.

{
  HashEntry*    thisEntry = NS_STATIC_CAST(HashEntry*, entry);
  thisEntry->~HashEntry();      // call dtor explicitly
  memset(thisEntry, 0, sizeof(HashEntry));    // and clear out
}

Here is the call graph for this function:

const void * nsCommandParams::HashGetKey ( PLDHashTable table,
PLDHashEntryHdr entry 
) [static, protected]

Definition at line 358 of file nsCommandParams.cpp.

{
  HashEntry*    thisEntry = NS_STATIC_CAST(HashEntry*, entry);
  return (void *)thisEntry->mEntryName.get();
}

Here is the call graph for this function:

PLDHashNumber nsCommandParams::HashKey ( PLDHashTable table,
const void key 
) [static, protected]

Definition at line 366 of file nsCommandParams.cpp.

{
  return nsCRT::HashCode((const char *)key);
}
PRBool nsCommandParams::HashMatchEntry ( PLDHashTable table,
const PLDHashEntryHdr entry,
const void key 
) [static, protected]

Definition at line 372 of file nsCommandParams.cpp.

{
  const char*   keyString = (const char*)key;
  const HashEntry*   thisEntry = NS_STATIC_CAST(const HashEntry*, entry);
  
  return thisEntry->mEntryName.Equals(keyString);
}
void nsCommandParams::HashMoveEntry ( PLDHashTable table,
const PLDHashEntryHdr from,
PLDHashEntryHdr to 
) [static, protected]

Definition at line 382 of file nsCommandParams.cpp.

{
  const HashEntry*   fromEntry  = NS_STATIC_CAST(const HashEntry*, from);
  HashEntry*         toEntry    = NS_STATIC_CAST(HashEntry*, to);
  
  *toEntry = *fromEntry;
  // we leave from dirty, but that's OK
}

Definition at line 74 of file nsCommandParams.cpp.

{
  if (!PL_DHashTableInit(&mValuesHash, &sHashOps, (void *)this, sizeof(HashEntry), 4))
    return NS_ERROR_FAILURE;
    
  return NS_OK;
}

Here is the call graph for this function:

void nsICommandParams::setBooleanValue ( in string  name,
in boolean  value 
) [inherited]
void nsICommandParams::setCStringValue ( in string  name,
in string  value 
) [inherited]
void nsICommandParams::setDoubleValue ( in string  name,
in double  value 
) [inherited]
void nsICommandParams::setISupportsValue ( in string  name,
in nsISupports  value 
) [inherited]
void nsICommandParams::setLongValue ( in string  name,
in long  value 
) [inherited]
void nsICommandParams::setStringValue ( in string  name,
in AString  value 
) [inherited]

Member Data Documentation

const short nsICommandParams::eBooleanType = 1 [inherited]

Definition at line 55 of file nsICommandParams.idl.

const short nsICommandParams::eDoubleType = 3 [inherited]

Definition at line 57 of file nsICommandParams.idl.

const short nsICommandParams::eISupportsType = 5 [inherited]

Definition at line 59 of file nsICommandParams.idl.

const short nsICommandParams::eLongType = 2 [inherited]

Definition at line 56 of file nsICommandParams.idl.

const short nsICommandParams::eNoType = 0 [inherited]

Definition at line 54 of file nsICommandParams.idl.

const short nsICommandParams::eStringType = 6 [inherited]

Definition at line 60 of file nsICommandParams.idl.

const short nsICommandParams::eWStringType = 4 [inherited]

Definition at line 58 of file nsICommandParams.idl.

Definition at line 181 of file nsCommandParams.h.

Definition at line 182 of file nsCommandParams.h.

Definition at line 178 of file nsCommandParams.h.


The documentation for this class was generated from the following files: