Relationship Generator 1.2.2
Believable families around a person: parents, siblings, partners and children, with ages and names for C++23
Loading...
Searching...
No Matches
relgen.hpp File Reference

Relationship Generator library — believable families around a person: parents, siblings, partners and children, with ages and names for C++23. More...

#include <dasmig/birthgen.hpp>
#include <dasmig/namegen.hpp>
#include "core.hpp"
#include <algorithm>
#include <array>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstddef>
#include <cstdint>
#include <filesystem>
#include <format>
#include <initializer_list>
#include <map>
#include <optional>
#include <ostream>
#include <span>
#include <stdexcept>
#include <string>
#include <string_view>
#include <system_error>
#include <unordered_map>
#include <utility>
#include <vector>

Go to the source code of this file.

Classes

struct  dasmig::person_name
 A name the caller already has, as plain words. More...
 
struct  dasmig::known_person
 Someone the caller already knows: used to build the family of a member of a family that exists, so that both agree. More...
 
struct  dasmig::known_sibling
 A brother or sister the caller already knows. More...
 
struct  dasmig::known_child
 A child the caller already knows. More...
 
struct  dasmig::known_union
 A union of the anchor that the caller already knows, with the children it had. More...
 
struct  dasmig::anchor_spec
 The person a family is built around, as plain values. More...
 
struct  dasmig::family_request
 What a family call asks for. More...
 
struct  dasmig::person
 A person in a family: who they are to the anchor, their name and when they live. More...
 
struct  dasmig::edge
 A link between two members, by id. More...
 
struct  dasmig::household
 Who the anchor lives with. More...
 
class  dasmig::family
 Return type for family generation. More...
 
class  dasmig::relg
 Relationship Generator: builds believable families around a person. More...
 
struct  dasmig::relg::sources
 The library instances a family is drawn from. More...
 

Enumerations

enum class  dasmig::relation : std::uint8_t {
  anchor , father , mother , sibling ,
  half_sibling , paternal_grandfather , paternal_grandmother , maternal_grandfather ,
  maternal_grandmother , partner , child , grandchild ,
  stepchild , stepfather , stepmother , stepsibling
}
 How a member is related to the anchor. More...
 
enum class  dasmig::edge_kind : std::uint8_t { parent_of , sibling_of , partner_of , step_parent_of }
 How two members are linked. More...
 
enum class  dasmig::union_end : std::uint8_t { ongoing , divorce , death }
 How a union ended. More...
 
enum class  dasmig::household_type : std::uint8_t {
  one_person , couple , nuclear , single_parent ,
  with_parents , multi_generation , other
}
 The kind of home the anchor lives in at the reference date. More...
 
enum class  dasmig::data_source : std::uint8_t { country , subregion , world }
 Where a table's values came from for the family's country. More...
 
enum class  dasmig::family_table : std::uint8_t {
  regions , fertility , unions , households ,
  defaults , parameters
}
 The tables of the family data, for extending it. More...
 

Functions

constexpr std::string_view dasmig::relation_name (relation r) noexcept
 The name of a relation as it appears in JSON (paternal_grandfather).
 
constexpr std::string_view dasmig::union_end_name (union_end e) noexcept
 The name of an ending as it appears in JSON.
 
constexpr std::string_view dasmig::household_type_name (household_type t) noexcept
 The name of a household type as it appears in JSON.
 
constexpr std::string_view dasmig::data_source_name (data_source s) noexcept
 The name of a data source as it appears in JSON.
 

Detailed Description

Relationship Generator library — believable families around a person: parents, siblings, partners and children, with ages and names for C++23.

Author
Diego Dasso Migotto (diegomigotto at hotmail dot com)
See also
See doc/usage.md for the narrative tutorial.

Definition in file relgen.hpp.

Enumeration Type Documentation

◆ data_source

enum class dasmig::data_source : std::uint8_t
strong

Where a table's values came from for the family's country.

Enumerator
country 

The country's own row.

subregion 

The median of its UN subregion.

