Wed, 31 Dec 2014 06:09:35 +0100
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 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | #ifndef nsResourceSet_h__ |
michael@0 | 6 | #define nsResourceSet_h__ |
michael@0 | 7 | |
michael@0 | 8 | #include "nsIRDFResource.h" |
michael@0 | 9 | |
michael@0 | 10 | class nsResourceSet |
michael@0 | 11 | { |
michael@0 | 12 | public: |
michael@0 | 13 | nsResourceSet() |
michael@0 | 14 | : mResources(nullptr), |
michael@0 | 15 | mCount(0), |
michael@0 | 16 | mCapacity(0) { |
michael@0 | 17 | MOZ_COUNT_CTOR(nsResourceSet); } |
michael@0 | 18 | |
michael@0 | 19 | nsResourceSet(const nsResourceSet& aResourceSet); |
michael@0 | 20 | |
michael@0 | 21 | nsResourceSet& operator=(const nsResourceSet& aResourceSet); |
michael@0 | 22 | |
michael@0 | 23 | ~nsResourceSet(); |
michael@0 | 24 | |
michael@0 | 25 | nsresult Clear(); |
michael@0 | 26 | nsresult Add(nsIRDFResource* aProperty); |
michael@0 | 27 | void Remove(nsIRDFResource* aProperty); |
michael@0 | 28 | |
michael@0 | 29 | bool Contains(nsIRDFResource* aProperty) const; |
michael@0 | 30 | |
michael@0 | 31 | protected: |
michael@0 | 32 | nsIRDFResource** mResources; |
michael@0 | 33 | int32_t mCount; |
michael@0 | 34 | int32_t mCapacity; |
michael@0 | 35 | |
michael@0 | 36 | public: |
michael@0 | 37 | class ConstIterator { |
michael@0 | 38 | protected: |
michael@0 | 39 | nsIRDFResource** mCurrent; |
michael@0 | 40 | |
michael@0 | 41 | public: |
michael@0 | 42 | ConstIterator() : mCurrent(nullptr) {} |
michael@0 | 43 | |
michael@0 | 44 | ConstIterator(const ConstIterator& aConstIterator) |
michael@0 | 45 | : mCurrent(aConstIterator.mCurrent) {} |
michael@0 | 46 | |
michael@0 | 47 | ConstIterator& operator=(const ConstIterator& aConstIterator) { |
michael@0 | 48 | mCurrent = aConstIterator.mCurrent; |
michael@0 | 49 | return *this; } |
michael@0 | 50 | |
michael@0 | 51 | ConstIterator& operator++() { |
michael@0 | 52 | ++mCurrent; |
michael@0 | 53 | return *this; } |
michael@0 | 54 | |
michael@0 | 55 | ConstIterator operator++(int) { |
michael@0 | 56 | ConstIterator result(*this); |
michael@0 | 57 | ++mCurrent; |
michael@0 | 58 | return result; } |
michael@0 | 59 | |
michael@0 | 60 | /*const*/ nsIRDFResource* operator*() const { |
michael@0 | 61 | return *mCurrent; } |
michael@0 | 62 | |
michael@0 | 63 | /*const*/ nsIRDFResource* operator->() const { |
michael@0 | 64 | return *mCurrent; } |
michael@0 | 65 | |
michael@0 | 66 | bool operator==(const ConstIterator& aConstIterator) const { |
michael@0 | 67 | return mCurrent == aConstIterator.mCurrent; } |
michael@0 | 68 | |
michael@0 | 69 | bool operator!=(const ConstIterator& aConstIterator) const { |
michael@0 | 70 | return mCurrent != aConstIterator.mCurrent; } |
michael@0 | 71 | |
michael@0 | 72 | protected: |
michael@0 | 73 | ConstIterator(nsIRDFResource** aProperty) : mCurrent(aProperty) {} |
michael@0 | 74 | friend class nsResourceSet; |
michael@0 | 75 | }; |
michael@0 | 76 | |
michael@0 | 77 | ConstIterator First() const { return ConstIterator(mResources); } |
michael@0 | 78 | ConstIterator Last() const { return ConstIterator(mResources + mCount); } |
michael@0 | 79 | }; |
michael@0 | 80 | |
michael@0 | 81 | #endif // nsResourceSet_h__ |
michael@0 | 82 |