|
Name Generator 1.0.0
Culture-aware name generation for C++23
|
Name generator that produces culture-aware names and surnames. More...
#include <namegen.hpp>
Public Member Functions | |
| ng ()=default | |
| Default constructor — creates an empty generator with no names. | |
| ng (const ng &)=delete | |
| Not copyable. | |
| ng & | operator= (const ng &)=delete |
| Not copyable. | |
| ng (ng &&) noexcept=default | |
| Move constructor. | |
| ng & | operator= (ng &&) noexcept=default |
| Move assignment. | |
| ~ng ()=default | |
| Default destructor. | |
| name | get_name (gender g=gender::any, culture c=culture::any) |
| Generate a first name. | |
| name | get_name (gender g, culture c, std::uint64_t call_seed) |
| Generate a deterministic first name using a specific seed. | |
| name | get_surname (culture c=culture::any) |
| Generate a surname. | |
| name | get_surname (culture c, std::uint64_t call_seed) |
| Generate a deterministic surname using a specific seed. | |
| bool | has_resources () const |
| Check whether any name databases have been loaded. | |
| void | load (const std::filesystem::path &resource_path) |
| Load name files from a directory. | |
Seeding | |
| ng & | seed (std::uint64_t seed_value) |
| Seed the internal random engine for deterministic sequences. | |
| ng & | unseed () |
| Reseed the engine with a non-deterministic source. | |
Static Public Member Functions | |
| static ng & | instance () |
| Access the global singleton instance. | |
| static culture | to_culture (const std::wstring &country_code) |
| Translate an ISO 3166 2-letter country code to a culture enum. | |
| static gender | to_gender (const std::wstring &gender_string) |
| Translate a gender string to a gender enum. | |
Friends | |
| class | name |
| struct | ::ng_test_access |
Name generator that produces culture-aware names and surnames.
Generates realistic names by picking from popular name databases indexed by culture and gender. Supports 23 cultures.
Can be used as a singleton via instance() or constructed independently. Independent instances own their own name databases and random engine.
Definition at line 162 of file namegen.hpp.
|
default |
Default constructor — creates an empty generator with no names.
Call load() to populate name databases before generating.
Generate a deterministic first name using a specific seed.
| g | Gender (default: random). |
| c | Culture (default: random). |
| call_seed | Seed for reproducible results. |
| std::invalid_argument | If no names loaded for the resolved culture/gender. |
Definition at line 252 of file namegen.hpp.
Generate a first name.
| g | Gender (default: random). |
| c | Culture (default: random). |
| std::invalid_argument | If no names loaded for the resolved culture/gender. |
Definition at line 237 of file namegen.hpp.
Generate a deterministic surname using a specific seed.
| c | Culture (default: random). |
| call_seed | Seed for reproducible results. |
| std::invalid_argument | If no surnames loaded for the resolved culture. |
Definition at line 277 of file namegen.hpp.
Generate a surname.
| c | Culture (default: random). |
| std::invalid_argument | If no surnames loaded for the resolved culture. |
Definition at line 264 of file namegen.hpp.
|
inline |
Check whether any name databases have been loaded.
true if at least one name file has been loaded. Definition at line 313 of file namegen.hpp.
|
inlinestatic |
Access the global singleton instance.
The singleton auto-probes common resource paths on first access. For independent generators, prefer constructing a separate ng instance.
Definition at line 181 of file namegen.hpp.
|
inline |
Load name files from a directory.
Recursively scans resource_path for .names files and indexes them by culture and gender. Safe to call multiple times.
| resource_path | Directory containing .names files. |
Definition at line 326 of file namegen.hpp.
|
inline |
Seed the internal random engine for deterministic sequences.
Subsequent get_name() / get_surname() calls (without an explicit seed) draw per-call seeds from this engine, producing a reproducible sequence.
| seed_value | The seed value. |
*this for chaining. Definition at line 295 of file namegen.hpp.
|
inlinestatic |
Translate an ISO 3166 2-letter country code to a culture enum.
| country_code | Two-letter country code (e.g., L"us", L"br"). |
Definition at line 190 of file namegen.hpp.
|
inlinestatic |
Translate a gender string to a gender enum.
| gender_string | Gender string (e.g., L"male", L"female", L"m", L"f"). |
Definition at line 216 of file namegen.hpp.
|
inline |
Reseed the engine with a non-deterministic source.
*this for chaining. Definition at line 303 of file namegen.hpp.
|
friend |
Definition at line 705 of file namegen.hpp.
|
friend |
Definition at line 704 of file namegen.hpp.