rdf/base/src/nsNameSpaceMap.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
michael@0 2 *
michael@0 3 * This Source Code Form is subject to the terms of the Mozilla Public
michael@0 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 6
michael@0 7 #ifndef nsNameSpaceMap_h__
michael@0 8 #define nsNameSpaceMap_h__
michael@0 9
michael@0 10 #include "nsCOMPtr.h"
michael@0 11 #include "nsString.h"
michael@0 12 #include "nsIAtom.h"
michael@0 13
michael@0 14 class nsNameSpaceMap
michael@0 15 {
michael@0 16 public:
michael@0 17 class Entry {
michael@0 18 public:
michael@0 19 Entry(const nsCSubstring& aURI, nsIAtom* aPrefix)
michael@0 20 : mURI(aURI), mPrefix(aPrefix), mNext(nullptr) {
michael@0 21 MOZ_COUNT_CTOR(nsNameSpaceMap::Entry); }
michael@0 22
michael@0 23 ~Entry() { MOZ_COUNT_DTOR(nsNameSpaceMap::Entry); }
michael@0 24
michael@0 25 nsCString mURI;
michael@0 26 nsCOMPtr<nsIAtom> mPrefix;
michael@0 27
michael@0 28 Entry* mNext;
michael@0 29 };
michael@0 30
michael@0 31 nsNameSpaceMap();
michael@0 32 ~nsNameSpaceMap();
michael@0 33
michael@0 34 nsresult
michael@0 35 Put(const nsAString& aURI, nsIAtom* aPrefix);
michael@0 36
michael@0 37 nsresult
michael@0 38 Put(const nsCSubstring& aURI, nsIAtom* aPrefix);
michael@0 39
michael@0 40 class const_iterator {
michael@0 41 protected:
michael@0 42 friend class nsNameSpaceMap;
michael@0 43
michael@0 44 const_iterator(const Entry* aCurrent)
michael@0 45 : mCurrent(aCurrent) {}
michael@0 46
michael@0 47 const Entry* mCurrent;
michael@0 48
michael@0 49 public:
michael@0 50 const_iterator()
michael@0 51 : mCurrent(nullptr) {}
michael@0 52
michael@0 53 const_iterator(const const_iterator& iter)
michael@0 54 : mCurrent(iter.mCurrent) {}
michael@0 55
michael@0 56 const_iterator&
michael@0 57 operator=(const const_iterator& iter) {
michael@0 58 mCurrent = iter.mCurrent;
michael@0 59 return *this; }
michael@0 60
michael@0 61 const_iterator&
michael@0 62 operator++() {
michael@0 63 mCurrent = mCurrent->mNext;
michael@0 64 return *this; }
michael@0 65
michael@0 66 const_iterator
michael@0 67 operator++(int) {
michael@0 68 const_iterator tmp(*this);
michael@0 69 mCurrent = mCurrent->mNext;
michael@0 70 return tmp; }
michael@0 71
michael@0 72 const Entry* operator->() const { return mCurrent; }
michael@0 73
michael@0 74 const Entry& operator*() const { return *mCurrent; }
michael@0 75
michael@0 76 bool
michael@0 77 operator==(const const_iterator& iter) const {
michael@0 78 return mCurrent == iter.mCurrent; }
michael@0 79
michael@0 80 bool
michael@0 81 operator!=(const const_iterator& iter) const {
michael@0 82 return ! iter.operator==(*this); }
michael@0 83 };
michael@0 84
michael@0 85 const_iterator first() const {
michael@0 86 return const_iterator(mEntries); }
michael@0 87
michael@0 88 const_iterator last() const {
michael@0 89 return const_iterator(nullptr); }
michael@0 90
michael@0 91 const_iterator GetNameSpaceOf(const nsCSubstring& aURI) const;
michael@0 92
michael@0 93 protected:
michael@0 94 Entry* mEntries;
michael@0 95 };
michael@0 96
michael@0 97
michael@0 98 #endif // nsNameSpaceMap_h__

mercurial