![]() | InDesign SDK 20.5 |
#include <StreamUtil.h>
Static Public Member Functions | |
| static IPMStream * | CreateDBStreamRead (IDataBase *db, UID id) |
| static IPMStream * | CreateDBStreamWrite (IDataBase *db, UID id) |
| static IPMStream * | CreateCloudDBStreamRead (IDataBase *db, UID uid) |
| static IPMStream * | CreateCloudDBStreamWrite (IDataBase *db, UID uid) |
| static IPMStream * | CreateCopyStream (IDataBase *src, IDataBase *dest, IXferBytes *xfer=nil) |
| static IPMStream * | CreateDBStreamCopy (IDataBase *src, IDataBase *dest, UID id, IPMUnknown *pmobject=nil) |
| static IPMStream * | CreateFileStreamRead (const IDFile &sysFile, uint32 mode=kOpenIn, OSType fileType=0x3f3f3f3f, OSType creator=0x3f3f3f3f) |
| static IPMStream * | CreateFileStreamWrite (const IDFile &sysFile, uint32 mode=kOpenOut, OSType fileType=0x3f3f3f3f, OSType creator=0x3f3f3f3f) |
| static IPMStream * | CreateFileStreamReadLazy (const IDFile &sysFile, uint32 mode=kOpenIn, OSType fileType=0x3f3f3f3f, OSType creator=0x3f3f3f3f) |
| static IPMStream * | CreateFileStreamWriteLazy (const IDFile &sysFile, uint32 mode=kOpenOut|kOpenTrunc, OSType fileType=0x3f3f3f3f, OSType creator=0x3f3f3f3f) |
| static IPMStream * | CreateObjectTextFileStreamWrite (IDataBase *db, const IDFile &sysFile, uint32 mode=kOpenOut, OSType fileType=0x3f3f3f3f, OSType creator=0x3f3f3f3f) |
| static IPMStream * | CreateResourceStreamRead (const RsrcSpec &spec, bool16 useLocaleIndexResource=kTrue) |
| static IPMStream * | CreateObjectResourceStreamRead (const RsrcSpec &spec, IDataBase *db) |
| static void | ResetStreamContentsChanged (IPMStream *) |
| static void | SetStreamContentsChanged (IPMStream *) |
| static bool16 | StreamContentsChanged (IPMStream *) |
| static IPMStream * | CreateCustomDBStreamWrite (IDataBase *source, UID sourceUID, IDataBase *target, UID targetUID) |
| static IPMStream * | CreateDCXCompositeStream (ClassID clsID, const AdobeDCX::CompositePtr compositePtr) |
Bauhaus managed streams | |
| static IPMStream * | CreateManagedFileStreamRead (const IDFile &sysFile, uint32 mode=kOpenIn, OSType fileType=0x3f3f3f3f, OSType creator=0x3f3f3f3f) |
| static IPMStream * | CreateManagedFileStreamReadLazy (const IDFile &sysFile, uint32 mode=kOpenIn, OSType fileType=0x3f3f3f3f, OSType creator=0x3f3f3f3f) |
Memory-based streams | |
| static IPMStream * | CreatePointerStreamRead (char *buffer, size_t len) |
| static IPMStream * | CreatePointerStreamWrite (char *buffer, size_t len) |
| static IPMStream * | CreateMemoryStreamRead (IXferBytes *underlyingXferBytes, bool16 takeOwnership=kFalse, bool16 recycleBoss=kTrue) |
| static IPMStream * | CreateMemoryStreamWrite (IXferBytes *underlyingXferBytes, bool16 takeOwnership=kFalse, bool16 recycleBoss=kTrue) |
StreamUtil is a class of static functions that create and manipulate InDesign streams. It is provided for convenience and ease of use. Note that any of the create stream methods will return nil if there is an error creating a stream (e.g., file cannot be opened, etc.). So client code should check for nil on return. Example Code:
InterfacePtr<IPMStream> s(StreamUtil::CreateFileStreamRead(myFile));
if (s) {
// read from file
}
else {
// handle error
Also, in all cases, the stream returned is a referenced object, and the caller is responsible for releasing it. Typically this is handled via InterfacePtr, as in the example above.
Create a Read stream from the cloud document to read the content from database.
| db | what database the object is in |
| UID | the object in the database to access |
Create a Read stream from the cloud document to read the content from database.
| db | what database the object is in |
| UID | the object in the database to access |
| static |
For internal use only. Open a stream for copying a database record.
| src | database to copy from |
| dest | database to copy to |
| IXerBytes* | the handler to use for the copy |
| static |
For internal use only. Copy a uid from the src database into a new object in the destination database.
| src | database to copy from |
| dest | database to copy to |
| dest | object to copy to |
| pmobject | used in translating UIDs during the copy (for internal use only) |
Open a stream for reading a database object
| db | what database the object is in |
| UID | the object in the database to access |
Open a stream for writing a database record.
| db | what database the object is in |
| UID | the object in the database to access |
| static |
Open a stream for reading from a file.
| sysFile | the file to read from |
| mode | mode for opening the file (open for read, read/write, etc.) |
| fileType | on Macintosh, this is the Finder file type |
| creator | on Macintosh, this the Finder creator type |
| static |
Open a stream for reading from a file. The file is opened on demand, the first time a read is requested. Note that in this case, you may get back a valid stream from the CreateFileStreamReadLazy method, but the file hasn't yet been opened. It will be opened as the result of a subsequent read request. If the open fails, the stream will go into an error state
| sysFile | the file to read from |
| mode | mode for opening the file (open for read, read/write, etc.) |
| fileType | on Macintosh, this is the Finder file type |
| creator | on Macintosh, this the Finder creator type |
| static |
Open a stream for writing to a file.
| sysFile | the file to read from |
| mode | mode for opening the file (open for read, read/write, etc.) |
| fileType | on Macintosh, this is the Finder file type |
| creator | on Macintosh, this the Finder creator type |
| static |
Open a stream for writing to a file. The file is opened on demand, the first time a write is requested. Note that in this case, you may get back a valid stream from the CreateFileStreamWriteLazy method, but the file hasn't yet been opened. It will be opened as the result of a subsequent write request. If the open fails, the stream will go into an error state
| sysFile | the file to read from |
| mode | mode for opening the file (open for read, read/write, etc.) |
| fileType | on Macintosh, this is the Finder file type |
| creator | on Macintosh, this the Finder creator type |
| static |
Open a stream for reading from a file, downloads the file if it's not already in local repository. Returns nil if file cannot be opened.
| sysFile | the file to read from |
| mode | mode for opening the file (open for read, read/write, etc.) |
| fileType | on Macintosh, this is the Finder file type |
| creator | on Macintosh, this the Finder creator type |
| static |
Open a stream for reading from a file. File is actually opened on demand, the first time a read is requested. Downloads the file if it's not already in local repository. Returns nil if file cannot be opened.
| sysFile | the file to read from |
| mode | mode for opening the file (open for read, read/write, etc.) |
| fileType | on Macintosh, this is the Finder file type |
| creator | on Macintosh, this the Finder creator type |
| static |
Open a stream for reading from memory.
| underlyingXferBytes | IXferBytes instance the memory stream will read from. |
| takeOwnership | Denotes whether the stream is to be the sole owner of the given IXferBytes. |
| recycleBoss | Denotes whether to utilize a recycle boss for the stream.\ If the underlying IXferBytes must be released to free up resources, a file for instance, it is recommended to not use a recycle boss since the IXferBytes might not be released until the stream boss is reused. |
| static |
Open a stream for writing to memory.
| underlyingXferBytes | IXferBytes instance the memory stream will write to. |
| takeOwnership | Denotes whether the stream is to be the sole owner of the given IXferBytes. |
| recycleBoss | Denotes whether to utilize a recycle boss for the stream.\ If the underlying IXferBytes must be released to free up resources, a file for instance, it is recommended to not use a recycle boss since the IXferBytes might not be released until the stream boss is reused. |
| static |
Open a stream for reading from memory.
| buffer | memory address to start reading from |
| len | number of bytes to read |
| static |
Open a stream for writing to memory.
| buffer | memory address to start writing to |
| len | number of bytes that can be written before end of stream |
| static |
Open a stream for reading from a resource.
| spec | a descriptor of the resource to read |
| useLocaleIndexResource | kTrue to use a localized resource |
| inlinestatic |
The following functions are used for verifying stream contents. They is debugging only because they are used to control assertions. There's an assert that comes up if an object has been modified, but Dirty() was never called on it ("object changed but not marked dirty"). The assert is for early detection of cases which could cause document corruption, but it does come up in some situations that are actually OK. For example, if your code does dynamic conversion of data, so that it gets converted when its read in, it would get this assert but be OK. Or if it writes out the current time. In any case, you can set a flag on the stream that causes the assert not to fire. From your ReadWrite, in the case where you're writing out, call SetStreamContentsChanged, and the assert will not come up.Set the stream back to normal after a call to SetStreamContentsChanged. Does nothing in Release target.
| s | the stream to set |
| inlinestatic |
Set the stream to "changes expected" to prevent the assert from firing. Does nothing in Release target.
| s | the stream to set |
| inlinestatic |
Get the stream to "changes expected" to see if the assert should fire. Does nothing in Release target. Internal Use Only.
| s | the stream to set |