Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Private Attributes | Static Private Attributes
XPCDispNameArray Class Reference

This class holds an array of names. More...

#include <XPCDispPrivate.h>

Collaboration diagram for XPCDispNameArray:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 XPCDispNameArray ()
 Intializes the array to zero elements.
 ~XPCDispNameArray ()
 Cleans up the mNames array.
void SetSize (PRUint32 size)
 Sets the size of the array.
PRUint32 GetSize () const
 Returns the current size of the array.
void SetName (DISPID dispid, nsAString const &name)
 Assigns a name/string to a given element.
const nsAString & GetName (DISPID dispid) const
 Retrieves a name/string for a dispid.
DISPID Find (const nsAString &target) const
 Performs a search of the array for the target returning the the id for the name.

Private Attributes

PRUint32 mCount
nsStringmNames

Static Private Attributes

static const nsString sEmpty
 This is used by Find when it doesn't find something.

Detailed Description

This class holds an array of names.

This is only used in wrapped JS objects, so the dispid's are not arbitrary. They begin with 1 and so dispid - 1 is the index into the array mNames

Definition at line 237 of file XPCDispPrivate.h.


Constructor & Destructor Documentation

Intializes the array to zero elements.

Definition at line 381 of file XPCDispInlines.h.

                                   : mCount(0), mNames(0) 
{
}

Cleans up the mNames array.

Definition at line 386 of file XPCDispInlines.h.

{ 
    delete [] mNames;
}

Member Function Documentation

DISPID XPCDispNameArray::Find ( const nsAString &  target) const [inline]

Performs a search of the array for the target returning the the id for the name.

Parameters:
targetthe name to find

Definition at line 422 of file XPCDispInlines.h.

{
    for(PRUint32 index = 0; index < mCount; ++index) 
    {
        if(mNames[index].Equals(target)) 
            return NS_STATIC_CAST(DISPID, index + 1);
    }
    return 0; 
}

Here is the call graph for this function:

Here is the caller graph for this function:

const nsAString & XPCDispNameArray::GetName ( DISPID  dispid) const [inline]

Retrieves a name/string for a dispid.

This function performs bounds checking in debug builds

Parameters:
dispiddispatch ID of the name to retrieve

Definition at line 413 of file XPCDispInlines.h.

{
    NS_ASSERTION(dispid <= (PRInt32)mCount, "Array bounds error in XPCDispNameArray::Get");
    if(dispid > 0)
        return mNames[dispid - 1];
    return sEmpty;
}

Here is the caller graph for this function:

PRUint32 XPCDispNameArray::GetSize ( ) const [inline]

Returns the current size of the array.

Returns:
the current size of the array

Definition at line 400 of file XPCDispInlines.h.

{
    return mCount;
}
void XPCDispNameArray::SetName ( DISPID  dispid,
nsAString const name 
) [inline]

Assigns a name/string to a given element.

This function will not expand the array and performs bounds checking in debug builds.

Parameters:
dispidIDispatch id for the name
namethe name to assign

Definition at line 406 of file XPCDispInlines.h.

{
    NS_ASSERTION(dispid <= (PRInt32)mCount, "Array bounds error in XPCDispNameArray::SetName");
    mNames[dispid - 1] = name;
}

Here is the caller graph for this function:

Sets the size of the array.

Parameters:
sizethe new size of the array

Definition at line 392 of file XPCDispInlines.h.

{
    NS_ASSERTION(mCount == 0, "SetSize called more than once");
    mCount = size;
    mNames = (size ? new nsString[size] : 0);
}

Here is the caller graph for this function:


Member Data Documentation

Definition at line 283 of file XPCDispPrivate.h.

Definition at line 284 of file XPCDispPrivate.h.

This is used by Find when it doesn't find something.

See also:
XPCDispNameArray::Find

Definition at line 282 of file XPCDispPrivate.h.


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