Jamba C++ API  6.0.0
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 (the "License"); you may not
5  * use this file except in compliance with the License. You may obtain a copy of
6  * the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13  * License for the specific language governing permissions and limitations under
14  * the License.
15  *
16  * @author Yan Pujante
17  */
18 
19 #ifndef JAMBA_FASTWRITEMEMORYSTREAM_H
20 #define JAMBA_FASTWRITEMEMORYSTREAM_H
21 
22 #include <pluginterfaces/base/ibstream.h>
23 
24 namespace pongasoft::VST::VstUtils {
25 
26 using namespace Steinberg;
27 
41 class FastWriteMemoryStream : public IBStream
42 {
43 public:
44  //------------------------------------------------------------------------
46 
47  virtual ~FastWriteMemoryStream();
48 
49  //---IBStream---------------------------------------
50  virtual tresult PLUGIN_API read(void *buffer, int32 numBytes, int32 *numBytesRead) SMTG_OVERRIDE;
51  virtual tresult PLUGIN_API write(void *buffer, int32 numBytes, int32 *numBytesWritten) SMTG_OVERRIDE;
52  virtual tresult PLUGIN_API seek(int64 pos, int32 mode, int64 *result) SMTG_OVERRIDE;
53  virtual tresult PLUGIN_API tell(int64 *pos) SMTG_OVERRIDE;
54 
55  TSize getSize() const { return size; };
56  void setSize(TSize size);
57  void reset();
58  inline void clear() { setSize(0); }
59  inline char const* getData() const { return memory; }
60  inline int64 pos() const { return cursor; }
61 
62  //------------------------------------------------------------------------
63 DECLARE_FUNKNOWN_METHODS
64 protected:
65  char *memory; // memory block
66  TSize memorySize; // size of the memory block
67  TSize size; // size of the stream
68  int64 cursor; // stream pointer
69  bool allocationError; // stream invalid
70 };
71 
72 }
73 
74 
75 #endif //JAMBA_FASTWRITEMEMORYSTREAM_H
TSize memorySize
Definition: FastWriteMemoryStream.h:66
int64 pos() const
Definition: FastWriteMemoryStream.h:60
Definition: ExpiringDataCache.h:27
This class is a copy of MemoryStream for the purpose of fixing the growing issue encountered on Windo...
Definition: FastWriteMemoryStream.h:41
char const * getData() const
Definition: FastWriteMemoryStream.h:59
char * memory
Definition: FastWriteMemoryStream.h:65
int64 cursor
Definition: FastWriteMemoryStream.h:68
void clear()
Definition: FastWriteMemoryStream.h:58
TSize size
Definition: FastWriteMemoryStream.h:67
bool allocationError
Definition: FastWriteMemoryStream.h:69
TSize getSize() const
Definition: FastWriteMemoryStream.h:55