NS_PRECONDITION(aCount != nsnull, "null ptr"); if (! aCount) return NS_ERROR_NULL_POINTER;
if (!mDataSource || !mContainer) return NS_ERROR_NOT_INITIALIZED;
RDFContainerImpl::GetCount(PRInt32 *aCount){    NS_PRECONDITION(aCount != nsnull, "null ptr");    if (! aCount)        return NS_ERROR_NULL_POINTER;    nsresult rv;    // Get the next value, which hangs off of the bag via the    // RDF:nextVal property. This is the _next value_ that will get    // assigned in a one-indexed array. So, it's actually _one more_    // than the actual count of elements in the container.    //    // XXX To handle aggregation, this should probably be a    // GetTargets() that enumerates all of the values and picks the    // largest one.    nsCOMPtr<nsIRDFNode> nextValNode;    rv = mDataSource->GetTarget(mContainer, kRDF_nextVal, PR_TRUE, getter_AddRefs(nextValNode));    if (NS_FAILED(rv)) return rv;    if (rv == NS_RDF_NO_VALUE)        return NS_ERROR_UNEXPECTED;    nsCOMPtr<nsIRDFLiteral> nextValLiteral;    rv = nextValNode->QueryInterface(NS_GET_IID(nsIRDFLiteral), getter_AddRefs(nextValLiteral));    if (NS_FAILED(rv)) return rv;    const PRUnichar *s;    rv = nextValLiteral->GetValueConst( &s );    if (NS_FAILED(rv)) return rv;    nsAutoString nextValStr(s);    PRInt32 nextVal;    PRInt32 err;    nextVal = nextValStr.ToInteger(&err);    if (NS_FAILED(err))        return NS_ERROR_UNEXPECTED;    *aCount = nextVal - 1;    return NS_OK;}