Name Generator 4.5.2
Culture-aware name generation for C++23
Loading...
Searching...
No Matches
dasmig::name Class Reference

Return type for name generation, holding both individual parts and the full composed string. More...

#include <namegen.hpp>

Public Member Functions

std::uint64_t seed () const
 Retrieve the random seed used to generate this name.
 
const core::seed_signature & signature () const
 The seed and the data this name was generated from.
 
const std::vector< std::wstring > & parts () const
 Return the individual parts (names/surnames) as a vector.
 
const std::vector< name_role > & roles () const
 The role of each part, in the order of parts().
 
bool composed () const
 Whether this name was composed by a culture's convention (ng::get_full_name(), ng::get_child_name() or ng::get_married_name()).
 
std::wstring given () const
 The given name (empty when the name has none).
 
std::wstring patronymic () const
 The patronymic (empty when the culture has none).
 
std::wstring family () const
 The family name; both surnames of a double surname, in order.
 
name & append_name ()
 Append a forename to this name, preserving gender and culture.
 
name & append_name (culture c)
 Append a forename of a specific culture.
 
name & append_surname ()
 Append a surname to this name, preserving culture.
 
name & append_surname (culture c)
 Append a surname of a specific culture.
 
void to_json (core::json_writer &w) const
 Write this name as a JSON object {"name":…,"parts":[…],"gender":…,"culture":…,"signature":{…}}.
 
std::string to_json () const
 This name as a JSON document.
 
 operator std::wstring () const
 Implicit conversion to std::wstring.
 
 operator std::vector< std::wstring > () const
 Implicit conversion to a vector of name parts.
 

Friends

class ng
 
std::wostream & operator<< (std::wostream &wos, const name &n)
 Stream the name to a wide output stream.
 

Detailed Description

Return type for name generation, holding both individual parts and the full composed string.

Supports implicit conversion to std::wstring, streaming via operator<<, chained appending of names and surnames, and JSON output via to_json().

Definition at line 248 of file namegen.hpp.

Member Function Documentation

◆ append_name() [1/2]

name & dasmig::name::append_name ( )
inline

Append a forename to this name, preserving gender and culture.

The part is drawn from this name's seed and its position, so the same seed and the same appends give the same full name.

Returns
*this for chaining.
Exceptions
std::invalid_argumentIf no names are loaded for the culture and gender.

Definition at line 2156 of file namegen.hpp.

◆ append_name() [2/2]

name & dasmig::name::append_name ( culture  c)
inline

Append a forename of a specific culture.

Parameters
cCulture for the appended name.
Returns
*this for chaining.
Exceptions
std::invalid_argumentIf no names are loaded for c.

Definition at line 2162 of file namegen.hpp.

◆ append_surname() [1/2]

name & dasmig::name::append_surname ( )
inline

Append a surname to this name, preserving culture.

Returns
*this for chaining.
Exceptions
std::invalid_argumentIf no surnames are loaded for the culture.

Definition at line 2168 of file namegen.hpp.

◆ append_surname() [2/2]

name & dasmig::name::append_surname ( culture  c)
inline

Append a surname of a specific culture.

Parameters
cCulture for the appended surname.
Returns
*this for chaining.
Exceptions
std::invalid_argumentIf no surnames are loaded for c.

Definition at line 2174 of file namegen.hpp.

◆ composed()

bool dasmig::name::composed ( ) const
inline

Whether this name was composed by a culture's convention (ng::get_full_name(), ng::get_child_name() or ng::get_married_name()).

Definition at line 283 of file namegen.hpp.

◆ family()

std::wstring dasmig::name::family ( ) const
inline

The family name; both surnames of a double surname, in order.

Definition at line 301 of file namegen.hpp.

◆ given()

std::wstring dasmig::name::given ( ) const
inline

The given name (empty when the name has none).

Definition at line 289 of file namegen.hpp.

◆ operator std::vector< std::wstring >()

dasmig::name::operator std::vector< std::wstring > ( ) const
inline

Implicit conversion to a vector of name parts.

Definition at line 358 of file namegen.hpp.

◆ operator std::wstring()

dasmig::name::operator std::wstring ( ) const
inline

Implicit conversion to std::wstring.

Returns
The full composed name string.

Definition at line 352 of file namegen.hpp.

◆ parts()

const std::vector< std::wstring > & dasmig::name::parts ( ) const
inline

Return the individual parts (names/surnames) as a vector.

Returns
Vector of name parts.

Definition at line 269 of file namegen.hpp.

◆ patronymic()

std::wstring dasmig::name::patronymic ( ) const
inline

The patronymic (empty when the culture has none).

Definition at line 295 of file namegen.hpp.

◆ roles()

const std::vector< name_role > & dasmig::name::roles ( ) const
inline

The role of each part, in the order of parts().

Returns
One role per part; given for a forename, family for a surname.

Definition at line 276 of file namegen.hpp.

◆ seed()

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

Retrieve the random seed used to generate this name.

Returns
The per-call seed for replay.
See also
ng::get_name(const name_request&, std::uint64_t)

Definition at line 254 of file namegen.hpp.

◆ signature()

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

The seed and the data this name was generated from.

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

Definition at line 262 of file namegen.hpp.

◆ to_json() [1/2]

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

This name as a JSON document.

Returns
Compact JSON.

Definition at line 343 of file namegen.hpp.

◆ to_json() [2/2]

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

Write this name as a JSON object {"name":…,"parts":[…],"gender":…,"culture":…,"signature":{…}}.

gender is the gender of the forenames (for a surname, the one append_name() would use) and culture the culture of the first part.

Parameters
wWriter positioned where a value is allowed.

Definition at line 2180 of file namegen.hpp.

Friends And Related Symbol Documentation

◆ ng

friend class ng
friend

Definition at line 412 of file namegen.hpp.

◆ operator<<

std::wostream & operator<< ( std::wostream &  wos,
const name &  n 
)
friend

Stream the name to a wide output stream.

Parameters
wosOutput stream.
nName to stream.
Returns
Reference to the output stream.

Definition at line 367 of file namegen.hpp.


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