OpenShot Audio Library | OpenShotAudio 0.3.2

Loading...
Searching...
No Matches
juce_MemoryBlock.h
1/*
2 ==============================================================================
3
4 This file is part of the JUCE library.
5 Copyright (c) 2017 - ROLI Ltd.
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//==============================================================================
32 class JUCE_API MemoryBlock
33{
34 public:
35 //==============================================================================
37 MemoryBlock() noexcept;
38
44 MemoryBlock (const size_t initialSize,
45 bool initialiseToZero = false);
46
48 MemoryBlock (const MemoryBlock&);
49
55 MemoryBlock (const void* dataToInitialiseFrom, size_t sizeInBytes);
56
58 ~MemoryBlock() noexcept;
59
63 MemoryBlock& operator= (const MemoryBlock&);
64
66 MemoryBlock (MemoryBlock&&) noexcept;
67
69 MemoryBlock& operator= (MemoryBlock&&) noexcept;
70
71 //==============================================================================
75 bool operator== (const MemoryBlock& other) const noexcept;
76
80 bool operator!= (const MemoryBlock& other) const noexcept;
81
83 bool matches (const void* data, size_t dataSize) const noexcept;
84
85 //==============================================================================
91 void* getData() noexcept { return data; }
92
98 const void* getData() const noexcept { return data; }
99
103 template <typename Type>
104 char& operator[] (const Type offset) noexcept { return data [offset]; }
105
107 template <typename Type>
108 const char& operator[] (const Type offset) const noexcept { return data [offset]; }
109
111 char* begin() noexcept { return data; }
112
114 const char* begin() const noexcept { return data; }
115
117 char* end() noexcept { return begin() + getSize(); }
118
120 const char* end() const noexcept { return begin() + getSize(); }
121
122 //==============================================================================
124 size_t getSize() const noexcept { return size; }
125
138 void setSize (const size_t newSize,
139 bool initialiseNewSpaceToZero = false);
140
150 void ensureSize (const size_t minimumSize,
151 bool initialiseNewSpaceToZero = false);
152
154 void reset();
155
156 //==============================================================================
160 void fillWith (uint8 valueToUse) noexcept;
161
165 void append (const void* data, size_t numBytes);
166
170 void replaceWith (const void* data, size_t numBytes);
171
177 void insert (const void* dataToInsert, size_t numBytesToInsert, size_t insertPosition);
178
186 void removeSection (size_t startByte, size_t numBytesToRemove);
187
188 //==============================================================================
196 void copyFrom (const void* srcData,
197 int destinationOffset,
198 size_t numBytes) noexcept;
199
207 void copyTo (void* destData,
208 int sourceOffset,
209 size_t numBytes) const noexcept;
210
211 //==============================================================================
215 void swapWith (MemoryBlock& other) noexcept;
216
217 //==============================================================================
219 String toString() const;
220
221 //==============================================================================
229 void loadFromHexString (StringRef sourceHexString);
230
231 //==============================================================================
233 void setBitRange (size_t bitRangeStart,
234 size_t numBits,
235 int binaryNumberToApply) noexcept;
236
238 int getBitRange (size_t bitRangeStart,
239 size_t numBitsToRead) const noexcept;
240
241 //==============================================================================
253 String toBase64Encoding() const;
254
266 bool fromBase64Encoding (StringRef encodedString);
267
268
269 private:
270 //==============================================================================
271 using HeapBlockType = HeapBlock<char, true>;
272 HeapBlockType data;
273 size_t size = 0;
274
275 JUCE_LEAK_DETECTOR (MemoryBlock)
276};
277
278} // namespace juce
juce::HeapBlock
Definition: juce_HeapBlock.h:87
juce::MemoryBlock
Definition: juce_MemoryBlock.h:33
juce::MemoryBlock::end
const char * end() const noexcept
Definition: juce_MemoryBlock.h:120
juce::MemoryBlock::begin
const char * begin() const noexcept
Definition: juce_MemoryBlock.h:114
juce::MemoryBlock::end
char * end() noexcept
Definition: juce_MemoryBlock.h:117
juce::MemoryBlock::getData
void * getData() noexcept
Definition: juce_MemoryBlock.h:91
juce::MemoryBlock::getSize
size_t getSize() const noexcept
Definition: juce_MemoryBlock.h:124
juce::MemoryBlock::getData
const void * getData() const noexcept
Definition: juce_MemoryBlock.h:98
juce::MemoryBlock::begin
char * begin() noexcept
Definition: juce_MemoryBlock.h:111
juce::StringRef
Definition: juce_StringRef.h:62
juce::String
Definition: juce_String.h:39