// param_format.h — ONE formatter per unit category, and the editor and the host are both its
// callers. It returns the DIGITS of a plain value: no embedded unit, no magnitude-switched unit,
// no width-conditional abbreviation. The editor's knob label adds its own static chrome (the
// unit suffix, a curve dial's "^"); the host receives these digits from getParamStringByValue and
// the unit from ParameterInfo::units. There is no second implementation on either side — the two
// surfaces disagreeing about what a value reads as is a defect class this closes structurally.

#pragma once

#include <cstddef>

#include "core/instrument/param/param_units.h"

namespace reasampler::instrument::param {

// Writes at most `len` bytes including the terminator.
void formatPlain(UnitKind kind, double plain, char* buf, std::size_t len);

// The digits a control reads as at `plain`. Convenience over formatPlain for the common case.
void formatPlainFor(DeckParam deck, double plain, char* buf, std::size_t len);

// Digits -> plain, for getParamValueByString. False when the text carries no number; a trailing
// unit suffix is tolerated, since a user retyping a displayed value keeps it.
bool parsePlain(UnitKind kind, const char* text, double& plain);

}  // namespace reasampler::instrument::param
