Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Private Member Functions | Private Attributes
NameSpaceManagerImpl Class Reference
Inheritance diagram for NameSpaceManagerImpl:
Inheritance graph
[legend]
Collaboration diagram for NameSpaceManagerImpl:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 NameSpaceManagerImpl ()
virtual ~NameSpaceManagerImpl ()
NS_DECL_ISUPPORTS nsresult Init ()
NS_IMETHOD RegisterNameSpace (const nsAString &aURI, PRInt32 &aNameSpaceID)
NS_IMETHOD GetNameSpaceURI (PRInt32 aNameSpaceID, nsAString &aURI)
NS_IMETHOD GetNameSpaceID (const nsAString &aURI, PRInt32 *aNameSpaceID)
PRBool HasElementCreator (PRInt32 aNameSpaceID)
PRBool HasNameSpaceURI (PRInt32 aNameSpaceID)

Private Member Functions

 NameSpaceManagerImpl (const NameSpaceManagerImpl &aCopy)
NameSpaceManagerImploperator= (const NameSpaceManagerImpl &aCopy)
nsresult AddNameSpace (const nsAString &aURI, const PRInt32 aNameSpaceID)

Private Attributes

nsNameSpaceHash mURIToIDTable
nsStringArray mURIArray

Detailed Description

Definition at line 117 of file nsNameSpaceManager.cpp.


Constructor & Destructor Documentation

Definition at line 151 of file nsNameSpaceManager.cpp.

{
}

Definition at line 155 of file nsNameSpaceManager.cpp.

{
}

Member Function Documentation

nsresult NameSpaceManagerImpl::AddNameSpace ( const nsAString &  aURI,
const PRInt32  aNameSpaceID 
) [private]

Definition at line 305 of file nsNameSpaceManager.cpp.

{
  NS_ASSERTION(aNameSpaceID - 1 == mURIArray.Count(),
               "BAD! AddNameSpace not called in right order!");

  if (!mURIArray.AppendString(aURI)) {
    return NS_ERROR_OUT_OF_MEMORY;
  }

  const nsString* uri = mURIArray.StringAt(aNameSpaceID - 1);
  nsNameSpaceEntry* entry = mURIToIDTable.AddEntry(*uri);
  if (!entry) {
    mURIArray.RemoveStringAt(aNameSpaceID - 1);

    return NS_ERROR_OUT_OF_MEMORY;
  }

  entry->mNameSpaceID = aNameSpaceID;

  return NS_OK;
}

Here is the caller graph for this function:

NS_IMETHODIMP NameSpaceManagerImpl::GetNameSpaceID ( const nsAString &  aURI,
PRInt32 aNameSpaceID 
) [virtual]

Implements nsINameSpaceManager.

Definition at line 228 of file nsNameSpaceManager.cpp.

{
  if (aURI.IsEmpty()) {
    *aNameSpaceID = kNameSpaceID_None; // xmlns="", see bug 75700 for details

    return NS_OK;
  }

  nsNameSpaceEntry* entry = mURIToIDTable.GetEntry(aURI);

  *aNameSpaceID = entry ? entry->mNameSpaceID : kNameSpaceID_Unknown;

  return NS_OK;
}
NS_IMETHODIMP NameSpaceManagerImpl::GetNameSpaceURI ( PRInt32  aNameSpaceID,
nsAString &  aURI 
) [virtual]

Implements nsINameSpaceManager.

Definition at line 213 of file nsNameSpaceManager.cpp.

{
  PRInt32 index = aNameSpaceID - 1; // id is index + 1
  if (index < 0 || index >= mURIArray.Count()) {
    aURI.Truncate();

    return NS_ERROR_ILLEGAL_VALUE;
  }

  mURIArray.StringAt(index, aURI);

  return NS_OK;
}

Implements nsINameSpaceManager.

Definition at line 282 of file nsNameSpaceManager.cpp.

{
  return aNameSpaceID == kNameSpaceID_XHTML ||
#ifdef MOZ_XUL
         aNameSpaceID == kNameSpaceID_XUL ||
#endif
#ifdef MOZ_MATHML
         aNameSpaceID == kNameSpaceID_MathML ||
#endif
#ifdef MOZ_SVG
         aNameSpaceID == kNameSpaceID_SVG ||
#endif
         aNameSpaceID == kNameSpaceID_XMLEvents ||
         PR_FALSE;
}

Definition at line 299 of file nsNameSpaceManager.cpp.

{
  return (aNameSpaceID > kNameSpaceID_None &&
          aNameSpaceID <= mURIArray.Count());
}
NameSpaceManagerImpl& NameSpaceManagerImpl::operator= ( const NameSpaceManagerImpl aCopy) [private]
NS_IMETHODIMP NameSpaceManagerImpl::RegisterNameSpace ( const nsAString &  aURI,
PRInt32 aNameSpaceID 
) [virtual]

Implements nsINameSpaceManager.

Definition at line 186 of file nsNameSpaceManager.cpp.

{
  if (aURI.IsEmpty()) {
    aNameSpaceID = kNameSpaceID_None; // xmlns="", see bug 75700 for details

    return NS_OK;
  }

  nsNameSpaceEntry* entry = mURIToIDTable.GetEntry(aURI);
  if (entry) {
    aNameSpaceID = entry->mNameSpaceID;

    return NS_OK;
  }

  aNameSpaceID = mURIArray.Count() + 1; // id is index + 1

  nsresult rv = AddNameSpace(aURI, aNameSpaceID);
  if (NS_FAILED(rv)) {
    aNameSpaceID = kNameSpaceID_Unknown;
  }

  return rv;
}

Here is the call graph for this function:


Member Data Documentation

nsStringArray NameSpaceManagerImpl::mURIArray [private]

Definition at line 145 of file nsNameSpaceManager.cpp.

Definition at line 144 of file nsNameSpaceManager.cpp.


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