JUCE-7.0.12-0-g4f43011b96 JUCE-7.0.12-0-g4f43011b96
JUCE — C++ application framework with suport for VST, VST3, LV2 audio plug-ins

« « « Anklang Documentation
Loading...
Searching...
No Matches
juce_MemoryOutputStream.h
Go to the documentation of this file.
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
23namespace juce
24{
25
26//==============================================================================
35class JUCE_API MemoryOutputStream : public OutputStream
36{
37public:
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
117private:
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
128};
129
131OutputStream& JUCE_CALLTYPE operator<< (OutputStream& stream, const MemoryOutputStream& streamToRead);
132
133} // namespace juce
The base class for streams that read data.
A class to hold a resizable block of raw data.
Writes data to an internal memory buffer, which grows as required.
size_t getDataSize() const noexcept
Returns the number of bytes of data that have been written to the stream.
The base class for streams that write data to some kind of destination.
The JUCE String class!
Definition juce_String.h:53
#define JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(className)
This is a shorthand way of writing both a JUCE_DECLARE_NON_COPYABLE and JUCE_LEAK_DETECTOR macro for ...
#define JUCE_CALLTYPE
This macro defines the C calling convention used as the standard for JUCE calls.
JUCE Namespace.
wchar_t juce_wchar
A platform-independent 32-bit unicode character type.
OutputStream &JUCE_CALLTYPE operator<<(OutputStream &stream, const BigInteger &value)
Writes a BigInteger to an OutputStream as a UTF8 decimal string.
Type unalignedPointerCast(void *ptr) noexcept
Casts a pointer to another type via void*, which suppresses the cast-align warning which sometimes ar...
Definition juce_Memory.h:88
unsigned char uint8
A platform-independent 8-bit unsigned integer type.
long long int64
A platform-independent 64-bit integer type.