Audio plugin host https://kx.studio/carla
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

88 lines
3.5KB

  1. //-----------------------------------------------------------------------------
  2. // Project : SDK Core
  3. //
  4. // Category : SDK Core Interfaces
  5. // Filename : pluginterfaces/base/ibstream.h
  6. // Created by : Steinberg, 01/2004
  7. // Description : Interface for reading/writing streams
  8. //
  9. //-----------------------------------------------------------------------------
  10. // This file is part of a Steinberg SDK. It is subject to the license terms
  11. // in the LICENSE file found in the top-level directory of this distribution
  12. // and at www.steinberg.net/sdklicenses.
  13. // No part of the SDK, including this file, may be copied, modified, propagated,
  14. // or distributed except according to the terms contained in the LICENSE file.
  15. //-----------------------------------------------------------------------------
  16. #pragma once
  17. #include "funknown.h"
  18. namespace Steinberg {
  19. //------------------------------------------------------------------------
  20. /** Base class for streams.
  21. \ingroup pluginBase
  22. - read/write binary data from/to stream
  23. - get/set stream read-write position (read and write position is the same)
  24. */
  25. class IBStream: public FUnknown
  26. {
  27. public:
  28. enum IStreamSeekMode
  29. {
  30. kIBSeekSet = 0, ///< set absolute seek position
  31. kIBSeekCur, ///< set seek position relative to current position
  32. kIBSeekEnd ///< set seek position relative to stream end
  33. };
  34. //------------------------------------------------------------------------
  35. /** Reads binary data from stream.
  36. \param buffer : destination buffer
  37. \param numBytes : amount of bytes to be read
  38. \param numBytesRead : result - how many bytes have been read from stream (set to 0 if this is of no interest) */
  39. virtual tresult PLUGIN_API read (void* buffer, int32 numBytes, int32* numBytesRead = nullptr) = 0;
  40. /** Writes binary data to stream.
  41. \param buffer : source buffer
  42. \param numBytes : amount of bytes to write
  43. \param numBytesWritten : result - how many bytes have been written to stream (set to 0 if this is of no interest) */
  44. virtual tresult PLUGIN_API write (void* buffer, int32 numBytes, int32* numBytesWritten = nullptr) = 0;
  45. /** Sets stream read-write position.
  46. \param pos : new stream position (dependent on mode)
  47. \param mode : value of enum IStreamSeekMode
  48. \param result : new seek position (set to 0 if this is of no interest) */
  49. virtual tresult PLUGIN_API seek (int64 pos, int32 mode, int64* result = nullptr) = 0;
  50. /** Gets current stream read-write position.
  51. \param pos : is assigned the current position if function succeeds */
  52. virtual tresult PLUGIN_API tell (int64* pos) = 0;
  53. //------------------------------------------------------------------------
  54. static const FUID iid;
  55. };
  56. DECLARE_CLASS_IID (IBStream, 0xC3BF6EA2, 0x30994752, 0x9B6BF990, 0x1EE33E9B)
  57. //------------------------------------------------------------------------
  58. /** Stream with a size.
  59. \ingroup pluginBase
  60. [extends IBStream] when stream type supports it (like file and memory stream)
  61. */
  62. class ISizeableStream: public FUnknown
  63. {
  64. public:
  65. //------------------------------------------------------------------------
  66. /** Return the stream size */
  67. virtual tresult PLUGIN_API getStreamSize (int64& size) = 0;
  68. /** Set the steam size. File streams can only be resized if they are write enabled. */
  69. virtual tresult PLUGIN_API setStreamSize (int64 size) = 0;
  70. //------------------------------------------------------------------------
  71. static const FUID iid;
  72. };
  73. DECLARE_CLASS_IID (ISizeableStream, 0x04F9549E, 0xE02F4E6E, 0x87E86A87, 0x47F4E17F)
  74. //------------------------------------------------------------------------
  75. } // namespace Steinberg