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

Method stateSave

distrho/src/DistrhoPluginCLAP.cpp:1456–1557  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1454 // state
1455
1456 bool stateSave(const clap_ostream_t* const stream)
1457 {
1458 const uint32_t paramCount = fPlugin.getParameterCount();
1459 #if DISTRHO_PLUGIN_WANT_STATE
1460 const uint32_t stateCount = fPlugin.getStateCount();
1461 #else
1462 const uint32_t stateCount = 0;
1463 #endif
1464
1465 if (stateCount == 0 && paramCount == 0)
1466 {
1467 char buffer = '\0';
1468 return stream->write(stream, &buffer, 1) == 1;
1469 }
1470
1471 #if DISTRHO_PLUGIN_WANT_FULL_STATE
1472 // Update current state
1473 for (StringMap::const_iterator cit=fStateMap.begin(), cite=fStateMap.end(); cit != cite; ++cit)
1474 {
1475 const String& key(cit->first);
1476 fStateMap[key] = fPlugin.getStateValue(key);
1477 }
1478 #endif
1479
1480 String state;
1481
1482 #if DISTRHO_PLUGIN_WANT_PROGRAMS
1483 {
1484 String tmpStr("__dpf_program__\xff");
1485 tmpStr += String(fCurrentProgram);
1486 tmpStr += "\xff";
1487
1488 state += tmpStr;
1489 }
1490 #endif
1491
1492 #if DISTRHO_PLUGIN_WANT_STATE
1493 if (stateCount != 0)
1494 {
1495 state += "__dpf_state_begin__\xff";
1496
1497 for (StringMap::const_iterator cit=fStateMap.begin(), cite=fStateMap.end(); cit != cite; ++cit)
1498 {
1499 const String& key(cit->first);
1500 const String& value(cit->second);
1501
1502 // join key and value
1503 String tmpStr;
1504 tmpStr = key;
1505 tmpStr += "\xff";
1506 tmpStr += value;
1507 tmpStr += "\xff";
1508
1509 state += tmpStr;
1510 }
1511
1512 state += "__dpf_state_end__\xff";
1513 }

Callers 1

clap_plugin_state_saveFunction · 0.80

Calls 5

StringFunction · 0.85
roundFunction · 0.85
writeMethod · 0.80
getParameterCountMethod · 0.45
getParameterValueMethod · 0.45

Tested by

no test coverage detected