27 #ifndef SB_PROPERTY_BAG_UTILS_H__
28 #define SB_PROPERTY_BAG_UTILS_H__
53 #include <nsIWritablePropertyBag.h>
54 #include <nsIWritablePropertyBag2.h>
92 const nsAString& aKey,
93 nsresult* aRV = nsnull) :
94 mPropertyBag(aPropertyBag),
130 NS_ENSURE_TRUE(mPropertyBag, T());
133 nsCOMPtr<nsIVariant>
value;
134 *mRV = mPropertyBag->GetProperty(mKey, getter_AddRefs(value));
135 NS_ENSURE_SUCCESS(*mRV, T());
153 NS_ENSURE_TRUE(mPropertyBag, *
this);
156 nsCOMPtr<nsIWritablePropertyBag>
157 propertyBag = do_QueryInterface(mPropertyBag, mRV);
158 NS_ENSURE_SUCCESS(*mRV, *
this);
161 *mRV = propertyBag->SetProperty(mKey,
sbNewVariant(aValue));
162 NS_ENSURE_SUCCESS(*mRV, *
this);
178 NS_ENSURE_TRUE(mPropertyBag, *
this);
181 nsCOMPtr<nsIWritablePropertyBag>
182 propertyBag = do_QueryInterface(mPropertyBag, mRV);
183 NS_ENSURE_SUCCESS(*mRV, *
this);
186 *mRV = propertyBag->SetProperty(mKey, aValue);
187 NS_ENSURE_SUCCESS(*mRV, *
this);
207 nsCOMPtr<nsIPropertyBag2>
208 propertyBag = do_QueryInterface(mPropertyBag, mRV);
212 nsCOMPtr<nsIPropertyBag> valuePropertyBag;
213 *mRV = propertyBag->GetPropertyAsInterface(mKey,
214 NS_GET_IID(nsIPropertyBag),
215 getter_AddRefs(valuePropertyBag));
248 nsCOMPtr<nsIPropertyBag> mPropertyBag;
251 nsresult mInternalRV;
272 NS_FORWARD_SAFE_NSIPROPERTYBAG(mPropertyBag)
273 NS_FORWARD_SAFE_NSIPROPERTYBAG2(mPropertyBag2)
274 NS_FORWARD_SAFE_NSIWRITABLEPROPERTYBAG(mWritablePropertyBag)
275 NS_FORWARD_SAFE_NSIWRITABLEPROPERTYBAG2(mWritablePropertyBag2)
294 do_CreateInstance(
"@songbirdnest.com/moz/xpcom/sbpropertybag;1", mRV);
295 NS_ENSURE_SUCCESS(*mRV, );
296 mPropertyBag2 = do_QueryInterface(mPropertyBag);
297 mWritablePropertyBag = do_QueryInterface(mPropertyBag);
298 mWritablePropertyBag2 = do_QueryInterface(mPropertyBag);
311 nsresult* aRV = nsnull) :
320 mPropertyBag = do_QueryInterface(aPropertyBag, mRV);
321 NS_ENSURE_SUCCESS(*mRV, );
322 mPropertyBag2 = do_QueryInterface(aPropertyBag);
323 mWritablePropertyBag = do_QueryInterface(mPropertyBag);
324 mWritablePropertyBag2 = do_QueryInterface(mPropertyBag);
336 operator nsIPropertyBag*()
const
341 operator nsIPropertyBag2*()
const
343 return mPropertyBag2;
346 operator nsIWritablePropertyBag*()
const
348 return mWritablePropertyBag;
351 operator nsIWritablePropertyBag2*()
const
353 return mWritablePropertyBag2;
384 return Get(aKey.BeginReading());
416 NS_ENSURE_STATE(mWritablePropertyBag);
417 NS_ENSURE_ARG_POINTER(aKey);
420 *mRV = mWritablePropertyBag->SetProperty(
sbAutoString(aKey),
422 NS_ENSURE_SUCCESS(*mRV, *mRV);
438 NS_ENSURE_TRUE(mPropertyBag2, PR_FALSE);
442 *mRV = mPropertyBag2->HasKey(
sbAutoString(aKey), &hasKey);
443 NS_ENSURE_SUCCESS(*mRV, PR_FALSE);
477 nsCOMPtr<nsIPropertyBag> mPropertyBag;
478 nsCOMPtr<nsIPropertyBag2> mPropertyBag2;
479 nsCOMPtr<nsIWritablePropertyBag>
480 mWritablePropertyBag;
481 nsCOMPtr<nsIWritablePropertyBag2>
482 mWritablePropertyBag2;
484 nsresult mInternalRV;
sbPropertyHelper & operator=(T aValue)
sbPropertyHelper operator[](const char *aKey) const
sbPropertyBagHelper(nsISupports *aPropertyBag, nsresult *aRV=nsnull)
sbPropertyBagHelper & operator*()
sbPropertyHelper(nsIPropertyBag *aPropertyBag, const nsAString &aKey, nsresult *aRV=nsnull)
Songbird Variant Utility Definitions.
sbPropertyHelper & operator=(nsIVariant *aValue)
sbPropertyHelper operator[](const char *aKey)
sbPropertyBagHelper * operator->()
nsresult Set(char *aKey, T aValue)
sbPropertyHelper(nsresult *aRV=nsnull)
PRBool HasKey(const char *aKey)
sbPropertyHelper Get(const char *aKey) const
sbPropertyHelper operator[](const nsACString &aKey) const
nsIPropertyBag * GetBag()