openshot-audio  0.1.2
juce_MemoryBlock.h
Go to the documentation of this file.
1 /*
2  ==============================================================================
3 
4  This file is part of the juce_core module of the JUCE library.
5  Copyright (c) 2015 - ROLI Ltd.
6 
7  Permission to use, copy, modify, and/or distribute this software for any purpose with
8  or without fee is hereby granted, provided that the above copyright notice and this
9  permission notice appear in all copies.
10 
11  THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
12  TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
13  NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
14  DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
15  IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
16  CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 
18  ------------------------------------------------------------------------------
19 
20  NOTE! This permissive ISC license applies ONLY to files within the juce_core module!
21  All other JUCE modules are covered by a dual GPL/commercial license, so if you are
22  using any other modules, be sure to check that you also comply with their license.
23 
24  For more details, visit www.juce.com
25 
26  ==============================================================================
27 */
28 
29 #ifndef JUCE_MEMORYBLOCK_H_INCLUDED
30 #define JUCE_MEMORYBLOCK_H_INCLUDED
31 
32 
33 //==============================================================================
39 {
40 public:
41  //==============================================================================
44 
50  MemoryBlock (const size_t initialSize,
51  bool initialiseToZero = false);
52 
54  MemoryBlock (const MemoryBlock&);
55 
61  MemoryBlock (const void* dataToInitialiseFrom, size_t sizeInBytes);
62 
65 
69  MemoryBlock& operator= (const MemoryBlock&);
70 
71  #if JUCE_COMPILER_SUPPORTS_MOVE_SEMANTICS
73  MemoryBlock& operator= (MemoryBlock&&) noexcept;
74  #endif
75 
76  //==============================================================================
80  bool operator== (const MemoryBlock& other) const noexcept;
81 
85  bool operator!= (const MemoryBlock& other) const noexcept;
86 
88  bool matches (const void* data, size_t dataSize) const noexcept;
89 
90  //==============================================================================
96  void* getData() const noexcept { return data; }
97 
101  template <typename Type>
102  char& operator[] (const Type offset) const noexcept { return data [offset]; }
103 
104 
105  //==============================================================================
107  size_t getSize() const noexcept { return size; }
108 
121  void setSize (const size_t newSize,
122  bool initialiseNewSpaceToZero = false);
123 
133  void ensureSize (const size_t minimumSize,
134  bool initialiseNewSpaceToZero = false);
135 
137  void reset();
138 
139  //==============================================================================
143  void fillWith (uint8 valueToUse) noexcept;
144 
148  void append (const void* data, size_t numBytes);
149 
153  void replaceWith (const void* data, size_t numBytes);
154 
160  void insert (const void* dataToInsert, size_t numBytesToInsert, size_t insertPosition);
161 
169  void removeSection (size_t startByte, size_t numBytesToRemove);
170 
171  //==============================================================================
179  void copyFrom (const void* srcData,
180  int destinationOffset,
181  size_t numBytes) noexcept;
182 
190  void copyTo (void* destData,
191  int sourceOffset,
192  size_t numBytes) const noexcept;
193 
194  //==============================================================================
198  void swapWith (MemoryBlock& other) noexcept;
199 
200  //==============================================================================
202  String toString() const;
203 
204  //==============================================================================
212  void loadFromHexString (StringRef sourceHexString);
213 
214  //==============================================================================
216  void setBitRange (size_t bitRangeStart,
217  size_t numBits,
218  int binaryNumberToApply) noexcept;
219 
221  int getBitRange (size_t bitRangeStart,
222  size_t numBitsToRead) const noexcept;
223 
224  //==============================================================================
232  String toBase64Encoding() const;
233 
241  bool fromBase64Encoding (StringRef encodedString);
242 
243 
244 private:
245  //==============================================================================
247  size_t size;
248 
250 };
251 
252 
253 #endif // JUCE_MEMORYBLOCK_H_INCLUDED
size_t getSize() const noexcept
Definition: juce_MemoryBlock.h:107
#define noexcept
Definition: juce_CompilerSupport.h:141
Definition: juce_MemoryBlock.h:38
Definition: juce_String.h:43
#define JUCE_API
Definition: juce_StandardHeader.h:139
#define const
void * getData() const noexcept
Definition: juce_MemoryBlock.h:96
bool operator==(const var &v1, const var &v2) noexcept
Definition: juce_Variant.cpp:565
Definition: juce_HeapBlock.h:90
JSAMPIMAGE data
Definition: jpeglib.h:945
#define JUCE_LEAK_DETECTOR(OwnerClass)
Definition: juce_LeakedObjectDetector.h:141
bool operator!=(const var &v1, const var &v2) noexcept
Definition: juce_Variant.cpp:566
unsigned char uint8
Definition: juce_MathsFunctions.h:43
Definition: juce_StringRef.h:65