OpenShot Audio Library | OpenShotAudio 0.4.0

Loading...
Searching...
No Matches
juce_MemoryOutputStream.h
1/*
2 ==============================================================================
3
4 This file is part of the JUCE library.
5 Copyright (c) 2022 - Raw Material Software Limited
6
7 JUCE is an open source library subject to commercial or open-source
8 licensing.
9
10 The code included in this file is provided under the terms of the ISC license
11 http://www.isc.org/downloads/software-support-policy/isc-license. Permission
12 To use, copy, modify, and/or distribute this software for any purpose with or
13 without fee is hereby granted provided that the above copyright notice and
14 this permission notice appear in all copies.
15
16 JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
17 EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
18 DISCLAIMED.
19
20 ==============================================================================
21*/
22
23 namespace juce
24{
25
26//==============================================================================
35 class JUCE_API MemoryOutputStream : public OutputStream
36{
37 public:
38 //==============================================================================
42 MemoryOutputStream (size_t initialSize = 256);
43
56 MemoryOutputStream (MemoryBlock& memoryBlockToWriteTo,
57 bool appendToExistingBlockContent);
58
64 MemoryOutputStream (void* destBuffer, size_t destBufferSize);
65
69 ~MemoryOutputStream() override;
70
71 //==============================================================================
75 const void* getData() const noexcept;
76
80 size_t getDataSize() const noexcept { return size; }
81
83 void reset() noexcept;
84
88 void preallocate (size_t bytesToPreallocate);
89
91 bool appendUTF8Char (juce_wchar character);
92
94 String toUTF8() const;
95
99 String toString() const;
100
102 MemoryBlock getMemoryBlock() const;
103
104 //==============================================================================
109 void flush() override;
110
111 bool write (const void*, size_t) override;
112 int64 getPosition() override { return (int64) position; }
113 bool setPosition (int64) override;
114 int64 writeFromInputStream (InputStream&, int64 maxNumBytesToWrite) override;
115 bool writeRepeatedByte (uint8 byte, size_t numTimesToRepeat) override;
116
117 private:
118 //==============================================================================
119 MemoryBlock* const blockToUse = nullptr;
120 MemoryBlock internalBlock;
121 void* externalData = nullptr;
122 size_t position = 0, size = 0, availableSize = 0;
123
124 void trimExternalBlockSize();
125 char* prepareToWrite (size_t);
126
127 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MemoryOutputStream)
128};
129
131OutputStream& JUCE_CALLTYPE operator<< (OutputStream& stream, const MemoryOutputStream& streamToRead);
132
133} // namespace juce
juce::InputStream
Definition juce_InputStream.h:37
juce::MemoryBlock
Definition juce_MemoryBlock.h:33
juce::MemoryOutputStream
Definition juce_MemoryOutputStream.h:36
juce::MemoryOutputStream::getDataSize
size_t getDataSize() const noexcept
Definition juce_MemoryOutputStream.h:80
juce::OutputStream
Definition juce_OutputStream.h:38
juce::String
Definition juce_String.h:53