summaryrefslogtreecommitdiffstats
path: root/dom/bindings/Record.h
diff options
context:
space:
mode:
authorJustOff <Off.Just.Off@gmail.com>2019-03-13 20:13:17 +0200
committerJustOff <Off.Just.Off@gmail.com>2019-03-13 20:13:17 +0200
commit66ee6fdde46bb9c246f7912fcc38d0883f66f961 (patch)
tree57677a5289d5dedb42daa638e137d3672fbd56fb /dom/bindings/Record.h
parent8525a292b0806d258576c2cfc5363b2c44dcaf22 (diff)
downloadUXP-66ee6fdde46bb9c246f7912fcc38d0883f66f961.tar
UXP-66ee6fdde46bb9c246f7912fcc38d0883f66f961.tar.gz
UXP-66ee6fdde46bb9c246f7912fcc38d0883f66f961.tar.lz
UXP-66ee6fdde46bb9c246f7912fcc38d0883f66f961.tar.xz
UXP-66ee6fdde46bb9c246f7912fcc38d0883f66f961.zip
Rename MozMap.h to Record.h
Diffstat (limited to 'dom/bindings/Record.h')
-rw-r--r--dom/bindings/Record.h80
1 files changed, 80 insertions, 0 deletions
diff --git a/dom/bindings/Record.h b/dom/bindings/Record.h
new file mode 100644
index 000000000..2fe18be2b
--- /dev/null
+++ b/dom/bindings/Record.h
@@ -0,0 +1,80 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* 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/. */
+
+/**
+ * Class for representing record arguments. Basically an array under the hood.
+ */
+
+#ifndef mozilla_dom_Record_h
+#define mozilla_dom_Record_h
+
+#include "nsTHashtable.h"
+#include "nsHashKeys.h"
+#include "nsStringGlue.h"
+#include "nsTArray.h"
+#include "mozilla/Attributes.h"
+#include "mozilla/Move.h"
+
+namespace mozilla {
+namespace dom {
+
+namespace binding_detail {
+template<typename KeyType, typename ValueType>
+class RecordEntry
+{
+public:
+ RecordEntry()
+ {
+ }
+
+ // Move constructor so we can do Records of Records.
+ RecordEntry(RecordEntry<KeyType, ValueType>&& aOther)
+ : mKey(Move(aOther.mKey)),
+ mValue(Move(aOther.mValue))
+ {
+ }
+
+ KeyType mKey;
+ ValueType mValue;
+};
+
+} // namespace binding_detail
+
+template<typename KeyType, typename ValueType>
+class Record
+{
+public:
+ typedef typename binding_detail::RecordEntry<nsString, ValueType> EntryType;
+ typedef Record<KeyType, ValueType> SelfType;
+
+ Record()
+ {
+ }
+
+ // Move constructor so we can do Record of Record.
+ Record(SelfType&& aOther) :
+ mEntries(Move(aOther.mEntries))
+ {
+ }
+
+ const nsTArray<EntryType>& Entries() const
+ {
+ return mEntries;
+ }
+
+ nsTArray<EntryType>& Entries()
+ {
+ return mEntries;
+ }
+
+private:
+ nsTArray<EntryType> mEntries;
+};
+
+} // namespace dom
+} // namespace mozilla
+
+#endif // mozilla_dom_Record_h