User Generator 2.1.2
Synthetic user records for apps and test data, composed from the other dasmig generators for C++23
Loading...
Searching...
No Matches
dasmig::user Class Reference

Return type for user generation. More...

#include <usergen.hpp>

Public Member Functions

std::uint64_t seed () const
 Retrieve the random seed used to generate this user.
 
const core::seed_signature & signature () const
 The seed and the data this user was generated from.
 
sex person_sex () const
 Biological sex of the user.
 
unsigned age () const
 Age in completed years at the request's reference date.
 
std::string to_string () const
 One-line summary: name, username, email and country.
 
void to_json (core::json_writer &w) const
 Write this user as a JSON object.
 
std::string to_json () const
 This user 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.
 
std::string given
 The given name.
 
std::string family
 The family name; empty when the name has one part.
 
std::string country_code
 ISO 3166-1 alpha-2.
 
std::string country_name
 Common name of the country.
 
dasmig::birth birthday
 Birth date, completed-year age and sex.
 
dasmig::address location
 The postal address, in the country.
 
dasmig::phone mobile
 A phone number of the country.
 
dasmig::email mail
 An email address, in the person's name.
 
user_account account
 The login, dates, device and regional settings.
 
std::optional< dasmig::device > client
 The device of the last sign-in; only with user_request::device.
 

Friends

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

Detailed Description

Return type for user 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 159 of file usergen.hpp.

Member Function Documentation

◆ age()

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

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

Returns
The age.

Definition at line 194 of file usergen.hpp.

◆ operator std::string()

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

Implicit conversion to std::string.

Returns
Summary string.

Definition at line 266 of file usergen.hpp.

◆ person_sex()

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

Biological sex of the user.

Returns
The sex drawn with the birth.

Definition at line 190 of file usergen.hpp.

◆ seed()

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

Retrieve the random seed used to generate this user.

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

Definition at line 177 of file usergen.hpp.

◆ signature()

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

The seed and the data this user was generated from.

Returns
The replay signature; data combines the data hashes of the libraries and this one's (and device-generator's, for a user with a device).

Definition at line 183 of file usergen.hpp.

◆ to_json() [1/2]

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

This user as a JSON document.

Returns
Compact JSON.

Definition at line 257 of file usergen.hpp.

◆ to_json() [2/2]

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

Write this user as a JSON object.

Each library's result is written as that library writes it (birth, address, phone, email), next to name, given, family, sex, age, country, account and signature. account has last_login as null for an account that never logged in. With user_request::device, device follows account, as device-generator writes it; without, the key is left out.

Parameters
wWriter positioned where a value is allowed.

Definition at line 212 of file usergen.hpp.

◆ to_string()

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

One-line summary: name, username, email and country.

Returns
For example Ana Silva (ana.silva92) <ana.silva92@gmail.com>, Brazil.

Definition at line 198 of file usergen.hpp.

Friends And Related Symbol Documentation

◆ operator<<

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

Stream the summary to an output stream.

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

Definition at line 275 of file usergen.hpp.

◆ usg

friend class usg
friend

Definition at line 283 of file usergen.hpp.

Member Data Documentation

◆ account

user_account dasmig::user::account

The login, dates, device and regional settings.

Definition at line 171 of file usergen.hpp.

◆ birthday

dasmig::birth dasmig::user::birthday

Birth date, completed-year age and sex.

Definition at line 167 of file usergen.hpp.

◆ client

std::optional<dasmig::device> dasmig::user::client

The device of the last sign-in; only with user_request::device.

Definition at line 172 of file usergen.hpp.

◆ country_code

std::string dasmig::user::country_code

ISO 3166-1 alpha-2.

Definition at line 165 of file usergen.hpp.

◆ country_name

std::string dasmig::user::country_name

Common name of the country.

Definition at line 166 of file usergen.hpp.

◆ family

std::string dasmig::user::family

The family name; empty when the name has one part.

Definition at line 164 of file usergen.hpp.

◆ given

std::string dasmig::user::given

The given name.

Definition at line 163 of file usergen.hpp.

◆ location

dasmig::address dasmig::user::location

The postal address, in the country.

Definition at line 168 of file usergen.hpp.

◆ mail

dasmig::email dasmig::user::mail

An email address, in the person's name.

Definition at line 170 of file usergen.hpp.

◆ mobile

dasmig::phone dasmig::user::mobile

A phone number of the country.

Definition at line 169 of file usergen.hpp.

◆ name

std::string dasmig::user::name

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

Definition at line 162 of file usergen.hpp.


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