Back to index

lightning-sunbird  0.9+nobinonly
Classes | Defines | Functions
nsHashPropertyBag.cpp File Reference
#include "nsHashPropertyBag.h"
#include "nsArray.h"
#include "nsArrayEnumerator.h"
#include "nsComponentManagerUtils.h"
#include "nsIVariant.h"
#include "nsIProperty.h"
#include "nsVariant.h"

Go to the source code of this file.

Classes

class  nsSimpleProperty

Defines

#define IMPL_GETSETPROPERTY_AS(Name, Type)

Functions

nsresult NS_NewHashPropertyBag (nsIWritablePropertyBag **_retval)
 PropertyHashToArrayFunc (const nsAString &aKey, nsIVariant *aData, void *userArg)

Define Documentation

#define IMPL_GETSETPROPERTY_AS (   Name,
  Type 
)
Value:
NS_IMETHODIMP \
nsHashPropertyBag::GetPropertyAs ## Name (const nsAString & prop, Type *_retval) \
{ \
    nsIVariant* v = mPropertyHash.GetWeak(prop); \
    if (!v) \
        return NS_ERROR_NOT_AVAILABLE; \
    return v->GetAs ## Name(_retval); \
} \
\
NS_IMETHODIMP \
nsHashPropertyBag::SetPropertyAs ## Name (const nsAString & prop, Type value) \
{ \
    nsCOMPtr<nsIWritableVariant> var = new nsVariant(); \
    if (!var) \
        return NS_ERROR_OUT_OF_MEMORY; \
    var->SetAs ## Name(value); \
    return SetProperty(prop, var); \
}

Definition at line 193 of file nsHashPropertyBag.cpp.


Function Documentation

Definition at line 49 of file nsHashPropertyBag.cpp.

{
    nsHashPropertyBag *hpb = new nsHashPropertyBag();
    if (!hpb)
        return NS_ERROR_OUT_OF_MEMORY;

    NS_ADDREF(hpb);

    nsresult rv = hpb->Init();
    if (NS_FAILED(rv)) {
        NS_RELEASE(hpb);
        return rv;
    }

    *_retval = hpb;
    return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PropertyHashToArrayFunc ( const nsAString &  aKey,
nsIVariant aData,
void userArg 
)

Definition at line 166 of file nsHashPropertyBag.cpp.

{
    nsIMutableArray *propertyArray =
        NS_STATIC_CAST(nsIMutableArray *, userArg);
    nsSimpleProperty *sprop = new nsSimpleProperty(aKey, aData);
    propertyArray->AppendElement(sprop, PR_FALSE);
    return PL_DHASH_NEXT;
}