Back to index

lightning-sunbird  0.9+nobinonly
Classes | Public Member Functions | Protected Attributes
nsResourceSet Class Reference

#include <nsResourceSet.h>

Collaboration diagram for nsResourceSet:
Collaboration graph
[legend]

List of all members.

Classes

class  ConstIterator

Public Member Functions

 nsResourceSet ()
 nsResourceSet (const nsResourceSet &aResourceSet)
nsResourceSetoperator= (const nsResourceSet &aResourceSet)
 ~nsResourceSet ()
nsresult Clear ()
nsresult Add (nsIRDFResource *aProperty)
void Remove (nsIRDFResource *aProperty)
PRBool Contains (nsIRDFResource *aProperty) const
ConstIterator First () const
ConstIterator Last () const

Protected Attributes

nsIRDFResource ** mResources
PRInt32 mCount
PRInt32 mCapacity

Detailed Description

Definition at line 43 of file nsResourceSet.h.


Constructor & Destructor Documentation

Definition at line 46 of file nsResourceSet.h.

Definition at line 41 of file nsResourceSet.cpp.

    : mResources(nsnull),
      mCount(0),
      mCapacity(0)
{
    ConstIterator last = aResourceSet.Last();
    for (ConstIterator resource = aResourceSet.First(); resource != last; ++resource)
        Add(*resource);
}

Here is the call graph for this function:

Definition at line 62 of file nsResourceSet.cpp.

Here is the call graph for this function:


Member Function Documentation

Definition at line 80 of file nsResourceSet.cpp.

{
    NS_PRECONDITION(aResource != nsnull, "null ptr");
    if (! aResource)
        return NS_ERROR_NULL_POINTER;

    if (Contains(aResource))
        return NS_OK;

    if (mCount >= mCapacity) {
        PRInt32 capacity = mCapacity + 4;
        nsIRDFResource** resources = new nsIRDFResource*[capacity];
        if (! resources)
            return NS_ERROR_OUT_OF_MEMORY;

        for (PRInt32 i = mCount - 1; i >= 0; --i)
            resources[i] = mResources[i];

        delete[] mResources;

        mResources = resources;
        mCapacity = capacity;
    }

    mResources[mCount++] = aResource;
    NS_ADDREF(aResource);
    return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 70 of file nsResourceSet.cpp.

{
    while (--mCount >= 0) {
        NS_RELEASE(mResources[mCount]);
    }
    mCount = 0;
    return NS_OK;
}

Here is the caller graph for this function:

Definition at line 132 of file nsResourceSet.cpp.

{
    for (PRInt32 i = mCount - 1; i >= 0; --i) {
        if (mResources[i] == aResource)
            return PR_TRUE;
    }

    return PR_FALSE;
}

Here is the caller graph for this function:

ConstIterator nsResourceSet::First ( ) const [inline]

Definition at line 110 of file nsResourceSet.h.

{ return ConstIterator(mResources); }

Here is the caller graph for this function:

ConstIterator nsResourceSet::Last ( ) const [inline]

Definition at line 111 of file nsResourceSet.h.

{ return ConstIterator(mResources + mCount); }

Here is the caller graph for this function:

nsResourceSet & nsResourceSet::operator= ( const nsResourceSet aResourceSet)

Definition at line 53 of file nsResourceSet.cpp.

{
    Clear();
    ConstIterator last = aResourceSet.Last();
    for (ConstIterator resource = aResourceSet.First(); resource != last; ++resource)
        Add(*resource);
    return *this;
}

Here is the call graph for this function:

Definition at line 110 of file nsResourceSet.cpp.

{
    PRBool found = PR_FALSE;

    nsIRDFResource** res = mResources;
    nsIRDFResource** limit = mResources + mCount;
    while (res < limit) {
        if (found) {
            *(res - 1) = *res;
        }
        else if (*res == aProperty) {
            NS_RELEASE(*res);
            found = PR_TRUE;
        }
        ++res;
    }

    if (found)
        --mCount;
}

Here is the caller graph for this function:


Member Data Documentation

Definition at line 67 of file nsResourceSet.h.

Definition at line 66 of file nsResourceSet.h.

Definition at line 65 of file nsResourceSet.h.


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