Jamba C++ API 7.5.0
Loading...
Searching...
No Matches
ReadOnlyMemoryStream.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_READONLYMEMORYSTREAM_H
21#define JAMBA_READONLYMEMORYSTREAM_H
22
23#include <pluginterfaces/base/ibstream.h>
24
26
27using namespace Steinberg;
28
29class ReadOnlyMemoryStream : public IBStream
30{
31public:
33 ReadOnlyMemoryStream(char const *iMemory, TSize iMemorySize);
34
35 virtual ~ReadOnlyMemoryStream() = default;
36
37 //---IBStream---------------------------------------
38 virtual tresult PLUGIN_API read(void *buffer, int32 numBytes, int32 *numBytesRead) SMTG_OVERRIDE;
39 virtual tresult PLUGIN_API write(void *buffer, int32 numBytes, int32 *numBytesWritten) SMTG_OVERRIDE;
40 virtual tresult PLUGIN_API seek(int64 pos, int32 mode, int64 *result) SMTG_OVERRIDE;
41 virtual tresult PLUGIN_API tell(int64 *pos) SMTG_OVERRIDE;
42
43 TSize getSize() const { return fMemorySize - fPos; };
44 inline char const* getData() const { return fMemory; }
45 TSize getMemorySize() const { return fMemorySize; };
46 inline int64 pos() const { return fPos; }
47
48 //------------------------------------------------------------------------
49DECLARE_FUNKNOWN_METHODS
50
51protected:
52 char const *fMemory; // memory block
53 TSize fMemorySize; // size of the memory block
54 int64 fPos; // stream pointer
55};
56
57}
58
59#endif //JAMBA_READONLYMEMORYSTREAM_H
TSize fMemorySize
Definition ReadOnlyMemoryStream.h:53
ReadOnlyMemoryStream(char const *iMemory, TSize iMemorySize)
Constructor.
Definition ReadOnlyMemoryStream.cpp:30
TSize getSize() const
Definition ReadOnlyMemoryStream.h:43
int64 fPos
Definition ReadOnlyMemoryStream.h:54
TSize getMemorySize() const
Definition ReadOnlyMemoryStream.h:45
virtual tresult PLUGIN_API tell(int64 *pos) SMTG_OVERRIDE
Definition ReadOnlyMemoryStream.cpp:114
char const * getData() const
returns the current memory size (how many chars can be read until the end)
Definition ReadOnlyMemoryStream.h:44
virtual tresult PLUGIN_API seek(int64 pos, int32 mode, int64 *result) SMTG_OVERRIDE
Definition ReadOnlyMemoryStream.cpp:88
char const * fMemory
Definition ReadOnlyMemoryStream.h:52
int64 pos() const
returns the total size of the memory
Definition ReadOnlyMemoryStream.h:46
virtual tresult PLUGIN_API write(void *buffer, int32 numBytes, int32 *numBytesWritten) SMTG_OVERRIDE
Definition ReadOnlyMemoryStream.cpp:79
virtual tresult PLUGIN_API read(void *buffer, int32 numBytes, int32 *numBytesRead) SMTG_OVERRIDE
Definition ReadOnlyMemoryStream.cpp:40
Definition ExpiringDataCache.h:28