2018-01-19 03:59:58 +08: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/. */
|
|
|
|
|
|
|
|
|
|
/**
|
2019-03-13 18:46:01 +02:00
|
|
|
* Class for representing MozMap arguments. Basically an array under the hood.
|
2018-01-19 03:59:58 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef mozilla_dom_MozMap_h
|
|
|
|
|
#define mozilla_dom_MozMap_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 {
|
2019-03-13 18:46:01 +02:00
|
|
|
template<typename KeyType, typename ValueType>
|
|
|
|
|
class MozMapEntry
|
2018-01-19 03:59:58 +08:00
|
|
|
{
|
|
|
|
|
public:
|
2019-03-13 18:46:01 +02:00
|
|
|
MozMapEntry()
|
2018-01-19 03:59:58 +08:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Move constructor so we can do MozMaps of MozMaps.
|
2019-03-13 18:46:01 +02:00
|
|
|
MozMapEntry(MozMapEntry<KeyType, ValueType>&& aOther)
|
|
|
|
|
: mKey(Move(aOther.mKey)),
|
|
|
|
|
mValue(Move(aOther.mValue))
|
2018-01-19 03:59:58 +08:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-13 18:46:01 +02:00
|
|
|
KeyType mKey;
|
|
|
|
|
ValueType mValue;
|
2018-01-19 03:59:58 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace binding_detail
|
|
|
|
|
|
2019-03-13 18:46:01 +02:00
|
|
|
template<typename ValueType>
|
|
|
|
|
class MozMap
|
2018-01-19 03:59:58 +08:00
|
|
|
{
|
|
|
|
|
public:
|
2019-03-13 18:46:01 +02:00
|
|
|
typedef nsString KeyType;
|
|
|
|
|
typedef typename binding_detail::MozMapEntry<KeyType, ValueType> EntryType;
|
|
|
|
|
typedef MozMap<ValueType> SelfType;
|
2018-01-19 03:59:58 +08:00
|
|
|
|
|
|
|
|
MozMap()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Move constructor so we can do MozMap of MozMap.
|
|
|
|
|
MozMap(SelfType&& aOther) :
|
2019-03-13 18:46:01 +02:00
|
|
|
mEntries(Move(aOther.mEntries))
|
2018-01-19 03:59:58 +08:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-13 18:46:01 +02:00
|
|
|
const nsTArray<EntryType>& Entries() const
|
2018-01-19 03:59:58 +08:00
|
|
|
{
|
2019-03-13 18:46:01 +02:00
|
|
|
return mEntries;
|
2018-01-19 03:59:58 +08:00
|
|
|
}
|
|
|
|
|
|
2019-03-13 18:46:01 +02:00
|
|
|
nsTArray<EntryType>& Entries()
|
2018-01-19 03:59:58 +08:00
|
|
|
{
|
2019-03-13 18:46:01 +02:00
|
|
|
return mEntries;
|
2018-01-19 03:59:58 +08:00
|
|
|
}
|
|
|
|
|
|
2019-03-13 18:46:01 +02:00
|
|
|
private:
|
|
|
|
|
nsTArray<EntryType> mEntries;
|
2018-01-19 03:59:58 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
|
|
#endif // mozilla_dom_MozMap_h
|