2003-07-27 19:20:11 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* 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/. */
|
2005-02-25 11:59:10 +03:00
|
|
|
#ifndef nsURIHashKey_h__
|
|
|
|
#define nsURIHashKey_h__
|
2003-07-27 19:20:11 +04:00
|
|
|
|
2015-09-16 06:49:53 +03:00
|
|
|
#include "PLDHashTable.h"
|
2003-07-27 19:20:11 +04:00
|
|
|
#include "nsCOMPtr.h"
|
2005-02-23 00:49:45 +03:00
|
|
|
#include "nsIURI.h"
|
2012-03-13 02:53:18 +04:00
|
|
|
#include "nsHashKeys.h"
|
2003-07-27 19:20:11 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Hashtable key class to use with nsTHashtable/nsBaseHashtable
|
|
|
|
*/
|
|
|
|
class nsURIHashKey : public PLDHashEntryHdr
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef nsIURI* KeyType;
|
|
|
|
typedef const nsIURI* KeyTypePointer;
|
|
|
|
|
2014-08-05 17:20:50 +04:00
|
|
|
explicit nsURIHashKey(const nsIURI* aKey) :
|
2007-07-08 11:08:04 +04:00
|
|
|
mKey(const_cast<nsIURI*>(aKey)) { MOZ_COUNT_CTOR(nsURIHashKey); }
|
2003-07-27 19:20:11 +04:00
|
|
|
nsURIHashKey(const nsURIHashKey& toCopy) :
|
|
|
|
mKey(toCopy.mKey) { MOZ_COUNT_CTOR(nsURIHashKey); }
|
|
|
|
~nsURIHashKey() { MOZ_COUNT_DTOR(nsURIHashKey); }
|
|
|
|
|
|
|
|
nsIURI* GetKey() const { return mKey; }
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool KeyEquals(const nsIURI* aKey) const {
|
|
|
|
bool eq;
|
2007-07-08 11:08:04 +04:00
|
|
|
if (NS_SUCCEEDED(mKey->Equals(const_cast<nsIURI*>(aKey), &eq))) {
|
2003-07-27 19:20:11 +04:00
|
|
|
return eq;
|
|
|
|
}
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2003-07-27 19:20:11 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static const nsIURI* KeyToPointer(nsIURI* aKey) { return aKey; }
|
|
|
|
static PLDHashNumber HashKey(const nsIURI* aKey) {
|
2012-09-02 06:35:17 +04:00
|
|
|
nsAutoCString spec;
|
2007-07-08 11:08:04 +04:00
|
|
|
const_cast<nsIURI*>(aKey)->GetSpec(spec);
|
2012-03-13 02:53:18 +04:00
|
|
|
return mozilla::HashString(spec);
|
2003-07-27 19:20:11 +04:00
|
|
|
}
|
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
enum { ALLOW_MEMMOVE = true };
|
2003-07-27 19:20:11 +04:00
|
|
|
|
2007-05-01 23:26:15 +04:00
|
|
|
protected:
|
2003-07-27 19:20:11 +04:00
|
|
|
nsCOMPtr<nsIURI> mKey;
|
|
|
|
};
|
2005-02-25 11:59:10 +03:00
|
|
|
|
|
|
|
#endif // nsURIHashKey_h__
|