2014-05-24 01:32:38 +04:00
|
|
|
/* -*- 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/. */
|
|
|
|
|
|
|
|
/**
|
2017-02-15 08:01:35 +03:00
|
|
|
* Class for representing record arguments. Basically an array under the hood.
|
2014-05-24 01:32:38 +04:00
|
|
|
*/
|
|
|
|
|
2017-02-15 08:01:35 +03:00
|
|
|
#ifndef mozilla_dom_Record_h
|
|
|
|
#define mozilla_dom_Record_h
|
2014-05-24 01:32:38 +04:00
|
|
|
|
|
|
|
#include "nsTHashtable.h"
|
|
|
|
#include "nsHashKeys.h"
|
2017-12-07 03:52:51 +03:00
|
|
|
#include "nsString.h"
|
2014-05-24 01:32:38 +04:00
|
|
|
#include "nsTArray.h"
|
2015-03-19 10:46:40 +03:00
|
|
|
#include "mozilla/Attributes.h"
|
2014-05-24 01:32:38 +04:00
|
|
|
#include "mozilla/Move.h"
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
|
|
|
namespace binding_detail {
|
2017-02-15 08:00:00 +03:00
|
|
|
template<typename KeyType, typename ValueType>
|
2017-02-15 08:01:35 +03:00
|
|
|
class RecordEntry
|
2014-05-24 01:32:38 +04:00
|
|
|
{
|
|
|
|
public:
|
2017-02-15 08:01:35 +03:00
|
|
|
RecordEntry()
|
2014-05-24 01:32:38 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2017-02-15 08:01:35 +03:00
|
|
|
// Move constructor so we can do Records of Records.
|
|
|
|
RecordEntry(RecordEntry<KeyType, ValueType>&& aOther)
|
2018-05-30 22:15:35 +03:00
|
|
|
: mKey(std::move(aOther.mKey)),
|
|
|
|
mValue(std::move(aOther.mValue))
|
2014-05-24 01:32:38 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2017-02-15 08:00:00 +03:00
|
|
|
KeyType mKey;
|
|
|
|
ValueType mValue;
|
2014-05-24 01:32:38 +04:00
|
|
|
};
|
2015-07-13 18:25:42 +03:00
|
|
|
|
2014-05-24 01:32:38 +04:00
|
|
|
} // namespace binding_detail
|
|
|
|
|
2017-02-15 08:01:35 +03:00
|
|
|
template<typename KeyType, typename ValueType>
|
|
|
|
class Record
|
2014-05-24 01:32:38 +04:00
|
|
|
{
|
|
|
|
public:
|
2017-02-15 08:01:39 +03:00
|
|
|
typedef typename binding_detail::RecordEntry<KeyType, ValueType> EntryType;
|
2017-02-15 08:01:35 +03:00
|
|
|
typedef Record<KeyType, ValueType> SelfType;
|
2014-05-24 01:32:38 +04:00
|
|
|
|
2017-02-15 08:01:35 +03:00
|
|
|
Record()
|
2014-05-24 01:32:38 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2017-02-15 08:01:35 +03:00
|
|
|
// Move constructor so we can do Record of Record.
|
|
|
|
Record(SelfType&& aOther) :
|
2018-05-30 22:15:35 +03:00
|
|
|
mEntries(std::move(aOther.mEntries))
|
2014-05-24 01:32:38 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2017-02-15 08:00:00 +03:00
|
|
|
const nsTArray<EntryType>& Entries() const
|
2014-05-24 01:32:38 +04:00
|
|
|
{
|
2017-02-15 08:00:00 +03:00
|
|
|
return mEntries;
|
2014-05-24 01:32:38 +04:00
|
|
|
}
|
|
|
|
|
2017-02-15 08:00:00 +03:00
|
|
|
nsTArray<EntryType>& Entries()
|
2014-06-25 21:25:09 +04:00
|
|
|
{
|
2017-02-15 08:00:00 +03:00
|
|
|
return mEntries;
|
2014-06-25 21:25:09 +04:00
|
|
|
}
|
|
|
|
|
2017-02-15 08:00:00 +03:00
|
|
|
private:
|
|
|
|
nsTArray<EntryType> mEntries;
|
2014-05-24 01:32:38 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2017-02-15 08:01:41 +03:00
|
|
|
template<typename K, typename V>
|
|
|
|
class nsDefaultComparator<mozilla::dom::binding_detail::RecordEntry<K, V>, K>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
bool Equals(const mozilla::dom::binding_detail::RecordEntry<K, V>& aEntry,
|
|
|
|
const K& aKey) const
|
|
|
|
{
|
|
|
|
return aEntry.mKey == aKey;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-02-15 08:01:35 +03:00
|
|
|
#endif // mozilla_dom_Record_h
|