openshot-audio  0.1.7
juce_MemoryOutputStream.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_MEMORYOUTPUTSTREAM_H_INCLUDED
30 #define JUCE_MEMORYOUTPUTSTREAM_H_INCLUDED
31 
32 
33 //==============================================================================
41 {
42 public:
43  //==============================================================================
47  MemoryOutputStream (size_t initialSize = 256);
48 
61  MemoryOutputStream (MemoryBlock& memoryBlockToWriteTo,
62  bool appendToExistingBlockContent);
63 
69  MemoryOutputStream (void* destBuffer, size_t destBufferSize);
70 
75 
76  //==============================================================================
80  const void* getData() const noexcept;
81 
85  size_t getDataSize() const noexcept { return size; }
86 
88  void reset() noexcept;
89 
93  void preallocate (size_t bytesToPreallocate);
94 
96  bool appendUTF8Char (juce_wchar character);
97 
99  String toUTF8() const;
100 
104  String toString() const;
105 
107  MemoryBlock getMemoryBlock() const;
108 
109  //==============================================================================
114  void flush() override;
115 
116  bool write (const void*, size_t) override;
117  int64 getPosition() override { return (int64) position; }
118  bool setPosition (int64) override;
119  int64 writeFromInputStream (InputStream&, int64 maxNumBytesToWrite) override;
120  bool writeRepeatedByte (uint8 byte, size_t numTimesToRepeat) override;
121 
122 private:
123  //==============================================================================
124  MemoryBlock* const blockToUse;
125  MemoryBlock internalBlock;
126  void* externalData;
127  size_t position, size, availableSize;
128 
129  void trimExternalBlockSize();
130  char* prepareToWrite (size_t);
131 
133 };
134 
137 
138 
139 #endif // JUCE_MEMORYOUTPUTSTREAM_H_INCLUDED
#define noexcept
Definition: juce_CompilerSupport.h:141
#define override
Definition: juce_CompilerSupport.h:156
Definition: juce_MemoryBlock.h:38
Definition: juce_InputStream.h:41
#define JUCE_CALLTYPE
Definition: juce_PlatformDefs.h:50
Definition: juce_String.h:43
#define JUCE_API
Definition: juce_StandardHeader.h:139
virtual bool writeRepeatedByte(uint8 byte, size_t numTimesToRepeat)
Definition: juce_OutputStream.cpp:80
#define const
OutputStream &JUCE_CALLTYPE operator<<(OutputStream &stream, const MemoryOutputStream &streamToRead)
Definition: juce_MemoryOutputStream.cpp:206
size_t getDataSize() const noexcept
Definition: juce_MemoryOutputStream.h:85
Definition: juce_OutputStream.h:42
long long int64
Definition: juce_MathsFunctions.h:60
#define JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(className)
Definition: juce_PlatformDefs.h:198
virtual int64 writeFromInputStream(InputStream &source, int64 maxNumBytesToWrite)
Definition: juce_OutputStream.cpp:255
Definition: juce_MemoryOutputStream.h:40
unsigned char uint8
Definition: juce_MathsFunctions.h:43
virtual bool setPosition(int64 newPosition)=0
wchar_t juce_wchar
Definition: juce_CharacterFunctions.h:49