Closed Bug 344605 Opened 19 years ago Closed 19 years ago

nsIPropertyBag2 should grow a non-throwing get() and hasKey()

Categories

(Core :: XPCOM, enhancement)

enhancement
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: sayrer, Unassigned)

References

Details

Attachments

(2 files)

Here's how I would like it to work: ----------------------------- /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ const BAG_CONTRACTID = "@mozilla.org/hash-property-bag;1" const Ci = Components.interfaces; const Cc = Components.classes; var bag = Cc[BAG_CONTRACTID].createInstance(Ci.nsIWritablePropertyBag2); bag.setPropertyAsAString("foo", "bar"); print("\n\n***************\n"); print(" getProperty() on existing key: " + bag.getProperty("foo")); print(" hasKey() on existing key: " + bag.hasKey("foo")); print(" get() on existing key: " + bag.get("foo")); try { bag.getProperty("baz"); } catch(e) { print("getProperty() on non-existent key: " + e.message); } print(" hasKey() on non-existent key: " + bag.hasKey("baz")); print(" get() on non-existent key: " + bag.get("baz")); print("\n\n***************\n"); ----------------------------- Should print as follows: *************** getProperty() on existing key: bar hasKey() on existing key: true get() on existing key: bar getProperty() on non-existent key: Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIWritablePropertyBag2.getProperty] hasKey() on non-existent key: false get() on non-existent key: null ***************
Here's a strawman.
Attachment #229178 - Flags: review?(darin)
Comment on attachment 229178 [details] [diff] [review] Patch with get() and hasKey() You need to change the UUID of an interface when you changes its vtable layout or the signature of any of its methods. s/Astring/AString/ r=darin otherwise
Attachment #229178 - Flags: review?(darin) → review+
Attachment #229931 - Flags: superreview?(shaver)
Comment on attachment 229931 [details] [diff] [review] fix darin's comments sr=shaver
Attachment #229931 - Flags: superreview?(shaver) → superreview+
Checking in nsHashPropertyBag.cpp; /cvsroot/mozilla/xpcom/ds/nsHashPropertyBag.cpp,v <-- nsHashPropertyBag.cpp new revision: 1.6; previous revision: 1.5 done Checking in nsIPropertyBag2.idl; /cvsroot/mozilla/xpcom/ds/nsIPropertyBag2.idl,v <-- nsIPropertyBag2.idl new revision: 1.2; previous revision: 1.1 done
Status: NEW → RESOLVED
Closed: 19 years ago
Resolution: --- → FIXED
Depends on: 375779
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: