MCPcopy Create free account
hub / github.com/DISTRHO/DPF / getState

Function getState

distrho/src/DistrhoPluginVST3.cpp:1169–1275  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1167 }
1168
1169 v3_result getState(v3_bstream** const stream)
1170 {
1171 const uint32_t paramCount = fPlugin.getParameterCount();
1172 #if DISTRHO_PLUGIN_WANT_STATE
1173 const uint32_t stateCount = fPlugin.getStateCount();
1174 #else
1175 constexpr const uint32_t stateCount = 0;
1176 #endif
1177
1178 if (stateCount == 0 && paramCount == 0)
1179 {
1180 char buffer = '\0';
1181 int32_t ignored;
1182 return v3_cpp_obj(stream)->write(stream, &buffer, 1, &ignored);
1183 }
1184
1185 #if DISTRHO_PLUGIN_WANT_FULL_STATE
1186 // Update current state
1187 for (StringMap::const_iterator cit=fStateMap.begin(), cite=fStateMap.end(); cit != cite; ++cit)
1188 {
1189 const String& key(cit->first);
1190 fStateMap[key] = fPlugin.getStateValue(key);
1191 }
1192 #endif
1193
1194 String state;
1195
1196 #if DISTRHO_PLUGIN_WANT_PROGRAMS
1197 {
1198 String tmpStr("__dpf_program__\xff");
1199 tmpStr += String(fCurrentProgram);
1200 tmpStr += "\xff";
1201
1202 state += tmpStr;
1203 }
1204 #endif
1205
1206 #if DISTRHO_PLUGIN_WANT_STATE
1207 if (stateCount != 0)
1208 {
1209 state += "__dpf_state_begin__\xff";
1210
1211 for (StringMap::const_iterator cit=fStateMap.begin(), cite=fStateMap.end(); cit != cite; ++cit)
1212 {
1213 const String& key(cit->first);
1214 const String& value(cit->second);
1215
1216 // join key and value
1217 String tmpStr;
1218 tmpStr = key;
1219 tmpStr += "\xff";
1220 tmpStr += value;
1221 tmpStr += "\xff";
1222
1223 state += tmpStr;
1224 }
1225
1226 state += "__dpf_state_end__\xff";

Callers 1

onDisplayMethod · 0.50

Calls 6

StringFunction · 0.85
d_roundToIntFunction · 0.85
writeMethod · 0.80
v3_cpp_objFunction · 0.50
getParameterCountMethod · 0.45
getParameterValueMethod · 0.45

Tested by

no test coverage detected