Birth Generator 3.2.2
Procedural birth date generation for C++23
Loading...
Searching...
No Matches
dasmig::birth Class Reference

Return type for birth generation. More...

#include <birthgen.hpp>

Public Member Functions

std::uint64_t seed () const
 Retrieve the random seed used to generate this birth.
 
const core::seed_signature & signature () const
 The seed and the data this birth was generated from.
 
std::string date_string () const
 ISO 8601 date string (YYYY-MM-DD).
 
void to_json (core::json_writer &w) const
 Write this birth as a JSON object.
 
std::string to_json () const
 This birth as a JSON document.
 
 operator std::string () const
 Implicit conversion to std::string.
 

Public Attributes

std::string country_code
 ISO 3166-1 alpha-2 code.
 
std::uint16_t year {0}
 Birth year.
 
std::uint8_t month {0}
 Birth month (1–12).
 
std::uint8_t day {0}
 Birth day (1–31).
 
std::uint8_t age {0}
 Age in completed years at the reference date.
 
sex bio_sex {sex::male}
 Biological sex.
 
std::uint8_t weekday {0}
 Day of week (0=Sun, 1=Mon, …, 6=Sat).
 
double le_remaining {0.0}
 Estimated years of life remaining.
 
std::string cohort
 Generational cohort label.
 

Friends

class bthg
 
std::ostream & operator<< (std::ostream &os, const birth &b)
 Stream the ISO date to an output stream.
 

Detailed Description

Return type for birth generation.

Supports implicit conversion to std::string (ISO 8601 date), streaming via operator<< and JSON output via to_json().

Definition at line 84 of file birthgen.hpp.

Member Function Documentation

◆ date_string()

std::string dasmig::birth::date_string ( ) const
inline

ISO 8601 date string (YYYY-MM-DD).

Returns
The date.

Definition at line 109 of file birthgen.hpp.

◆ operator std::string()

dasmig::birth::operator std::string ( ) const
inline

Implicit conversion to std::string.

Returns
ISO 8601 date string.

Definition at line 146 of file birthgen.hpp.

◆ seed()

std::uint64_t dasmig::birth::seed ( ) const
inline

Retrieve the random seed used to generate this birth.

Returns
The call seed; pass it to get_birth(request, seed) with the original request and data to generate the same birth again.

Definition at line 100 of file birthgen.hpp.

◆ signature()

const core::seed_signature & dasmig::birth::signature ( ) const
inline

The seed and the data this birth was generated from.

Returns
The replay signature; data is bthg::data_hash() at the time of generation.

Definition at line 105 of file birthgen.hpp.

◆ to_json() [1/2]

std::string dasmig::birth::to_json ( ) const
inline

This birth as a JSON document.

Returns
Compact JSON.

Definition at line 137 of file birthgen.hpp.

◆ to_json() [2/2]

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

Write this birth as a JSON object.

Parameters
wWriter positioned where a value is allowed.

Definition at line 117 of file birthgen.hpp.

Friends And Related Symbol Documentation

◆ bthg

friend class bthg
friend

Definition at line 163 of file birthgen.hpp.

◆ operator<<

std::ostream & operator<< ( std::ostream &  os,
const birth &  b 
)
friend

Stream the ISO date to an output stream.

Parameters
osOutput stream.
bBirth to stream.
Returns
The stream.

Definition at line 155 of file birthgen.hpp.

Member Data Documentation

◆ age

std::uint8_t dasmig::birth::age {0}

Age in completed years at the reference date.

Definition at line 91 of file birthgen.hpp.

◆ bio_sex

sex dasmig::birth::bio_sex {sex::male}

Biological sex.

Definition at line 92 of file birthgen.hpp.

◆ cohort

std::string dasmig::birth::cohort

Generational cohort label.

Definition at line 95 of file birthgen.hpp.

◆ country_code

std::string dasmig::birth::country_code

ISO 3166-1 alpha-2 code.

Definition at line 87 of file birthgen.hpp.

◆ day

std::uint8_t dasmig::birth::day {0}

Birth day (1–31).

Definition at line 90 of file birthgen.hpp.

◆ le_remaining

double dasmig::birth::le_remaining {0.0}

Estimated years of life remaining.

Definition at line 94 of file birthgen.hpp.

◆ month

std::uint8_t dasmig::birth::month {0}

Birth month (1–12).

Definition at line 89 of file birthgen.hpp.

◆ weekday

std::uint8_t dasmig::birth::weekday {0}

Day of week (0=Sun, 1=Mon, …, 6=Sat).

Definition at line 93 of file birthgen.hpp.

◆ year

std::uint16_t dasmig::birth::year {0}

Birth year.

Definition at line 88 of file birthgen.hpp.


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