DSPark 1.6.1
Header-only audio DSP framework in pure C++20 — zero dependencies
Loading...
Searching...
No Matches
dspark::StateReader Class Reference

Tolerant reader: missing keys yield defaults, unknown keys are skipped. More...

#include <StateBlob.h>

Classes

struct  Entry
 Access for generic tooling (JSON rendering, preset browsers). More...
 

Public Member Functions

 StateReader (const uint8_t *data, size_t size)
 
bool isValid () const noexcept
 
uint32_t processorId () const noexcept
 
uint16_t processorVersion () const noexcept
 
float read (const char *key, float defaultValue) const
 Reads a float, or defaultValue when the key is absent.
 
int32_t read (const char *key, int32_t defaultValue) const
 Reads an int32, or defaultValue when the key is absent.
 
bool read (const char *key, bool defaultValue) const
 Reads a bool, or defaultValue when the key is absent.
 
std::vector< uint8_t > readBlob (const char *key) const
 Reads a nested blob; empty when the key is absent.
 
const std::vector< Entry > & entries () const noexcept
 

Detailed Description

Tolerant reader: missing keys yield defaults, unknown keys are skipped.

A truncated or corrupt blob parses as far as it stays consistent: entries decoded before the damage remain readable, and isValid() reports whether the FULL blob parsed. Bounds are checked entry by entry, so no input can read outside [data, data+size).

Definition at line 159 of file StateBlob.h.

Constructor & Destructor Documentation

◆ StateReader()

dspark::StateReader::StateReader ( const uint8_t *  data,
size_t  size 
)
inline

Definition at line 162 of file StateBlob.h.

Member Function Documentation

◆ entries()

const std::vector< Entry > & dspark::StateReader::entries ( ) const
inlinenoexcept

Definition at line 246 of file StateBlob.h.

◆ isValid()

bool dspark::StateReader::isValid ( ) const
inlinenoexcept

Definition at line 198 of file StateBlob.h.

◆ processorId()

uint32_t dspark::StateReader::processorId ( ) const
inlinenoexcept

Definition at line 199 of file StateBlob.h.

◆ processorVersion()

uint16_t dspark::StateReader::processorVersion ( ) const
inlinenoexcept

Definition at line 200 of file StateBlob.h.

◆ read() [1/3]

bool dspark::StateReader::read ( const char *  key,
bool  defaultValue 
) const
inline

Reads a bool, or defaultValue when the key is absent.

Definition at line 223 of file StateBlob.h.

◆ read() [2/3]

float dspark::StateReader::read ( const char *  key,
float  defaultValue 
) const
inline

Reads a float, or defaultValue when the key is absent.

Definition at line 203 of file StateBlob.h.

◆ read() [3/3]

int32_t dspark::StateReader::read ( const char *  key,
int32_t  defaultValue 
) const
inline

Reads an int32, or defaultValue when the key is absent.

Definition at line 215 of file StateBlob.h.

◆ readBlob()

std::vector< uint8_t > dspark::StateReader::readBlob ( const char *  key) const
inline

Reads a nested blob; empty when the key is absent.

Definition at line 231 of file StateBlob.h.


The documentation for this class was generated from the following file: