3 * Copyright (C) 2012-2023 Filipe Coelho <falktx@falktx.com>
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; either version 2 of
8 * the License, or any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * For a full copy of the GNU General Public License see the doc/GPL.txt file.
18 #ifndef CARLA_STATE_UTILS_HPP_INCLUDED
19 #define CARLA_STATE_UTILS_HPP_INCLUDED
21 #include "CarlaBackend.h"
22 #include "LinkedList.hpp"
24 #include "water/text/String.h"
26 CARLA_BACKEND_START_NAMESPACE
28 // -----------------------------------------------------------------------
30 struct CarlaStateSave
{
32 bool dummy
; // if true only midiChannel/CC are used
37 #ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH
38 int16_t mappedControlIndex
;
40 bool mappedRangeValid
;
46 ~Parameter() noexcept
;
48 CARLA_DECLARE_NON_COPYABLE(Parameter
)
51 typedef LinkedList
<Parameter
*> ParameterList
;
52 typedef LinkedList
<Parameter
*>::Itenerator ParameterItenerator
;
59 CustomData() noexcept
;
60 ~CustomData() noexcept
;
61 bool isValid() const noexcept
;
63 CARLA_DECLARE_NON_COPYABLE(CustomData
)
66 typedef LinkedList
<CustomData
*> CustomDataList
;
67 typedef LinkedList
<CustomData
*>::Itenerator CustomDataItenerator
;
76 // saved during clone, rename or similar
79 #ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH
89 int32_t currentProgramIndex
;
90 const char* currentProgramName
;
91 int32_t currentMidiBank
;
92 int32_t currentMidiProgram
;
95 ParameterList parameters
;
96 CustomDataList customData
;
98 CarlaStateSave() noexcept
;
99 ~CarlaStateSave() noexcept
;
100 void clear() noexcept
;
102 bool fillFromXmlElement(const water::XmlElement
* const xmlElement
);
103 void dumpToMemoryStream(water::MemoryOutputStream
& stream
) const;
105 CARLA_DECLARE_NON_COPYABLE(CarlaStateSave
)
109 water::String
xmlSafeString(const char* const cstring
, const bool toXml
)
111 water::String newString
= water::String(water::CharPointer_UTF8(cstring
));
114 return newString
.replace("&","&").replace("<","<").replace(">",">").replace("'","'").replace("\"",""");
116 return newString
.replace("<","<").replace(">",">").replace("'","'").replace(""","\"").replace("&","&");
120 water::String
xmlSafeString(const water::String
& string
, const bool toXml
)
122 water::String
newString(string
);
125 return newString
.replace("&","&").replace("<","<").replace(">",">").replace("'","'").replace("\"",""");
127 return newString
.replace("<","<").replace(">",">").replace("'","'").replace(""","\"").replace("&","&");
130 // -----------------------------------------------------------------------
132 CARLA_BACKEND_END_NAMESPACE
134 #endif // CARLA_STATE_UTILS_HPP_INCLUDED