Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
834 B

  1. //
  2. // pbag.cpp
  3. //
  4. #include "pbag.h"
  5. /////////////////////////////////////////////////////////////////////////////
  6. //
  7. STDMETHODIMP CPropBag::Read(LPCOLESTR pszPropName, VARIANT* pVar, IErrorLog* pErrorLog)
  8. {
  9. HRESULT hr = S_OK;
  10. BAGMAP::iterator pFind;
  11. pFind = m_map.find(pszPropName);
  12. if (pFind != m_map.end())
  13. VariantCopy(pVar, &(*pFind).second);
  14. else
  15. hr = E_FAIL;
  16. return hr;
  17. }
  18. STDMETHODIMP CPropBag::Write( LPCOLESTR pszPropName, VARIANT* pVar )
  19. {
  20. HRESULT hr = S_OK;
  21. try
  22. {
  23. pair<BAGMAP::iterator, bool> pr;
  24. pr = m_map.insert(BAGMAP::value_type(pszPropName, *pVar));
  25. if (!pr.second) // couldn't insert (someone's there)
  26. VariantCopy(&(*pr.first).second, pVar);
  27. }
  28. catch(...)
  29. {
  30. return E_OUTOFMEMORY;
  31. }
  32. return hr;
  33. }