persona-generator 4.1.3
Complete characters composed from the other dasmig generators for C++23
Loading...
Searching...
No Matches
dasmig::persona Class Reference

Return type for persona generation. More...

#include <personagen.hpp>

Public Member Functions

std::uint64_t seed () const
 Retrieve the random seed used to generate this persona.
 
const core::seed_signature & signature () const
 The seed and the data this persona was generated from.
 
sex person_sex () const
 Biological sex of the persona.
 
unsigned age () const
 Age in completed years at the request's reference date.
 
std::string to_string () const
 One-line summary: name, age, sex, city, country and job.
 
void to_json (core::json_writer &w) const
 Write this persona as a JSON object.
 
std::string to_json () const
 This persona as a JSON document.
 
 operator std::string () const
 Implicit conversion to std::string.
 

Public Attributes

std::string name
 Full name (UTF-8), from the country's culture and the sex.
 
dasmig::country country_info
 The country.
 
dasmig::city city_info
 The city of residence, in the country.
 
std::string admin1
 Name of the city's state or province; empty when city-generator has no admin1 names loaded.
 
dasmig::birth birthday
 Birth date, completed-year age and sex.
 
dasmig::biodata body
 Height, weight, eyes, hair, skin and blood type, at the persona's age and sex.
 
dasmig::personality traits
 Personality traits and axes.
 
dasmig::interest interests
 Religion, hobbies and media.
 
dasmig::occupation job
 Employment status, education and job.
 
std::optional< family > relatives {}
 The persona's family; set only when persona_request::relations was. // NOLINT(readability-redundant-member-init)
 

Friends

class psg
 
std::ostream & operator<< (std::ostream &os, const persona &v)
 Stream the summary to an output stream.
 

Detailed Description

Return type for persona generation.

Holds the typed result of every library in the pipeline. Supports implicit conversion to std::string (a one-line summary), streaming via operator<< and JSON output via to_json().

Definition at line 89 of file personagen.hpp.

Member Function Documentation

◆ age()

unsigned dasmig::persona::age ( ) const
inline

Age in completed years at the request's reference date.

Returns
The age.

Definition at line 122 of file personagen.hpp.

◆ operator std::string()

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

Implicit conversion to std::string.

Returns
Summary string.

Definition at line 185 of file personagen.hpp.

◆ person_sex()

sex dasmig::persona::person_sex ( ) const
inline

Biological sex of the persona.

Returns
The sex drawn with the birth.

Definition at line 118 of file personagen.hpp.

◆ seed()

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

Retrieve the random seed used to generate this persona.

Returns
The call seed; pass it to get_persona(request, seed) with the same request and data to replay this persona.

Definition at line 106 of file personagen.hpp.

◆ signature()

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

The seed and the data this persona was generated from.

Returns
The replay signature; data combines the data hashes of the eight libraries and the request.

Definition at line 111 of file personagen.hpp.

◆ to_json() [1/2]

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

This persona as a JSON document.

Returns
Compact JSON.

Definition at line 176 of file personagen.hpp.

◆ to_json() [2/2]

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

Write this persona as a JSON object.

Each library's result is written as that library writes it (country, city, birth, biodata, personality, interest, occupation), next to name, sex, age, admin1 and signature, and relatives (the family) when the request asked for it.

Parameters
wWriter positioned where a value is allowed.

Definition at line 143 of file personagen.hpp.

◆ to_string()

std::string dasmig::persona::to_string ( ) const
inline

One-line summary: name, age, sex, city, country and job.

Returns
For example Ana Silva, 34, female, Porto, Portugal, Teacher.

Definition at line 126 of file personagen.hpp.

Friends And Related Symbol Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream &  os,
const persona &  v 
)
friend

Stream the summary to an output stream.

Parameters
osOutput stream.
vThe persona to stream.
Returns
The stream.

Definition at line 194 of file personagen.hpp.

◆ psg

friend class psg
friend

Definition at line 202 of file personagen.hpp.

Member Data Documentation

◆ admin1

std::string dasmig::persona::admin1

Name of the city's state or province; empty when city-generator has no admin1 names loaded.

Definition at line 95 of file personagen.hpp.

◆ birthday

dasmig::birth dasmig::persona::birthday

Birth date, completed-year age and sex.

Definition at line 96 of file personagen.hpp.

◆ body

dasmig::biodata dasmig::persona::body

Height, weight, eyes, hair, skin and blood type, at the persona's age and sex.

Definition at line 97 of file personagen.hpp.

◆ city_info

dasmig::city dasmig::persona::city_info

The city of residence, in the country.

Definition at line 94 of file personagen.hpp.

◆ country_info

dasmig::country dasmig::persona::country_info

The country.

Definition at line 93 of file personagen.hpp.

◆ interests

dasmig::interest dasmig::persona::interests

Religion, hobbies and media.

Definition at line 99 of file personagen.hpp.

◆ job

dasmig::occupation dasmig::persona::job

Employment status, education and job.

Definition at line 100 of file personagen.hpp.

◆ name

std::string dasmig::persona::name

Full name (UTF-8), from the country's culture and the sex.

Definition at line 92 of file personagen.hpp.

◆ relatives

std::optional<family> dasmig::persona::relatives {}

The persona's family; set only when persona_request::relations was. // NOLINT(readability-redundant-member-init)

Definition at line 101 of file personagen.hpp.

◆ traits

dasmig::personality dasmig::persona::traits

Personality traits and axes.

Definition at line 98 of file personagen.hpp.


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