Bug 1850713: remove duplicated setting of early hint preloader id in `ScriptLoader...
[gecko.git] / xpcom / ds / nsIPropertyBag2.idl
blob3232dce0ce45de4dcb66b76fc72d424d4bb395fd
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 /* nsIVariant based Property Bag support. */
7 #include "nsIPropertyBag.idl"
9 [scriptable, uuid(625cfd1e-da1e-4417-9ee9-dbc8e0b3fd79)]
10 interface nsIPropertyBag2 : nsIPropertyBag
12 // Accessing a property as a different type may attempt conversion to the
13 // requested value
15 int32_t getPropertyAsInt32 (in AString prop);
16 uint32_t getPropertyAsUint32 (in AString prop);
17 int64_t getPropertyAsInt64 (in AString prop);
18 uint64_t getPropertyAsUint64 (in AString prop);
19 double getPropertyAsDouble (in AString prop);
20 AString getPropertyAsAString (in AString prop);
21 ACString getPropertyAsACString (in AString prop);
22 AUTF8String getPropertyAsAUTF8String (in AString prop);
23 boolean getPropertyAsBool (in AString prop);
25 /**
26 * This method returns null if the value exists, but is null.
28 * Note: C++ callers should not use this method. They should use the
29 * typesafe `do_GetProperty` wrapper instead.
31 void getPropertyAsInterface (in AString prop,
32 in nsIIDRef iid,
33 [iid_is(iid), retval] out nsQIResult result);
35 /**
36 * This method returns null if the value does not exist,
37 * or exists but is null.
39 nsIVariant get (in AString prop);
41 /**
42 * Check for the existence of a key.
44 boolean hasKey (in AString prop);
48 %{C++
49 #include "nsCOMPtr.h"
50 #include "nsAString.h"
52 class MOZ_STACK_CLASS nsGetProperty final : public nsCOMPtr_helper {
53 public:
54 nsGetProperty(nsIPropertyBag2* aPropBag, const nsAString& aPropName, nsresult* aError)
55 : mPropBag(aPropBag), mPropName(aPropName), mErrorPtr(aError) {}
57 virtual nsresult NS_FASTCALL operator()(const nsIID&, void**) const override;
59 private:
60 nsIPropertyBag2* MOZ_NON_OWNING_REF mPropBag;
61 const nsAString& mPropName;
62 nsresult* mErrorPtr;
65 /**
66 * A typesafe wrapper around nsIPropertyBag2::GetPropertyAsInterface. Similar
67 * to the `do_QueryInterface` family of functions, when assigned to a
68 * `nsCOMPtr` of a given type, attempts to query the given property to that
69 * type.
71 * If `aError` is passed, the return value of `GetPropertyAsInterface` is
72 * stored in it.
74 inline const nsGetProperty do_GetProperty(nsIPropertyBag2* aPropBag,
75 const nsAString& aPropName,
76 nsresult* aError = 0) {
77 return nsGetProperty(aPropBag, aPropName, aError);