TCStrings.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. #ifndef __TCStrings_h__
  2. #define __TCStrings_h__
  3. /////////////////////////////////////////////////////////////////////////////
  4. // TCStrings.h | Declaration of the CTCStrings, which implements the
  5. // CLSID_TCStrings component object.
  6. #include "resource.h" // main symbols
  7. #include "SrcInc.h"
  8. #include <TCObj.h>
  9. /////////////////////////////////////////////////////////////////////////////
  10. // CTCStrings
  11. class ATL_NO_VTABLE CTCStrings :
  12. public IDispatchImpl<ITCStrings, &IID_ITCStrings, &LIBID_TCObj>,
  13. public IDispatchImpl<ITCCollectionPersistHelper, &IID_ITCCollectionPersistHelper, &LIBID_TCObj>,
  14. public TCPersistPropertyBagImpl<CTCStrings>,
  15. public IPersistStorageImpl<CTCStrings>,
  16. public TCPersistStreamInitImpl<CTCStrings>,
  17. public TCComPropertyClass<CTCStrings>,
  18. public CComCoClass<CTCStrings, &CLSID_TCStrings>,
  19. public CComObjectRoot
  20. {
  21. // Declarations
  22. public:
  23. DECLARE_REGISTRY_RESOURCEID(IDR_TCStrings)
  24. DECLARE_GET_CONTROLLING_UNKNOWN()
  25. // Category Map
  26. public:
  27. BEGIN_CATEGORY_MAP(CTCStrings)
  28. IMPLEMENTED_CATEGORY(CATID_TCObj)
  29. END_CATEGORY_MAP()
  30. // Interface Map
  31. public:
  32. BEGIN_COM_MAP(CTCStrings)
  33. COM_INTERFACE_ENTRY(ITCStrings)
  34. COM_INTERFACE_ENTRY2(IDispatch, ITCStrings)
  35. COM_INTERFACE_ENTRY(ITCCollection)
  36. COM_INTERFACE_ENTRY(ITCCollectionPersistHelper)
  37. COM_INTERFACE_ENTRY2(IPersist, TCPersistPropertyBagImpl<CTCStrings>)
  38. COM_INTERFACE_ENTRY(IPersistPropertyBag)
  39. COM_INTERFACE_ENTRY(IPersistStorage)
  40. COM_INTERFACE_ENTRY(IPersistStreamInit)
  41. COM_INTERFACE_ENTRY2(IPersistStream, TCPersistStreamInitImplBase)
  42. COM_INTERFACE_ENTRY_AUTOAGGREGATE(IID_IMarshal, m_punkMBV.p,
  43. CLSID_TCMarshalByValue)
  44. END_COM_MAP()
  45. // Property Map
  46. public:
  47. BEGIN_PROP_MAP(CTCStrings)
  48. PROP_ENTRY_EX("Strings", dispid_Collection1, CLSID_NULL,
  49. IID_ITCCollectionPersistHelper)
  50. END_PROP_MAP()
  51. // Construction / Destruction
  52. public:
  53. CTCStrings();
  54. // ITCCollection Interface Methods
  55. public:
  56. STDMETHODIMP get_Count(long* pnCount);
  57. STDMETHODIMP get__NewEnum(IUnknown** ppunkEnum);
  58. // ITCStrings Interface Methods
  59. public:
  60. STDMETHODIMP get_Item(VARIANT* pvIndex, BSTR* pbstr);
  61. STDMETHODIMP Add(BSTR bstr);
  62. STDMETHODIMP Remove(VARIANT* pvIndex);
  63. STDMETHODIMP RemoveAll();
  64. STDMETHODIMP AddDelimited(BSTR bstrDelimiter, BSTR bstrStrings);
  65. STDMETHODIMP get_DelimitedItems(BSTR bstrDelimiter, BSTR* pbstrStrings);
  66. STDMETHODIMP AddStrings(ITCStrings* pStrings);
  67. // ITCCollectionPersistHelper Interface Methods
  68. public:
  69. STDMETHODIMP put_Collection1(VARIANT* pvarSafeArray);
  70. STDMETHODIMP get_Collection1(VARIANT* pvarSafeArray);
  71. // Types
  72. protected:
  73. typedef std::vector<CComBSTR> CStringVector;
  74. typedef CStringVector::iterator CStringIterator;
  75. // Data Members
  76. public:
  77. CComPtr<IUnknown> m_punkMBV;
  78. protected:
  79. CStringVector m_vecStrings;
  80. };
  81. /////////////////////////////////////////////////////////////////////////////
  82. #endif // !__TCStrings_h__