home *** CD-ROM | disk | FTP | other *** search
/ Chip 1997 October / Chip_1997-10_cd.bin / tema / sybase / powerj / hpp.z / wolestor.hpp < prev    next >
C/C++ Source or Header  |  1996-10-18  |  11KB  |  311 lines

  1. /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  2.    %     Copyright (C) 1994, by WATCOM International Inc.  All rights    %
  3.    %     reserved.  No part of this software may be reproduced or        %
  4.    %     used in any form or by any means - graphic, electronic or       %
  5.    %     mechanical, including photocopying, recording, taping or        %
  6.    %     information storage and retrieval systems - except with the     %
  7.    %     written permission of WATCOM International Inc.                 %
  8.    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  9. */
  10.  
  11. #ifndef _WOLESTOR_HPP_INCLUDED
  12. #define _WOLESTOR_HPP_INCLUDED
  13.  
  14. #ifndef _WNO_PRAGMA_PUSH
  15. #pragma pack(push,8);
  16. #pragma enum int;
  17. #endif
  18.  
  19. #ifndef _WARRAY_HPP_INCLUDED
  20. #  include "warray.hpp"
  21. #endif
  22. #ifndef _WSTRING_HPP_INCLUDED
  23. #  include "wstring.hpp"
  24. #endif
  25. #ifndef _WOLETYPE_HPP_INCLUDED
  26. #  include "woletype.hpp"
  27. #endif
  28. #ifndef _WOLEAUTO_HPP_INCLUDED
  29. #  include "woleauto.hpp"
  30. #endif
  31.  
  32. // forward class declarations
  33. class WCMCLASS WOleStream;
  34. class WCMCLASS WOleStorage;
  35.  
  36. /* Storage instantiation modes */
  37. #define WSTGM_DIRECT             0x00000000L
  38. #define WSTGM_TRANSACTED         0x00010000L
  39. #define WSTGM_SIMPLE             0x08000000L
  40.  
  41. #define WSTGM_READ               0x00000000L
  42. #define WSTGM_WRITE              0x00000001L
  43. #define WSTGM_READWRITE          0x00000002L
  44.  
  45. #define WSTGM_SHARE_DENY_NONE    0x00000040L
  46. #define WSTGM_SHARE_DENY_READ    0x00000030L
  47. #define WSTGM_SHARE_DENY_WRITE   0x00000020L
  48. #define WSTGM_SHARE_EXCLUSIVE    0x00000010L
  49.  
  50. #define WSTGM_PRIORITY           0x00040000L
  51. #define WSTGM_DELETEONRELEASE    0x04000000L
  52. #define WSTGM_NOSCRATCH          0x00100000L
  53.  
  54. #define WSTGM_CREATE             0x00001000L
  55. #define WSTGM_CONVERT            0x00020000L
  56. #define WSTGM_FAILIFTHERE        0x00000000L
  57.  
  58. enum WSTGTY {
  59.     WSTGTY_STORAGE      = 1,
  60.     WSTGTY_STREAM       = 2,
  61.     WSTGTY_LOCKBYTES    = 3,
  62.     WSTGTY_PROPERTY     = 4
  63. };
  64.  
  65. enum WSTREAM_SEEK {
  66.     WSTREAM_SEEK_SET    = 0,
  67.     WSTREAM_SEEK_CUR    = 1,
  68.     WSTREAM_SEEK_END    = 2
  69. };
  70.  
  71. enum WLOCKTYPE {
  72.     WLOCK_WRITE         = 1,
  73.     WLOCK_EXCLUSIVE     = 2,
  74.     WLOCK_ONLYONCE      = 4
  75. };
  76.  
  77. enum WSTGC {
  78.     WSTGC_DEFAULT       = 0,
  79.     WSTGC_OVERWRITE     = 1,
  80.     WSTGC_ONLYIFCURRENT = 2,
  81.     WSTGC_DANGEROUSLYCOMMITMERELYTODISKCACHE    = 4
  82. };
  83.  
  84. enum WSTGMOVE {
  85.     WSTGMOVE_MOVE       = 0,
  86.     WSTGMOVE_COPY       = 1
  87. };
  88.  
  89. enum WSTATFLAG {
  90.     WSTATFLAG_DEFAULT   = 0,
  91.     WSTATFLAG_NONAME    = 1
  92. };
  93.  
  94. class WCMCLASS WStatStg {
  95.  
  96.     public:
  97.  
  98.     /**********************************************************
  99.      * Constructors and Destructors
  100.      *********************************************************/
  101.  
  102.         WStatStg();
  103.         WStatStg( const WStatStg & statStg );
  104.         ~WStatStg();
  105.  
  106.     /**********************************************************
  107.      * Operators
  108.      *********************************************************/
  109.  
  110.         WStatStg & operator=( const WStatStg & statStg );
  111.     
  112.     /**********************************************************
  113.      * Data Members
  114.      *********************************************************/
  115.  
  116.     public:
  117.         WString         name;
  118.         WSTGTY          type;
  119.         WULARGE_INTEGER size;
  120.         WFileTime       mtime;
  121.         WFileTime       ctime;
  122.         WFileTime       atime;
  123.         WDWord          grfMode;
  124.         WDWord          grfLocksSupported;
  125.         WCLSID          clsid;
  126.         WDWord          grfStateBits;
  127. };
  128.  
  129. extern template WArrayReference<WStatStg>;
  130. extern template WArray<WStatStg>;
  131. typedef WArray<WStatStg> WStatStgArray;
  132.  
  133. /*************************************************************************
  134.  *
  135.  * WOleStream -- OLE Stream
  136.  *
  137.  *
  138.  *   Events:
  139.  *
  140.  *
  141.  *************************************************************************/
  142.  
  143. class WCMCLASS WOleStream : public WObject {
  144.  
  145.     public:
  146.  
  147.     /**********************************************************
  148.      * Constructors and Destructors
  149.      *********************************************************/
  150.  
  151.         WOleStream();
  152.         WOleStream( WPIStream stream );
  153.         WOleStream( const WOleStream & stream );
  154.         ~WOleStream();
  155.  
  156.     /**************************************************************
  157.      * Properties
  158.      **************************************************************/
  159.  
  160.         // Valid
  161.         WBool GetValid( void ) const;
  162.     
  163.         // Handle
  164.         WPIStream GetHandle( void ) const;
  165.     
  166.         // HGlobal
  167.         WMemoryHandle GetHGlobal( void ) const;
  168.  
  169.         // Last Result
  170.         WHRESULT GetLastResult( void ) const;
  171.     
  172.     /**************************************************************
  173.      * Methods
  174.      **************************************************************/
  175.  
  176.         void Clear( void );
  177.  
  178.         WBool Read( void *data, WULong length, WULong *numRead );
  179.         WBool Write( const void *data, WULong length, WULong *numWritten );
  180.         WBool Seek( WLong move, WSTREAM_SEEK origin, WULong *newPosition );
  181.         WBool Seek( WLARGE_INTEGER move, WSTREAM_SEEK origin, WULARGE_INTEGER *newPosition );
  182.         WBool SetSize( WULong newSize );
  183.         WBool SetSize( WULARGE_INTEGER newSize );
  184.         WBool CopyTo( WOleStream & stream, WULong length, WULong *numRead, WULong *numWritten );
  185.         WBool CopyTo( WOleStream & stream, WULARGE_INTEGER length, WULARGE_INTEGER  *numRead, WULARGE_INTEGER *numWritten );
  186.         WBool Commit( WDWord commitFlags );
  187.         WBool Revert( void );
  188.         WBool LockRegion( WULong offset, WULong length, WLOCKTYPE lockType );
  189.         WBool LockRegion( WULARGE_INTEGER offset, WULARGE_INTEGER length, WLOCKTYPE lockType );
  190.         WBool UnlockRegion( WULong offset, WULong length, WLOCKTYPE lockType );
  191.         WBool UnlockRegion( WULARGE_INTEGER offset, WULARGE_INTEGER length, WLOCKTYPE lockType );
  192.         WBool Stat( WStatStg & wstatStg, WSTATFLAG statFlag );
  193.         WBool Clone( WOleStream & stream );
  194.         
  195.         static WBool CreateStreamOnHGlobal( WMemoryHandle hGlobal, WBool deleteOnRelease, WOleStream & stream );
  196.  
  197.     /**********************************************************
  198.      * Operators
  199.      *********************************************************/
  200.  
  201.         WOleStream & operator=( const WOleStream & stream );
  202.         WOleStream & operator=( WPIStream stream );
  203.  
  204.         operator WPIStream() const;
  205.     
  206.     /**********************************************************
  207.      * Data Members
  208.      *********************************************************/
  209.  
  210.     protected:
  211.  
  212.         WPIStream       _stream;
  213.         WHRESULT        _lastResult;
  214.  
  215. };
  216.     
  217.  
  218. /*************************************************************************
  219.  *
  220.  * WOleStorage -- OLE Storage
  221.  *
  222.  *
  223.  *   Events:
  224.  *
  225.  *
  226.  *************************************************************************/
  227.  
  228. class WCMCLASS WOleStorage : public WObject {
  229.  
  230.     public:
  231.  
  232.     /**********************************************************
  233.      * Constructors and Destructors
  234.      *********************************************************/
  235.  
  236.         WOleStorage();
  237.         WOleStorage( WPIStorage storage );
  238.         WOleStorage( const WOleStorage & storage );
  239.         ~WOleStorage();
  240.  
  241.     /**************************************************************
  242.      * Properties
  243.      **************************************************************/
  244.  
  245.         // Valid
  246.         WBool GetValid( void ) const;
  247.     
  248.         // Handle
  249.         WPIStorage GetHandle( void ) const;
  250.     
  251.         // Last Result
  252.         WHRESULT GetLastResult( void ) const;
  253.     
  254.     /**************************************************************
  255.      * Methods
  256.      **************************************************************/
  257.  
  258.         void Clear( void );
  259.  
  260.         WBool CreateStream( const WString & name, WDWord mode, WOleStream & wstream );
  261.         WBool OpenStream( const WString & name, WDWord mode, WOleStream & wstream );
  262.         WBool CreateStorage( const WString & name, WDWord mode, WDWord stgFmt, WOleStorage & storage );
  263.         WBool OpenStorage( const WString & name, WDWord mode, WOleStorage & storage );
  264.         // NYI WBool OpenStorage( const WString & name, WOleStorage & stgPriority, WDWord mode, SNB snbExclude, WOleStorage & storage );
  265.         WBool CopyTo( WOleStorage & stgDest );
  266.         // NYI WBool CopyTo( WDWord numIIDExclude, const WIID *IIDExclude, SNB snbExclude, WOleStorage & stgDest );
  267.         WBool MoveElementTo( const WString & name, WOleStorage & stgDest, const WString & newName, WDWord flags );
  268.         WBool Commit( WDWord commitFlags );
  269.         WBool Revert( void );
  270.         WBool EnumElements( WStatStgArray & stgArray );
  271.         WBool DestroyElement( const WString & name );
  272.         WBool RenameElement( const WString & oldName, const WString & newName );
  273.         WBool SetElementTimes( const WString & name, const WFileTime *wctime, const WFileTime *watime, const WFileTime *wmtime );
  274.         WBool SetClass( const WCLSID & clsid );
  275.         WBool SetStateBits( WDWord stateBits, WDWord mask );
  276.         WBool Stat( WStatStg & wstatStg, WSTATFLAG statFlag );
  277.             
  278.         static WBool StgCreateDocfile( const WString & name, WDWord mode, WOleStorage & stgOpen, WHRESULT *result=NULL );
  279.         static WBool StgOpenStorage( const WString & name, WDWord mode, WOleStorage & stgOpen, WHRESULT *result=NULL );
  280.         // NYI static WBool StgOpenStorage( const WString & name, WOleStorage & stgPriority, WDWord mode, SNB snbExclude, WOleStorage & stgOpen, WHRESULT *result=NULL );
  281.         static WBool StgIsStorageFile( const WString & name, WHRESULT *result=NULL );
  282.         static WBool StgSetTimes( const WString & name, const WFileTime *wctime, const WFileTime *watime, const WFileTime *wmtime, WHRESULT *result=NULL );
  283.  
  284.     /**********************************************************
  285.      * Operators
  286.      *********************************************************/
  287.  
  288.         WOleStorage & operator=( const WOleStorage & storage );
  289.         WOleStorage & operator=( WPIStorage storage );
  290.     
  291.         operator WPIStorage() const;
  292.  
  293.     /**********************************************************
  294.      * Data Members
  295.      *********************************************************/
  296.  
  297.     protected:
  298.  
  299.         WPIStorage      _storage;
  300.         WHRESULT        _lastResult;
  301.  
  302. };
  303.     
  304. #ifndef _WNO_PRAGMA_PUSH
  305. #pragma enum pop;
  306. #pragma pack(pop);
  307. #endif
  308.  
  309. #endif // _WOLESTOR_HPP_INCLUDED
  310.  
  311.