1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef nsNameSpaceMap_h__
8 #define nsNameSpaceMap_h__
19 Entry(const nsCSubstring
& aURI
, nsIAtom
* aPrefix
)
20 : mURI(aURI
), mPrefix(aPrefix
), mNext(nullptr) {
21 MOZ_COUNT_CTOR(nsNameSpaceMap::Entry
); }
23 ~Entry() { MOZ_COUNT_DTOR(nsNameSpaceMap::Entry
); }
26 nsCOMPtr
<nsIAtom
> mPrefix
;
35 Put(const nsAString
& aURI
, nsIAtom
* aPrefix
);
38 Put(const nsCSubstring
& aURI
, nsIAtom
* aPrefix
);
40 class const_iterator
{
42 friend class nsNameSpaceMap
;
44 const_iterator(const Entry
* aCurrent
)
45 : mCurrent(aCurrent
) {}
47 const Entry
* mCurrent
;
51 : mCurrent(nullptr) {}
53 const_iterator(const const_iterator
& iter
)
54 : mCurrent(iter
.mCurrent
) {}
57 operator=(const const_iterator
& iter
) {
58 mCurrent
= iter
.mCurrent
;
63 mCurrent
= mCurrent
->mNext
;
68 const_iterator
tmp(*this);
69 mCurrent
= mCurrent
->mNext
;
72 const Entry
* operator->() const { return mCurrent
; }
74 const Entry
& operator*() const { return *mCurrent
; }
77 operator==(const const_iterator
& iter
) const {
78 return mCurrent
== iter
.mCurrent
; }
81 operator!=(const const_iterator
& iter
) const {
82 return ! iter
.operator==(*this); }
85 const_iterator
first() const {
86 return const_iterator(mEntries
); }
88 const_iterator
last() const {
89 return const_iterator(nullptr); }
91 const_iterator
GetNameSpaceOf(const nsCSubstring
& aURI
) const;
98 #endif // nsNameSpaceMap_h__