InDesign SDK  20.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StreamUtil.h
1 //========================================================================================
2 //
3 // $File$
4 //
5 // Owner: Robin_Briggs
6 //
7 // $Author$
8 //
9 // $DateTime$
10 //
11 // $Revision$
12 //
13 // $Change$
14 //
15 // Copyright 1997-2010 Adobe Systems Incorporated. All rights reserved.
16 //
17 // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance
18 // with the terms of the Adobe license agreement accompanying it. If you have received
19 // this file from a source other than Adobe, then your use, modification, or
20 // distribution of it requires the prior written permission of Adobe.
21 //
22 //========================================================================================
23 
24 #ifndef __StreamUtil__
25 #define __StreamUtil__
26 
27 #include "ShuksanID.h"
28 #include "IPMStream.h"
29 #include "IBoolData.h"
30 
31 #define ID_FORWARD_DECLARE(_X) \
32  class _X; \
33  using _X##Ptr = std::shared_ptr<_X>;\
34  using Const##_X##Ptr = std::shared_ptr<const _X>;\
35  using _X##WeakPtr = std::weak_ptr<_X>;\
36  using Const##_X##WeakPtr = std::weak_ptr<const _X>;\
37  using _X##UniquePtr = std::unique_ptr<_X>;\
38 
39 namespace AdobeDCX{
40 ID_FORWARD_DECLARE(Composite);
41 }
42 
43 class IXferBytes;
44 class IDataBase;
45 class RsrcSpec;
46 
68 class StreamUtil {
69  public:
70 
71  // Database stream access
72 
79  static IPMStream *CreateDBStreamRead(IDataBase *db, UID id);
80 
87  static IPMStream *CreateDBStreamWrite(IDataBase *db, UID id);
88 
89 
98 
99 
109 
119  static IPMStream *CreateCopyStream(IDataBase *src, IDataBase *dest, IXferBytes *xfer = nil);
120 
130  static IPMStream *CreateDBStreamCopy(IDataBase *src, IDataBase *dest, UID id, IPMUnknown* pmobject = nil);
131 
132  // File access
133 
142  static IPMStream *CreateFileStreamRead(const IDFile& sysFile, uint32 mode = kOpenIn, OSType fileType = 0x3f3f3f3f, OSType creator = 0x3f3f3f3f);
143 
152  static IPMStream *CreateFileStreamWrite(const IDFile& sysFile, uint32 mode = kOpenOut, OSType fileType = 0x3f3f3f3f, OSType creator = 0x3f3f3f3f);
153 
166  static IPMStream *CreateFileStreamReadLazy(const IDFile& sysFile, uint32 mode = kOpenIn, OSType fileType = 0x3f3f3f3f, OSType creator = 0x3f3f3f3f);
167 
180  static IPMStream *CreateFileStreamWriteLazy(const IDFile& sysFile, uint32 mode = kOpenOut | kOpenTrunc, OSType fileType = 0x3f3f3f3f, OSType creator = 0x3f3f3f3f);
181 
182  static IPMStream *CreateObjectTextFileStreamWrite(IDataBase* db, const IDFile& sysFile, uint32 mode = kOpenOut, OSType fileType = 0x3f3f3f3f, OSType creator = 0x3f3f3f3f);
183 
185 
186 
195  static IPMStream *CreateManagedFileStreamRead(const IDFile& sysFile, uint32 mode = kOpenIn, OSType fileType = 0x3f3f3f3f, OSType creator = 0x3f3f3f3f);
196 
206  static IPMStream *CreateManagedFileStreamReadLazy(const IDFile& sysFile, uint32 mode = kOpenIn, OSType fileType = 0x3f3f3f3f, OSType creator = 0x3f3f3f3f);
207 
209 
211 
212 
220  static IPMStream *CreatePointerStreamRead(char *buffer, size_t len);
221 
229  static IPMStream *CreatePointerStreamWrite(char *buffer, size_t len);
230 
240  static IPMStream *CreateMemoryStreamRead(IXferBytes* underlyingXferBytes, bool16 takeOwnership = kFalse, bool16 recycleBoss = kTrue);
241 
251  static IPMStream *CreateMemoryStreamWrite(IXferBytes* underlyingXferBytes, bool16 takeOwnership = kFalse, bool16 recycleBoss = kTrue);
252 
254 
262  static IPMStream *CreateResourceStreamRead(const RsrcSpec& spec, bool16 useLocaleIndexResource = kTrue);
263 
264  // For Internal Use Only.
265  static IPMStream *CreateObjectResourceStreamRead(const RsrcSpec& spec, IDataBase* db);
266 
279 #if defined(DEBUG)
280 
285  static void ResetStreamContentsChanged(IPMStream *s)
286  {
287  InterfacePtr<IBoolData> sBool(s, IID_IBOOLDATA);
288  if (sBool != nil)
289  sBool->Set(kFalse);
290  }
296  static void SetStreamContentsChanged(IPMStream *s)
297  {
298  InterfacePtr<IBoolData> sBool(s, IID_IBOOLDATA);
299  if (sBool != nil)
300  sBool->Set(kTrue);
301  }
309  static bool16 StreamContentsChanged(IPMStream *s)
310  {
311  InterfacePtr<IBoolData> sBool(s, IID_IBOOLDATA);
312  if (sBool == nil)
313  return kFalse;
314  else
315  return sBool->GetBool();
316  }
317 #else
318 
324  {}
331  {}
340  {return kFalse;}
341 
342 #endif
343  /*
344  Internal Use Only.
345  Used to copy data from source db to destination database.
346  @param source source database
347  @param sourceUID the UID from source database
348  @param target target database
349  @param targetUID the UID from target database
350  */
351 
352  static IPMStream* CreateCustomDBStreamWrite(IDataBase* source, UID sourceUID, IDataBase* target, UID targetUID);
353  /*
354  Internal Use Only.
355  Wrapper stream for composite type files. Cannot actually perform read write directly.
356  Can be used to access the composite pointer.
357  */
358  static IPMStream* CreateDCXCompositeStream(ClassID clsID,const AdobeDCX::CompositePtr compositePtr);
359 
360 };
361 
362 #endif // __StreamUtil__