world 

The world median.

Definition at line 327 of file relgen.hpp.

◆ edge_kind

enum class dasmig::edge_kind : std::uint8_t
strong

How two members are linked.

Enumerator
parent_of 

from is a parent of to.

sibling_of 

from and to share a parent; from is the older.

partner_of 

from (the anchor, or a parent of the anchor for a stepparent) and to are, or were, partners.

step_parent_of 

from (a stepfather or stepmother) is a stepparent of to (the anchor).

Definition at line 245 of file relgen.hpp.

◆ family_table

enum class dasmig::family_table : std::uint8_t
strong

The tables of the family data, for extending it.

Enumerator
regions 

regions.tsv: the UN subregion of each country.

fertility 

fertility.tsv: total fertility rate (now and by period) and fertility by the mother's age.

unions 

unions.tsv: age at first marriage, never married and divorced shares.

households 

households.tsv: household size and types.

defaults 

defaults.tsv: the median of every column per subregion, and the world.

parameters 

parameters.tsv: the model's constants.

Definition at line 598 of file relgen.hpp.

◆ household_type

enum class dasmig::household_type : std::uint8_t
strong

The kind of home the anchor lives in at the reference date.

Enumerator
one_person 

The anchor lives alone.

couple 

The anchor and a partner.

nuclear 

Two adults and children under 18.

single_parent 

One adult and children under 18.

with_parents 

An adult living with a parent (and the younger siblings still at home).

multi_generation 

Three generations, or an adult household that includes a parent.

other 

Anyone else: the relatives the family holds do not live with the anchor.

Definition at line 289 of file relgen.hpp.

◆ relation

enum class dasmig::relation : std::uint8_t
strong

How a member is related to the anchor.

Enumerator
anchor 

The person the family is built around.

father 

The anchor's father.

mother 

The anchor's mother.

sibling 

A full brother or sister.

half_sibling 

A half-brother or half-sister, through one parent.

paternal_grandfather 

The father's father.

paternal_grandmother 

The father's mother.

maternal_grandfather 

The mother's father.

maternal_grandmother 

The mother's mother.

partner 

A partner of the anchor, current or former.

child 

A child of the anchor, by birth or adoption.

grandchild 

A child of one of the anchor's children.

stepchild 

A child of a partner by an earlier union, not the anchor's.

stepfather 

A man who is, or was, a parent's partner while the anchor was a child.

stepmother 

A woman who is, or was, a parent's partner while the anchor was a child.

stepsibling 

A stepparent's child by an earlier union, not a parent's.

Definition at line 179 of file relgen.hpp.

◆ union_end

enum class dasmig::union_end : std::uint8_t
strong

How a union ended.

Enumerator
ongoing 

It has not ended at the reference date.

divorce 

The partners separated.

death 

The partner died.

Definition at line 254 of file relgen.hpp.

Function Documentation

◆ data_source_name()

constexpr std::string_view dasmig::data_source_name ( data_source  s)
constexprnoexcept

The name of a data source as it appears in JSON.

Parameters
sThe source.
Returns
country, subregion or world.

Definition at line 337 of file relgen.hpp.

◆ household_type_name()

constexpr std::string_view dasmig::household_type_name ( household_type  t)
constexprnoexcept

The name of a household type as it appears in JSON.

Parameters
tThe type.
Returns
one_person, couple, nuclear, single_parent, with_parents, multi_generation or other.

Definition at line 304 of file relgen.hpp.

◆ relation_name()

constexpr std::string_view dasmig::relation_name ( relation  r)
constexprnoexcept

The name of a relation as it appears in JSON (paternal_grandfather).

Parameters
rThe relation.
Returns
The name.

Definition at line 202 of file relgen.hpp.

◆ union_end_name()

constexpr std::string_view dasmig::union_end_name ( union_end  e)
constexprnoexcept

The name of an ending as it appears in JSON.

Parameters
eThe ending.
Returns
ongoing, divorce or death.

Definition at line 264 of file relgen.hpp.