Bug 783551 - Get tooltool running on the b2g on OS X builds. r=respindola
[gecko.git] / rdf / base / src / nsNameSpaceMap.h
bloba67898098e60d51fec762d9b8ce7dbd928987854
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__
10 #include "nsCOMPtr.h"
11 #include "nsString.h"
12 #include "nsIAtom.h"
14 class nsNameSpaceMap
16 public:
17 class Entry {
18 public:
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); }
25 nsCString mURI;
26 nsCOMPtr<nsIAtom> mPrefix;
28 Entry* mNext;
31 nsNameSpaceMap();
32 ~nsNameSpaceMap();
34 nsresult
35 Put(const nsAString& aURI, nsIAtom* aPrefix);
37 nsresult
38 Put(const nsCSubstring& aURI, nsIAtom* aPrefix);
40 class const_iterator {
41 protected:
42 friend class nsNameSpaceMap;
44 const_iterator(const Entry* aCurrent)
45 : mCurrent(aCurrent) {}
47 const Entry* mCurrent;
49 public:
50 const_iterator()
51 : mCurrent(nullptr) {}
53 const_iterator(const const_iterator& iter)
54 : mCurrent(iter.mCurrent) {}
56 const_iterator&
57 operator=(const const_iterator& iter) {
58 mCurrent = iter.mCurrent;
59 return *this; }
61 const_iterator&
62 operator++() {
63 mCurrent = mCurrent->mNext;
64 return *this; }
66 const_iterator
67 operator++(int) {
68 const_iterator tmp(*this);
69 mCurrent = mCurrent->mNext;
70 return tmp; }
72 const Entry* operator->() const { return mCurrent; }
74 const Entry& operator*() const { return *mCurrent; }
76 bool
77 operator==(const const_iterator& iter) const {
78 return mCurrent == iter.mCurrent; }
80 bool
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;
93 protected:
94 Entry* mEntries;
98 #endif // nsNameSpaceMap_h__