Back to index

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

#include <txNamespaceMap.h>

Collaboration diagram for txNamespaceMap:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 txNamespaceMap ()
 txNamespaceMap (const txNamespaceMap &aOther)
nsrefcnt AddRef ()
nsrefcnt Release ()
nsresult mapNamespace (nsIAtom *aPrefix, const nsAString &aNamespaceURI)
PRInt32 lookupNamespace (nsIAtom *aPrefix)
PRInt32 lookupNamespace (const nsAString &aPrefix)
PRInt32 lookupNamespaceWithDefault (const nsAString &aPrefix)

Private Attributes

nsAutoRefCnt mRefCnt
nsCOMArray< nsIAtommPrefixes
nsVoidArray mNamespaces

Detailed Description

Definition at line 45 of file txNamespaceMap.h.


Constructor & Destructor Documentation

Definition at line 43 of file txNamespaceMap.cpp.

{
}

Definition at line 47 of file txNamespaceMap.cpp.

    : mPrefixes(aOther.mPrefixes)
{
    mNamespaces = aOther.mNamespaces; //bah! I want a copy-constructor!
}

Member Function Documentation

Definition at line 51 of file txNamespaceMap.h.

    {
        return ++mRefCnt;
    }

Definition at line 102 of file txNamespaceMap.cpp.

{
    if (aPrefix == txXMLAtoms::xml) {
        return kNameSpaceID_XML;
    }

    nsIAtom* prefix = aPrefix == txXMLAtoms::_empty ? 0 : aPrefix;

    PRInt32 index = mPrefixes.IndexOf(prefix);
    if (index >= 0) {
        return NS_PTR_TO_INT32(mNamespaces.SafeElementAt(index));
    }

    if (!prefix) {
        return kNameSpaceID_None;
    }

    return kNameSpaceID_Unknown;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRInt32 txNamespaceMap::lookupNamespace ( const nsAString &  aPrefix)

Definition at line 123 of file txNamespaceMap.cpp.

Here is the call graph for this function:

Definition at line 131 of file txNamespaceMap.cpp.

{
    nsCOMPtr<nsIAtom> prefix = do_GetAtom(aPrefix);
    if (prefix != txXSLTAtoms::_poundDefault) {
        return lookupNamespace(prefix);
    }

    return lookupNamespace(nsnull);
}

Here is the call graph for this function:

nsresult txNamespaceMap::mapNamespace ( nsIAtom aPrefix,
const nsAString &  aNamespaceURI 
)

Definition at line 54 of file txNamespaceMap.cpp.

{
    nsIAtom* prefix = aPrefix == txXMLAtoms::_empty ? nsnull : aPrefix;

    PRInt32 nsId;
    if (prefix && aNamespaceURI.IsEmpty()) {
        // Remove the mapping
        PRInt32 index = mPrefixes.IndexOf(prefix);
        if (index >= 0) {
            mPrefixes.RemoveObjectAt(index);
            mNamespaces.RemoveElementAt(index);
        }

        return NS_OK;
    }

    if (aNamespaceURI.IsEmpty()) {
        // Set default to empty namespace
        nsId = kNameSpaceID_None;
    }
    else {
        nsId = txNamespaceManager::getNamespaceID(aNamespaceURI);
        NS_ENSURE_FALSE(nsId == kNameSpaceID_Unknown, NS_ERROR_FAILURE);
    }

    // Check if the mapping already exists
    PRInt32 index = mPrefixes.IndexOf(prefix);
    if (index >= 0) {
        mNamespaces.ReplaceElementAt(NS_INT32_TO_PTR(nsId), index);

        return NS_OK;
    }

    // New mapping
    if (!mPrefixes.AppendObject(prefix)) {
        return NS_ERROR_OUT_OF_MEMORY;
    }
    
    if (!mNamespaces.AppendElement(NS_INT32_TO_PTR(nsId))) {
        mPrefixes.RemoveObjectAt(mPrefixes.Count() - 1);

        return NS_ERROR_OUT_OF_MEMORY;
    }

    return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 55 of file txNamespaceMap.h.

    {
        if (--mRefCnt == 0) {
            mRefCnt = 1; //stabilize
            delete this;
            return 0;
        }
        return mRefCnt;
    }

Member Data Documentation

Definition at line 73 of file txNamespaceMap.h.

Definition at line 72 of file txNamespaceMap.h.

Definition at line 71 of file txNamespaceMap.h.


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