Back to index

lightning-sunbird  0.9+nobinonly
Classes | Public Member Functions | Private Member Functions | Private Attributes
PropertyList Class Reference

#include <PropertyList.h>

Collaboration diagram for PropertyList:
Collaboration graph
[legend]

List of all members.

Classes

struct  Property

Public Member Functions

 PropertyList ()
 ~PropertyList ()
void Clear ()
unsigned long GetSize () const
const BSTR GetNameOf (unsigned long nIndex) const
const VARIANT * GetValueOf (unsigned long nIndex) const
bool AddOrReplaceNamedProperty (const BSTR bstrName, const VARIANT &vValue)
bool AddNamedProperty (const BSTR bstrName, const VARIANT &vValue)

Private Member Functions

bool EnsureMoreSpace ()

Private Attributes

struct PropertyList::PropertymProperties
unsigned long mListSize
unsigned long mMaxListSize

Detailed Description

Definition at line 44 of file PropertyList.h.


Class Documentation

struct PropertyList::Property

Definition at line 46 of file PropertyList.h.

Class Members
BSTR bstrName
VARIANT vValue

Constructor & Destructor Documentation

Definition at line 77 of file PropertyList.h.

Definition at line 83 of file PropertyList.h.

    {
    }

Member Function Documentation

bool PropertyList::AddNamedProperty ( const BSTR  bstrName,
const VARIANT &  vValue 
) [inline]

Definition at line 136 of file PropertyList.h.

    {
        if (!bstrName || !EnsureMoreSpace())
            return false;
        Property *pProp = &mProperties[mListSize];
        pProp->bstrName = ::SysAllocString(bstrName);
        if (!pProp->bstrName)
        {
            return false;
        }
        VariantInit(&pProp->vValue);
        if (FAILED(VariantCopy(&pProp->vValue, const_cast<VARIANT *>(&vValue))))
        {
            SysFreeString(pProp->bstrName);
            return false;
        }
        mListSize++;
        return true;
    }

Here is the call graph for this function:

Here is the caller graph for this function:

bool PropertyList::AddOrReplaceNamedProperty ( const BSTR  bstrName,
const VARIANT &  vValue 
) [inline]

Definition at line 121 of file PropertyList.h.

    {
        if (!bstrName)
            return false;
        for (unsigned long i = 0; i < GetSize(); i++)
        {
            // Case insensitive
            if (wcsicmp(mProperties[i].bstrName, bstrName) == 0)
            {
                return SUCCEEDED(
                    VariantCopy(&mProperties[i].vValue, const_cast<VARIANT *>(&vValue)));
            }
        }
        return AddNamedProperty(bstrName, vValue);
    }

Here is the call graph for this function:

Here is the caller graph for this function:

void PropertyList::Clear ( void  ) [inline]

Definition at line 86 of file PropertyList.h.

    {
        if (mProperties)
        {
            for (unsigned long i = 0; i < mListSize; i++)
            {
                SysFreeString(mProperties[i].bstrName); // Safe even if NULL
                VariantClear(&mProperties[i].vValue);
            }
            free(mProperties);
            mProperties = NULL;
        }
        mListSize = 0;
        mMaxListSize = 0;
    }
bool PropertyList::EnsureMoreSpace ( ) [inline, private]

Definition at line 53 of file PropertyList.h.

    {
        // Ensure enough space exists to accomodate a new item
        const unsigned long kGrowBy = 10;
        if (!mProperties)
        {
            mProperties = (Property *) malloc(sizeof(Property) * kGrowBy);
            if (!mProperties)
                return false;
            mMaxListSize = kGrowBy;
        }
        else if (mListSize == mMaxListSize)
        {
            Property *pNewProperties;
            pNewProperties = (Property *) realloc(mProperties, sizeof(Property) * (mMaxListSize + kGrowBy));
            if (!pNewProperties)
                return false;
            mProperties = pNewProperties;
            mMaxListSize += kGrowBy;
        }
        return true;
    }

Here is the call graph for this function:

Here is the caller graph for this function:

const BSTR PropertyList::GetNameOf ( unsigned long  nIndex) const [inline]

Definition at line 105 of file PropertyList.h.

    {
        if (nIndex > mListSize)
        {
            return NULL;
        }
        return mProperties[nIndex].bstrName;
    }

Here is the caller graph for this function:

unsigned long PropertyList::GetSize ( ) const [inline]

Definition at line 101 of file PropertyList.h.

    {
        return mListSize;
    }

Here is the caller graph for this function:

const VARIANT* PropertyList::GetValueOf ( unsigned long  nIndex) const [inline]

Definition at line 113 of file PropertyList.h.

    {
        if (nIndex > mListSize)
        {
            return NULL;
        }
        return &mProperties[nIndex].vValue;
    }

Here is the caller graph for this function:


Member Data Documentation

unsigned long PropertyList::mListSize [private]

Definition at line 50 of file PropertyList.h.

unsigned long PropertyList::mMaxListSize [private]

Definition at line 51 of file PropertyList.h.


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