![]() |
Birth Generator 1.1.1
Procedural birth date generation for C++23
|
Birth generator that produces demographically plausible random birthdays using UN WPP 2024 population data. More...
#include <birthgen.hpp>
Public Member Functions | |
| bthg () | |
| Default constructor — creates an empty generator with no data. | |
| bthg (const bthg &)=delete | |
| bthg & | operator= (const bthg &)=delete |
| bthg (bthg &&) noexcept=default | |
| bthg & | operator= (bthg &&) noexcept=default |
| birth | get_birth (std::string_view cca2) |
| Generate a random birth for a specific country. | |
| birth | get_birth (std::string_view cca2, std::uint64_t call_seed) const |
| Generate a deterministic birth for a specific country. | |
| birth | get_birth () |
| Generate a random birth from a random country. | |
| birth | get_birth (std::uint64_t call_seed) const |
| Generate a deterministic birth from a random country. | |
| birth | get_birth (std::string_view cca2, sex bio_sex) |
| Generate a random birth with a predetermined sex. | |
| birth | get_birth (std::string_view cca2, sex bio_sex, std::uint64_t call_seed) const |
| Generate a deterministic birth with a predetermined sex. | |
| birth | get_birth (sex bio_sex) |
| Generate a random birth from a random country with a predetermined sex. | |
| birth | get_birth (sex bio_sex, std::uint64_t call_seed) const |
| Generate a deterministic birth from a random country with a predetermined sex. | |
| birth | get_birth (std::string_view cca2, year_t year) |
| Generate a random birth for a specific year. | |
| birth | get_birth (std::string_view cca2, year_t year, std::uint64_t call_seed) const |
| Generate a deterministic birth for a specific year. | |
| birth | get_birth (std::string_view cca2, sex bio_sex, year_t year) |
| Generate a random birth with predetermined sex and year. | |
| birth | get_birth (std::string_view cca2, sex bio_sex, year_t year, std::uint64_t call_seed) const |
| Generate a deterministic birth with predetermined sex and year. | |
| birth | get_birth (std::string_view cca2, age_range range) |
| Generate a random birth with age within [range.min, range.max]. | |
| birth | get_birth (std::string_view cca2, age_range range, std::uint64_t call_seed) const |
| Generate a deterministic birth with age within [range.min, range.max]. | |
| bthg & | seed (std::uint64_t seed_value) |
| Seed the internal random engine for deterministic sequences. | |
| bthg & | unseed () |
| Reseed the engine with a non-deterministic source. | |
| bthg & | weighted (bool enable) |
| Set whether country selection is population-weighted. | |
| bool | weighted () const |
| Query whether country selection is population-weighted. | |
| bool | has_data () const |
| Check whether any data has been loaded. | |
| std::size_t | country_count () const |
| Return the number of loaded countries. | |
| void | load (const std::filesystem::path &dir) |
| Load birth data from a resource directory. | |
| bool | load (dataset tier) |
| Load a specific dataset tier from auto-probed paths. | |
Static Public Member Functions | |
| static bthg & | instance () |
| Access the global singleton instance. | |
Birth generator that produces demographically plausible random birthdays using UN WPP 2024 population data.
The generation pipeline:
Can be used as a singleton via instance() or constructed independently.
Definition at line 133 of file birthgen.hpp.
|
inline |
Default constructor — creates an empty generator with no data.
Definition at line 137 of file birthgen.hpp.
|
inline |
Return the number of loaded countries.
Definition at line 367 of file birthgen.hpp.
|
inline |
Generate a random birth from a random country.
| std::runtime_error | If no data has been loaded. |
Definition at line 174 of file birthgen.hpp.
|
inline |
Generate a random birth from a random country with a predetermined sex.
Definition at line 216 of file birthgen.hpp.
|
inline |
Generate a deterministic birth from a random country with a predetermined sex.
Definition at line 236 of file birthgen.hpp.
|
inline |
Generate a random birth for a specific country.
| cca2 | ISO 3166-1 alpha-2 country code (e.g. "US", "BR"). |
| std::runtime_error | If no data has been loaded. |
| std::invalid_argument | If the country code is unknown. |
Definition at line 160 of file birthgen.hpp.
Generate a random birth with age within [range.min, range.max].
| std::invalid_argument | If range.min > range.max. |
Definition at line 301 of file birthgen.hpp.
|
inline |
Generate a deterministic birth with age within [range.min, range.max].
Definition at line 318 of file birthgen.hpp.
|
inline |
Generate a random birth with a predetermined sex.
Definition at line 200 of file birthgen.hpp.
|
inline |
Generate a deterministic birth with a predetermined sex.
Definition at line 207 of file birthgen.hpp.
Generate a random birth with predetermined sex and year.
Definition at line 277 of file birthgen.hpp.
|
inline |
Generate a deterministic birth with predetermined sex and year.
Definition at line 287 of file birthgen.hpp.
|
inline |
Generate a deterministic birth for a specific country.
Definition at line 166 of file birthgen.hpp.
Generate a random birth for a specific year.
| cca2 | ISO 3166-1 alpha-2 country code. |
| year | Birth year (e.g. year_t{1990}). Age is derived as ref_year − year and clamped to [0, 100]. |
Definition at line 260 of file birthgen.hpp.
|
inline |
Generate a deterministic birth for a specific year.
Definition at line 267 of file birthgen.hpp.
|
inline |
Generate a deterministic birth from a random country.
Definition at line 180 of file birthgen.hpp.
|
inline |
Check whether any data has been loaded.
Definition at line 364 of file birthgen.hpp.
|
inlinestatic |
Access the global singleton instance.
Auto-probes common resource paths on first access.
Definition at line 148 of file birthgen.hpp.
|
inline |
Load birth data from a resource directory.
Expects the directory to contain: countries.tsv, age_pyramid.tsv, monthly_births.tsv.
Definition at line 376 of file birthgen.hpp.
|
inline |
Load a specific dataset tier from auto-probed paths.
Definition at line 390 of file birthgen.hpp.
|
inline |
Seed the internal random engine for deterministic sequences.
Definition at line 338 of file birthgen.hpp.
|
inline |
Reseed the engine with a non-deterministic source.
Definition at line 345 of file birthgen.hpp.
|
inline |
Query whether country selection is population-weighted.
Definition at line 359 of file birthgen.hpp.
|
inline |
Set whether country selection is population-weighted.
Definition at line 352 of file birthgen.hpp.