2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
|
|
|
*
|
2012-05-21 04:12:37 -07:00
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#ifndef nsNameSpaceMap_h__
|
|
|
|
#define nsNameSpaceMap_h__
|
|
|
|
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsString.h"
|
|
|
|
#include "nsIAtom.h"
|
|
|
|
|
|
|
|
class nsNameSpaceMap
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
class Entry {
|
|
|
|
public:
|
|
|
|
Entry(const nsCSubstring& aURI, nsIAtom* aPrefix)
|
2012-07-30 07:20:58 -07:00
|
|
|
: mURI(aURI), mPrefix(aPrefix), mNext(nullptr) {
|
2007-03-22 10:30:00 -07:00
|
|
|
MOZ_COUNT_CTOR(nsNameSpaceMap::Entry); }
|
|
|
|
|
|
|
|
~Entry() { MOZ_COUNT_DTOR(nsNameSpaceMap::Entry); }
|
|
|
|
|
|
|
|
nsCString mURI;
|
|
|
|
nsCOMPtr<nsIAtom> mPrefix;
|
|
|
|
|
|
|
|
Entry* mNext;
|
|
|
|
};
|
|
|
|
|
|
|
|
nsNameSpaceMap();
|
|
|
|
~nsNameSpaceMap();
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
Put(const nsAString& aURI, nsIAtom* aPrefix);
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
Put(const nsCSubstring& aURI, nsIAtom* aPrefix);
|
|
|
|
|
|
|
|
class const_iterator {
|
|
|
|
protected:
|
|
|
|
friend class nsNameSpaceMap;
|
|
|
|
|
2014-09-02 15:21:23 -07:00
|
|
|
explicit const_iterator(const Entry* aCurrent)
|
2007-03-22 10:30:00 -07:00
|
|
|
: mCurrent(aCurrent) {}
|
|
|
|
|
|
|
|
const Entry* mCurrent;
|
|
|
|
|
|
|
|
public:
|
|
|
|
const_iterator()
|
2012-07-30 07:20:58 -07:00
|
|
|
: mCurrent(nullptr) {}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
const_iterator(const const_iterator& iter)
|
|
|
|
: mCurrent(iter.mCurrent) {}
|
|
|
|
|
|
|
|
const_iterator&
|
|
|
|
operator=(const const_iterator& iter) {
|
|
|
|
mCurrent = iter.mCurrent;
|
|
|
|
return *this; }
|
|
|
|
|
|
|
|
const_iterator&
|
|
|
|
operator++() {
|
|
|
|
mCurrent = mCurrent->mNext;
|
|
|
|
return *this; }
|
|
|
|
|
|
|
|
const_iterator
|
|
|
|
operator++(int) {
|
|
|
|
const_iterator tmp(*this);
|
|
|
|
mCurrent = mCurrent->mNext;
|
|
|
|
return tmp; }
|
|
|
|
|
|
|
|
const Entry* operator->() const { return mCurrent; }
|
|
|
|
|
|
|
|
const Entry& operator*() const { return *mCurrent; }
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool
|
2007-03-22 10:30:00 -07:00
|
|
|
operator==(const const_iterator& iter) const {
|
|
|
|
return mCurrent == iter.mCurrent; }
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool
|
2007-03-22 10:30:00 -07:00
|
|
|
operator!=(const const_iterator& iter) const {
|
|
|
|
return ! iter.operator==(*this); }
|
|
|
|
};
|
|
|
|
|
|
|
|
const_iterator first() const {
|
|
|
|
return const_iterator(mEntries); }
|
|
|
|
|
|
|
|
const_iterator last() const {
|
2012-07-30 07:20:58 -07:00
|
|
|
return const_iterator(nullptr); }
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
const_iterator GetNameSpaceOf(const nsCSubstring& aURI) const;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
Entry* mEntries;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif // nsNameSpaceMap_h__
|