TCStrings.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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 <AGC.h>
  7. #include "resource.h"
  8. /////////////////////////////////////////////////////////////////////////////
  9. // CTCStrings
  10. class ATL_NO_VTABLE CTCStrings :
  11. public IDispatchImpl<ITCStrings, &IID_ITCStrings, &LIBID_AGCLib>,
  12. public IDispatchImpl<ITCCollectionPersistHelper, &IID_ITCCollectionPersistHelper, &LIBID_AGCLib>,
  13. public TCPersistPropertyBagImpl<CTCStrings>,
  14. public IPersistStorageImpl<CTCStrings>,
  15. public TCPersistStreamInitImpl<CTCStrings>,
  16. public TCComPropertyClass<CTCStrings>,
  17. public AGCObjectSafetyImpl<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_AGC)
  29. IMPLEMENTED_CATEGORY(CATID_SafeForScripting)
  30. IMPLEMENTED_CATEGORY(CATID_SafeForInitializing)
  31. END_CATEGORY_MAP()
  32. // Interface Map
  33. public:
  34. BEGIN_COM_MAP(CTCStrings)
  35. COM_INTERFACE_ENTRY(ITCStrings)
  36. COM_INTERFACE_ENTRY2(IDispatch, ITCStrings)
  37. COM_INTERFACE_ENTRY(ITCCollection)
  38. COM_INTERFACE_ENTRY(ITCCollectionPersistHelper)
  39. COM_INTERFACE_ENTRY2(IPersist, TCPersistPropertyBagImpl<CTCStrings>)
  40. COM_INTERFACE_ENTRY(IPersistPropertyBag)
  41. COM_INTERFACE_ENTRY(IPersistStorage)
  42. COM_INTERFACE_ENTRY(IPersistStreamInit)
  43. COM_INTERFACE_ENTRY2(IPersistStream, TCPersistStreamInitImplBase)
  44. COM_INTERFACE_ENTRY(IObjectSafety)
  45. COM_INTERFACE_ENTRY_AUTOAGGREGATE(IID_IMarshal, m_punkMBV.p,
  46. CLSID_TCMarshalByValue)
  47. END_COM_MAP()
  48. // Property Map
  49. public:
  50. BEGIN_PROP_MAP(CTCStrings)
  51. PROP_ENTRY_EX("Strings", dispid_Collection1, CLSID_NULL,
  52. IID_ITCCollectionPersistHelper)
  53. END_PROP_MAP()
  54. // Construction / Destruction
  55. public:
  56. CTCStrings();
  57. // IAGCCollection Interface Methods
  58. public:
  59. STDMETHODIMP get_Count(long* pnCount);
  60. STDMETHODIMP get__NewEnum(IUnknown** ppunkEnum);
  61. // ITCStrings Interface Methods
  62. public:
  63. STDMETHODIMP get_Item(VARIANT* pvIndex, BSTR* pbstr);
  64. STDMETHODIMP Add(BSTR bstr);
  65. STDMETHODIMP Remove(VARIANT* pvIndex);
  66. STDMETHODIMP RemoveAll();
  67. STDMETHODIMP AddDelimited(BSTR bstrDelimiter, BSTR bstrStrings);
  68. STDMETHODIMP get_DelimitedItems(BSTR bstrDelimiter, BSTR* pbstrStrings);
  69. STDMETHODIMP AddStrings(ITCStrings* pStrings);
  70. // ITCCollectionPersistHelper Interface Methods
  71. public:
  72. STDMETHODIMP put_Collection1(VARIANT* pvarSafeArray);
  73. STDMETHODIMP get_Collection1(VARIANT* pvarSafeArray);
  74. // Types
  75. protected:
  76. typedef std::vector<CComBSTR> CStringVector;
  77. typedef CStringVector::iterator CStringIterator;
  78. // Data Members
  79. public:
  80. CComPtr<IUnknown> m_punkMBV;
  81. protected:
  82. CStringVector m_vecStrings;
  83. };
  84. /////////////////////////////////////////////////////////////////////////////
  85. #endif // !__TCStrings_h__