Jamba C++ API  4.1.0
GUIParamSerializers.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018 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 #pragma once
19 
20 #include <vstgui4/vstgui/lib/cstring.h>
21 
22 #include <pongasoft/VST/ParamDef.h>
23 
24 namespace pongasoft {
25 namespace VST {
26 namespace GUI {
27 namespace Params {
28 
29 using namespace Steinberg;
30 using namespace VSTGUI;
31 
36 template<int size = 128>
37 class UTF8StringParamSerializer : public IParamSerializer<UTF8String>
38 {
39 public:
40  // readFromStream
41  inline tresult readFromStream(IBStreamer &iStreamer, ParamType &oValue) const override
42  {
43  char8 str[size];
44  iStreamer.readString8(str, size);
45  str[size - 1] = 0; // making sure it is null terminated....
46  oValue = UTF8String{str};
47  return kResultOk;
48  }
49 
50  // writeToStream
51  inline tresult writeToStream(const ParamType &iValue, IBStreamer &oStreamer) const override
52  {
53  oStreamer.writeString8(iValue, true);
54  return kResultOk;
55  }
56 
57  // writeToStream
58  void writeToStream(ParamType const &iValue, std::ostream &oStream) const override
59  {
60  oStream << iValue;
61  }
62 };
63 
64 }
65 }
66 }
67 }
A parameter backed by a UTF8String.
Definition: GUIParamSerializers.h:37
tresult readFromStream(IBStreamer &iStreamer, ParamType &oValue) const override
Definition: GUIParamSerializers.h:41
void writeToStream(ParamType const &iValue, std::ostream &oStream) const override
By default, this implementation simply writes the value to the stream IF it is possible (determined a...
Definition: GUIParamSerializers.h:58
Definition: Clock.h:22
tresult writeToStream(const ParamType &iValue, IBStreamer &oStreamer) const override
Definition: GUIParamSerializers.h:51
Definition: Types.h:29
A vst parameter is represented by a ParamValue type which is a double in the range [0,...
Definition: ParamSerializers.h:105
UTF8String ParamType
Definition: ParamSerializers.h:108