1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #include "nsProperties.h"
9 ////////////////////////////////////////////////////////////////////////////////
11 NS_IMPL_ISUPPORTS(nsProperties
, nsIProperties
)
14 nsProperties::Get(const char* prop
, const nsIID
& uuid
, void** result
) {
15 if (NS_WARN_IF(!prop
)) {
16 return NS_ERROR_INVALID_ARG
;
19 nsCOMPtr
<nsISupports
> value
;
20 if (!nsProperties_HashBase::Get(prop
, getter_AddRefs(value
))) {
21 return NS_ERROR_FAILURE
;
23 return (value
) ? value
->QueryInterface(uuid
, result
) : NS_ERROR_NO_INTERFACE
;
27 nsProperties::Set(const char* prop
, nsISupports
* value
) {
28 if (NS_WARN_IF(!prop
)) {
29 return NS_ERROR_INVALID_ARG
;
31 InsertOrUpdate(prop
, value
);
36 nsProperties::Undefine(const char* prop
) {
37 if (NS_WARN_IF(!prop
)) {
38 return NS_ERROR_INVALID_ARG
;
41 return nsProperties_HashBase::Remove(prop
) ? NS_OK
: NS_ERROR_FAILURE
;
45 nsProperties::Has(const char* prop
, bool* result
) {
46 if (NS_WARN_IF(!prop
)) {
47 return NS_ERROR_INVALID_ARG
;
50 *result
= nsProperties_HashBase::Contains(prop
);
55 nsProperties::GetKeys(nsTArray
<nsCString
>& aKeys
) {
56 mozilla::AppendToArray(aKeys
, this->Keys());
61 ////////////////////////////////////////////////////////////////////////////////