dasmig-core 1.2.0
Shared random engine, distributions and data tiers for the dasmig generator libraries
Loading...
Searching...
No Matches
dasmig::core::seed_signature Struct Reference

What a result needs to be generated again: its call seed and the data it was generated from. More...

#include <seed_signature.hpp>

Public Member Functions

std::string to_string () const
 The text form.
 
void to_json (json_writer &w) const
 Write as a JSON object {"seed":"…","data":"…"}.
 

Static Public Member Functions

static seed_signature parse (std::string_view text)
 Parse the text form. A lone seed (16 hex digits) is accepted with data 0.
 

Public Attributes

std::uint64_t seed {0}
 The call seed.
 
std::uint64_t data {0}
 Hash of the data used; 0 when not recorded.
 

Friends

constexpr bool operator== (const seed_signature &, const seed_signature &) noexcept=default
 Signatures are equal when seed and data are equal.
 

Detailed Description

What a result needs to be generated again: its call seed and the data it was generated from.

data is the layered_table::data_hash() (or a combination of several) of the data loaded when the result was made; 0 means "not recorded". A seed replays the same result only against the same data, so a replay can compare data and report a mismatch instead of returning a different result silently.

The text form is <seed>-<data>, each 16 lowercase hex digits, for example 00000000000004d2-9ae16a3b2f90404f. In JSON both parts are strings, because JavaScript numbers cannot hold every 64-bit value.

Definition at line 39 of file seed_signature.hpp.

Member Function Documentation

◆ parse()

static seed_signature dasmig::core::seed_signature::parse ( std::string_view  text)
inlinestatic

Parse the text form. A lone seed (16 hex digits) is accepted with data 0.

Parameters
text<seed>-<data> or <seed>.
Returns
The signature.
Exceptions
std::invalid_argumentIf text is not in that form.

Definition at line 56 of file seed_signature.hpp.

◆ to_json()

void dasmig::core::seed_signature::to_json ( json_writer &  w) const
inline

Write as a JSON object {"seed":"…","data":"…"}.

Parameters
wWriter positioned where a value is allowed.

Definition at line 73 of file seed_signature.hpp.

◆ to_string()

std::string dasmig::core::seed_signature::to_string ( ) const
inline

The text form.

Returns
<seed>-<data> in 16-digit lowercase hex.

Definition at line 46 of file seed_signature.hpp.

Member Data Documentation

◆ data

std::uint64_t dasmig::core::seed_signature::data {0}

Hash of the data used; 0 when not recorded.

Definition at line 42 of file seed_signature.hpp.

◆ seed

std::uint64_t dasmig::core::seed_signature::seed {0}

The call seed.

Definition at line 41 of file seed_signature.hpp.


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