Jamba C++ API 7.5.0
Loading...
Searching...
No Matches
FastWriteMemoryStream.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2020 pongasoft
3 *
4 * Licensed under the Apache License, Version 2.0 or the MIT license,
5 * at your option. You may not use this file except in compliance with
6 * one of these licenses. You may obtain copies of the licenses at:
7 *
8 * https://www.apache.org/licenses/LICENSE-2.0
9 * https://opensource.org/licenses/MIT
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14 * License for the specific language governing permissions and limitations under
15 * the License.
16 *
17 * @author Yan Pujante
18 */
19
20#ifndef JAMBA_FASTWRITEMEMORYSTREAM_H
21#define JAMBA_FASTWRITEMEMORYSTREAM_H
22
23#include <pluginterfaces/base/ibstream.h>
24
26
27using namespace Steinberg;
28
42class FastWriteMemoryStream : public IBStream
43{
44public:
45 //------------------------------------------------------------------------
47
48 virtual ~FastWriteMemoryStream();
49
50 //---IBStream---------------------------------------
51 virtual tresult PLUGIN_API read(void *buffer, int32 numBytes, int32 *numBytesRead) SMTG_OVERRIDE;
52 virtual tresult PLUGIN_API write(void *buffer, int32 numBytes, int32 *numBytesWritten) SMTG_OVERRIDE;
53 virtual tresult PLUGIN_API seek(int64 pos, int32 mode, int64 *result) SMTG_OVERRIDE;
54 virtual tresult PLUGIN_API tell(int64 *pos) SMTG_OVERRIDE;
55
56 TSize getSize() const { return size; };
57 void setSize(TSize size);
58 void reset();
59 inline void clear() { setSize(0); }
60 inline char const* getData() const { return memory; }
61 inline int64 pos() const { return cursor; }
62
63 //------------------------------------------------------------------------
64DECLARE_FUNKNOWN_METHODS
65protected:
66 char *memory; // memory block
67 TSize memorySize; // size of the memory block
68 TSize size; // size of the stream
69 int64 cursor; // stream pointer
70 bool allocationError; // stream invalid
71};
72
73}
74
75
76#endif //JAMBA_FASTWRITEMEMORYSTREAM_H
void setSize(TSize size)
returns the current memory size
Definition FastWriteMemoryStream.cpp:167
virtual tresult PLUGIN_API seek(int64 pos, int32 mode, int64 *result) SMTG_OVERRIDE
Definition FastWriteMemoryStream.cpp:129
bool allocationError
Definition FastWriteMemoryStream.h:70
TSize memorySize
Definition FastWriteMemoryStream.h:67
char * memory
Definition FastWriteMemoryStream.h:66
TSize getSize() const
Definition FastWriteMemoryStream.h:56
FastWriteMemoryStream()
Definition FastWriteMemoryStream.cpp:32
int64 cursor
Definition FastWriteMemoryStream.h:69
virtual tresult PLUGIN_API write(void *buffer, int32 numBytes, int32 *numBytesWritten) SMTG_OVERRIDE
Definition FastWriteMemoryStream.cpp:93
virtual tresult PLUGIN_API tell(int64 *pos) SMTG_OVERRIDE
Definition FastWriteMemoryStream.cpp:155
virtual tresult PLUGIN_API read(void *buffer, int32 numBytes, int32 *numBytesRead) SMTG_OVERRIDE
Definition FastWriteMemoryStream.cpp:52
char const * getData() const
Definition FastWriteMemoryStream.h:60
TSize size
Definition FastWriteMemoryStream.h:68
virtual ~FastWriteMemoryStream()
Definition FastWriteMemoryStream.cpp:41
void clear()
Definition FastWriteMemoryStream.h:59
void reset()
Definition FastWriteMemoryStream.cpp:228
int64 pos() const
Definition FastWriteMemoryStream.h:61
Definition ExpiringDataCache.h:28