| 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 | } |
no test coverage detected