home *** CD-ROM | disk | FTP | other *** search
/ QBasic & Borland Pascal & C / Delphi5.iso / C / BC_502 / DRAWCL.PAK / PROPSET.H < prev    next >
Encoding:
C/C++ Source or Header  |  1997-05-06  |  5.4 KB  |  199 lines

  1. // propset.h : interface of the CProperty, CPropertySection, and CPropertSet classes
  2. //
  3. // This is a part of the Microsoft Foundation Classes C++ library.
  4. // Copyright (C) 1992-1995 Microsoft Corporation
  5. // All rights reserved.
  6. //
  7. // This source code is only intended as a supplement to the
  8. // Microsoft Foundation Classes Reference and related
  9. // electronic documentation provided with the library.
  10. // See these sources for detailed information regarding the
  11. // Microsoft Foundation Classes product.
  12.  
  13. #if !defined(_MAC)
  14.  
  15. //  Property setting
  16.  
  17. typedef struct tagSECTIONHEADER
  18. {
  19.     DWORD       cbSection ;
  20.     DWORD       cProperties ;  // Number of props.
  21. } SECTIONHEADER, *LPSECTIONHEADER ;
  22.  
  23. typedef struct tagPROPERTYIDOFFSET
  24. {
  25.     DWORD       propertyID;
  26.     DWORD       dwOffset;
  27. } PROPERTYIDOFFSET, *LPPROPERTYIDOFFSET;
  28.  
  29. typedef struct tagPROPHEADER
  30. {
  31.     WORD        wByteOrder ;    // Always 0xFFFE
  32.     WORD        wFormat ;       // Always 0
  33.     DWORD       dwOSVer ;       // System version
  34.     CLSID       clsID ;         // Application CLSID
  35.     DWORD       cSections ;     // Number of sections (must be at least 1)
  36. } PROPHEADER, *LPPROPHEADER ;
  37.  
  38. typedef struct tagFORMATIDOFFSET
  39. {
  40.     GUID        formatID;
  41.     DWORD       dwOffset;
  42. } FORMATIDOFFSET, *LPFORMATIDOFFSET;
  43.  
  44.  
  45. /////////////////////////////////////////////////////////////////////////////
  46. // CProperty
  47.  
  48. class CProperty : public CObject
  49. {
  50.     friend class CPropertySet ;
  51.     friend class CPropertySection ;
  52.  
  53. public:
  54. // Construction
  55.     CProperty( void ) ;
  56.     CProperty( DWORD dwID, const LPVOID pValue, DWORD dwType ) ;
  57.  
  58. // Attributes
  59.     BOOL    Set( DWORD dwID, const LPVOID pValue, DWORD dwType ) ;
  60.     BOOL    Set( const LPVOID pValue, DWORD dwType ) ;
  61.     BOOL    Set( const LPVOID pValue ) ;
  62.     LPVOID  Get( DWORD* pcb ) ;     // Returns pointer to actual value
  63.     LPVOID  Get( void ) ;           // Returns pointer to actual value
  64.     DWORD   GetType( void ) ;       // Returns property type
  65.     void    SetType( DWORD dwType ) ;
  66.     DWORD   GetID( void ) ;
  67.     void    SetID( DWORD dwPropID ) ;
  68.  
  69.     LPVOID  GetRawValue( void ) ;   // Returns pointer internal value (may
  70.                                     // include size information)
  71. // Operations
  72.     BOOL    WriteToStream( IStream* pIStream ) ;
  73.     BOOL    ReadFromStream( IStream* pIStream ) ;
  74.  
  75. private:
  76.     DWORD       m_dwPropID ;
  77.     DWORD       m_dwType ;
  78.     LPVOID      m_pValue ;
  79.  
  80.     LPVOID  AllocValue(ULONG cb);
  81.     void    FreeValue();
  82.  
  83. public:
  84.     ~CProperty() ;
  85. } ;
  86.  
  87.  
  88. /////////////////////////////////////////////////////////////////////////////
  89. // CPropertySection
  90.  
  91. class CPropertySection : public CObject
  92. {
  93.     friend class CPropertySet ;
  94.     friend class CProperty ;
  95.  
  96. public:
  97. // Construction
  98.     CPropertySection( void ) ;
  99.     CPropertySection( CLSID FormatID ) ;
  100.  
  101. // Attributes
  102.     CLSID   GetFormatID( void ) ;
  103.     void    SetFormatID( CLSID FormatID ) ;
  104.  
  105.     BOOL    Set( DWORD dwPropID, LPVOID pValue, DWORD dwType ) ;
  106.     BOOL    Set( DWORD dwPropID, LPVOID pValue ) ;
  107.     LPVOID  Get( DWORD dwPropID, DWORD* pcb ) ;
  108.     LPVOID  Get( DWORD dwPropID ) ;
  109.     void    Remove( DWORD dwPropID ) ;
  110.     void    RemoveAll() ;
  111.  
  112.     CProperty* GetProperty( DWORD dwPropID ) ;
  113.     void AddProperty( CProperty* pProp ) ;
  114.  
  115.     DWORD   GetSize( void ) ;
  116.     DWORD   GetCount( void ) ;
  117.     CObList* GetList( void ) ;
  118.  
  119.     BOOL    GetID( LPCTSTR pszName, DWORD* pdwPropID ) ;
  120.     BOOL    SetName( DWORD dwPropID, LPCTSTR pszName ) ;
  121.  
  122.     BOOL    SetSectionName( LPCTSTR pszName );
  123.     LPCTSTR GetSectionName( void );
  124.  
  125. // Operations
  126.     BOOL    WriteToStream( IStream* pIStream ) ;
  127.     BOOL    ReadFromStream( IStream* pIStream, LARGE_INTEGER liPropSet ) ;
  128.     BOOL    WriteNameDictToStream( IStream* pIStream ) ;
  129.     BOOL    ReadNameDictFromStream( IStream* pIStream ) ;
  130.  
  131. private:
  132. // Implementation
  133.     CLSID           m_FormatID ;
  134.     SECTIONHEADER   m_SH ;
  135.     // List of properties (CProperty)
  136.     CObList         m_PropList ;
  137.     // Dictionary of property names
  138.     CMapStringToPtr m_NameDict ;
  139.     CString         m_strSectionName;
  140.  
  141. public:
  142.     ~CPropertySection();
  143. } ;
  144.  
  145.  
  146. /////////////////////////////////////////////////////////////////////////////
  147. // CPropertySet
  148.  
  149. class CPropertySet : public CObject
  150. {
  151.     friend class CPropertySection ;
  152.     friend class CProperty ;
  153.  
  154. public:
  155. // Construction
  156.     CPropertySet( void ) ;
  157.     CPropertySet( CLSID clsID )  ;
  158.  
  159. // Attributes
  160.     BOOL    Set( CLSID FormatID, DWORD dwPropID, LPVOID pValue, DWORD dwType ) ;
  161.     BOOL    Set( CLSID FormatID, DWORD dwPropID, LPVOID pValue ) ;
  162.     LPVOID  Get( CLSID FormatID, DWORD dwPropID, DWORD* pcb ) ;
  163.     LPVOID  Get( CLSID FormatID, DWORD dwPropID ) ;
  164.     void    Remove( CLSID FormatID, DWORD dwPropID ) ;
  165.     void    Remove( CLSID FormatID ) ;
  166.     void    RemoveAll( ) ;
  167.  
  168.     CProperty* GetProperty( CLSID FormatID, DWORD dwPropID ) ;
  169.     void AddProperty( CLSID FormatID, CProperty* pProp ) ;
  170.     CPropertySection* GetSection( CLSID FormatID ) ;
  171.     CPropertySection* AddSection( CLSID FormatID ) ;
  172.     void AddSection( CPropertySection* psect ) ;
  173.  
  174.     WORD    GetByteOrder( void ) ;
  175.     WORD    GetFormatVersion( void ) ;
  176.     void    SetFormatVersion( WORD wFmtVersion ) ;
  177.     DWORD   GetOSVersion( void ) ;
  178.     void    SetOSVersion( DWORD dwOSVer ) ;
  179.     CLSID   GetClassID( void ) ;
  180.     void    SetClassID( CLSID clsid ) ;
  181.     DWORD   GetCount( void ) ;
  182.     CObList* GetList( void ) ;
  183.  
  184. // Operations
  185.     BOOL    WriteToStream( IStream* pIStream ) ;
  186.     BOOL    ReadFromStream( IStream* pIStream ) ;
  187.  
  188. // Implementation
  189. private:
  190.     PROPHEADER      m_PH ;
  191.     CObList         m_SectionList ;
  192.  
  193. public:
  194.     ~CPropertySet();
  195. } ;
  196.  
  197. #endif // !defined(_MAC)
  198.  
  199.