1 //-----------------------------------------------------------------------------
2 // LICENSE
3 // (c) 2004-2018, Steinberg Media Technologies GmbH, All Rights Reserved
4 // (c) 2018, Guillaume Piolat (contact@auburnsounds.com)
5 //-----------------------------------------------------------------------------
6 //
7 // This Software Development Kit is licensed under the terms of the General
8 // Public License (GPL) Version 3.
9 //
10 // This source is part of the "Auburn Sounds (Guillaume Piolat) extension to the 
11 // Steinberg VST 3 Plug-in SDK".
12 //
13 // Details of that license can be found at: www.gnu.org/licenses/gpl-3.0.html
14 //
15 // Dual-licence:
16 // 
17 // The "Auburn Sounds (Guillaume Piolat) extension to the Steinberg VST 3 Plug-in
18 // SDK", hereby referred to as DPLUG:VST3, is a language translation of the VST3 
19 // SDK suitable for usage in Dplug. Any Licensee of a currently valid Steinberg 
20 // VST 3 Plug-In SDK Licensing Agreement (version 2.2.4 or ulterior, hereby referred
21 // to as the AGREEMENT), is granted by Auburn Sounds (Guillaume Piolat) a non-exclusive, 
22 // worldwide, nontransferable license during the term the AGREEMENT to use parts
23 // of DPLUG:VST3 not covered by the AGREEMENT, as if they were originally 
24 // inside the Licensed Software Developer Kit mentionned in the AGREEMENT. 
25 // Under this licence all conditions that apply to the Licensed Software Developer 
26 // Kit also apply to DPLUG:VST3.
27 //
28 //-----------------------------------------------------------------------------
29 module dplug.vst3.ibstream;
30 
31 version(VST3):
32 
33 import dplug.vst3.ftypes;
34 
35 /** Base class for streams.
36 \ingroup pluginBase
37 - read/write binary data from/to stream
38 - get/set stream read-write position (read and write position is the same)
39 */
40 interface IBStream: FUnknown
41 {
42 public:
43 nothrow:
44 @nogc:
45 
46     alias IStreamSeekMode = int;
47 	enum : IStreamSeekMode
48 	{
49 		kIBSeekSet = 0, ///< set absolute seek position
50 		kIBSeekCur,     ///< set seek position relative to current position
51 		kIBSeekEnd      ///< set seek position relative to stream end
52 	}
53 
54 	/** Reads binary data from stream.
55 	\param buffer : destination buffer
56 	\param numBytes : amount of bytes to be read
57 	\param numBytesRead : result - how many bytes have been read from stream (set to 0 if this is of no interest) */
58 	tresult read (void* buffer, int32 numBytes, int32* numBytesRead = null);
59 	
60 	/** Writes binary data to stream.
61 	\param buffer : source buffer
62 	\param numBytes : amount of bytes to write
63 	\param numBytesWritten : result - how many bytes have been written to stream (set to 0 if this is of no interest) */
64 	tresult write (void* buffer, int32 numBytes, int32* numBytesWritten = null);
65 	
66 	/** Sets stream read-write position. 
67 	\param pos : new stream position (dependent on mode)
68 	\param mode : value of enum IStreamSeekMode
69 	\param result : new seek position (set to 0 if this is of no interest) */
70 	tresult seek (int64 pos, int32 mode, int64* result = null);
71 	
72 	/** Gets current stream read-write position. 
73 	\param pos : is assigned the current position if function succeeds */
74 	tresult tell (int64* pos);
75 
76     __gshared immutable TUID iid = INLINE_UID(0xC3BF6EA2, 0x30994752, 0x9B6BF990, 0x1EE33E9B);
77 }
78 
79 /+
80 /** Stream with a size. 
81 \ingroup pluginBase
82 [extends IBStream] when stream type supports it (like file and memory stream) */
83 class ISizeableStream: FUnknown
84 {
85 public:
86 
87 	/** Return the stream size */
88 	virtual tresult PLUGIN_API getStreamSize (int64& size) = 0;
89 	/** Set the steam size. File streams can only be resized if they are write enabled. */
90 	virtual tresult PLUGIN_API setStreamSize (int64 size) = 0;
91 
92 
93 	static const FUID iid;
94 };
95 DECLARE_CLASS_IID (ISizeableStream, 0x04F9549E, 0xE02F4E6E, 0x87E86A87, 0x47F4E17F)
96 
97 +/