summaryrefslogtreecommitdiffstats
path: root/dom/xul/templates/nsResourceSet.h
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /dom/xul/templates/nsResourceSet.h
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'dom/xul/templates/nsResourceSet.h')
-rw-r--r--dom/xul/templates/nsResourceSet.h82
1 files changed, 82 insertions, 0 deletions
diff --git a/dom/xul/templates/nsResourceSet.h b/dom/xul/templates/nsResourceSet.h
new file mode 100644
index 000000000..1f50538a8
--- /dev/null
+++ b/dom/xul/templates/nsResourceSet.h
@@ -0,0 +1,82 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/* 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/. */
+#ifndef nsResourceSet_h__
+#define nsResourceSet_h__
+
+#include "nsIRDFResource.h"
+
+class nsResourceSet
+{
+public:
+ nsResourceSet()
+ : mResources(nullptr),
+ mCount(0),
+ mCapacity(0) {
+ MOZ_COUNT_CTOR(nsResourceSet); }
+
+ nsResourceSet(const nsResourceSet& aResourceSet);
+
+ nsResourceSet& operator=(const nsResourceSet& aResourceSet);
+
+ ~nsResourceSet();
+
+ nsresult Clear();
+ nsresult Add(nsIRDFResource* aProperty);
+ void Remove(nsIRDFResource* aProperty);
+
+ bool Contains(nsIRDFResource* aProperty) const;
+
+protected:
+ nsIRDFResource** mResources;
+ int32_t mCount;
+ int32_t mCapacity;
+
+public:
+ class ConstIterator {
+ protected:
+ nsIRDFResource** mCurrent;
+
+ public:
+ ConstIterator() : mCurrent(nullptr) {}
+
+ ConstIterator(const ConstIterator& aConstIterator)
+ : mCurrent(aConstIterator.mCurrent) {}
+
+ ConstIterator& operator=(const ConstIterator& aConstIterator) {
+ mCurrent = aConstIterator.mCurrent;
+ return *this; }
+
+ ConstIterator& operator++() {
+ ++mCurrent;
+ return *this; }
+
+ ConstIterator operator++(int) {
+ ConstIterator result(*this);
+ ++mCurrent;
+ return result; }
+
+ /*const*/ nsIRDFResource* operator*() const {
+ return *mCurrent; }
+
+ /*const*/ nsIRDFResource* operator->() const MOZ_NO_ADDREF_RELEASE_ON_RETURN {
+ return *mCurrent; }
+
+ bool operator==(const ConstIterator& aConstIterator) const {
+ return mCurrent == aConstIterator.mCurrent; }
+
+ bool operator!=(const ConstIterator& aConstIterator) const {
+ return mCurrent != aConstIterator.mCurrent; }
+
+ protected:
+ explicit ConstIterator(nsIRDFResource** aProperty) : mCurrent(aProperty) {}
+ friend class nsResourceSet;
+ };
+
+ ConstIterator First() const { return ConstIterator(mResources); }
+ ConstIterator Last() const { return ConstIterator(mResources + mCount); }
+};
+
+#endif // nsResourceSet_h__
+