90 const std::vector<TweakParam>& params);
96std::optional<RewriteResult>
set_edit_param(std::string_view text, std::string_view key,
97 std::string_view json_value);
Definition design_adherence.hpp:32
std::optional< RewriteResult > rewrite_edit_block(std::string_view text, const std::vector< TweakParam > ¶ms)
Rewrite text's edit block so its payload encodes params, preserving every byte outside the marker spa...
constexpr std::string_view kEditBlockBegin
The exact opening and closing markers that anchor the block.
Definition design_tweaks.hpp:35
std::optional< EditBlockSpan > find_edit_block(std::string_view text)
Locate the first edit block in text.
std::optional< std::string > edit_block_payload(const std::vector< TweakParam > ¶ms)
Serialize parameters to the canonical single-line block payload (no outer markers): {"k1":v1,...
std::optional< std::vector< TweakParam > > read_edit_block(std::string_view text)
Parse the parameters out of text's edit block.
std::optional< RewriteResult > set_edit_param(std::string_view text, std::string_view key, std::string_view json_value)
Apply a single key=value change to text's block: update the key in place if present,...
constexpr std::string_view kEditBlockEnd
Definition design_tweaks.hpp:36
Where the block sits in the host text, as byte offsets.
Definition design_tweaks.hpp:50
size_t block_end
offset one past the last byte of kEditBlockEnd
Definition design_tweaks.hpp:52
size_t payload_begin
offset of the first byte of the JSON payload
Definition design_tweaks.hpp:53
size_t payload_end
offset one past the last byte of the JSON payload
Definition design_tweaks.hpp:54
size_t block_begin
offset of the first byte of kEditBlockBegin
Definition design_tweaks.hpp:51
Result of a rewrite: the new full artifact text plus whether anything outside the block changed (it m...
Definition design_tweaks.hpp:80
std::string text
the artifact with the block's payload replaced
Definition design_tweaks.hpp:81
bool outside_bytes_intact
true iff every byte outside the block is unchanged
Definition design_tweaks.hpp:82
One parameter in the block: a key and its JSON-encoded value.
Definition design_tweaks.hpp:42
std::string key
Definition design_tweaks.hpp:43
std::string json_value
the value's JSON text, exactly as it will serialize
Definition design_tweaks.hpp:44