![]() |
Name Generator 4.5.2
Culture-aware name generation for C++23
|
Requires C++23 (e.g.,
-std=c++23for GCC/Clang,/std:c++latestfor MSVC).
API Reference · Usage Guide · Releases
Culturally appropriate first names and surnames from popular name databases, by culture and gender.
get_full_name composes a name by the culture's convention (family name first, two surnames, patronymics); get_child_name, get_parent_name and get_married_name share surnames between people by the same rules.to_culture() and to_gender() for converting strings to enums.has_resources() lets you verify databases loaded before generating.get_name(name_request, seed) (the request carries the gender and culture) for reproducible results, and name::seed() for replaying a previous generation, appended parts included..names layers on top of the shipped lists to add, reweight or remove names (extend()), checked before they are applied.to_json() on every result, and a signature() recording the seed and the data it came from.DASMIG_NAME_EMBED to build the lite tier into the program, for WebAssembly and other builds without files.ng instances with their own name databases.namegen.hpp is the library released here. Keep core.hpp and the core/ directory (dasmig-core) in the same directory. Add
to the files you want to use it in, and supply the resources folder (or define DASMIG_NAME_EMBED).
Version 3 changes every seeded result; see Migrating from v2. Version 4 makes name_request the only way to call a getter; see Migrating from v3.
Due to the necessity of supporting multiple culture characters and the way std::string works on Windows, this library uses std::wstring for all generated names; dasmig::core::to_utf8() converts them, and to_json() is UTF-8.
When requesting a name for the first time the singleton loads the lite tier, from the compiled-in copy or from resources/lite (it looks in resources, ../resources, name-generator/resources and ../name-generator/resources). Manually load the resources folder if it's in a different location, or use load(dataset) to pick between the lite and full tiers. Loading replaces what was loaded; extend() adds to it.
For the complete feature guide — cultures, chaining, thread safety, seeding, extending data, compiled-in data, and more — see the Usage Guide. Where the names come from and what they leave out: Data and Method.
Tested with:
-std=c++23)-std=c++23)/std:c++latest)| Dependency | Version | Bundled | Purpose |
|---|---|---|---|
| dasmig-core | 1.4 | Yes (core.hpp, core/) | Platform-independent random engine and distributions, data layers, JSON |
| Catch2 | 3.x | Yes (amalgamated) | Unit testing |
| Library | Description |
|---|---|
| address-generator | Postal addresses with real streets by place |
| biodata-generator | Procedural human physical characteristics |
| birth-generator | Demographically plausible birthdays |
| city-generator | Weighted city selection by population |
| company-generator | Companies by country: industry, size, legal form, name, registration numbers and domain |
| country-generator | Weighted country selection by population |
| device-generator | Devices, browsers, user agents and IP addresses that fit together |
| email-generator | Email addresses in each country's style |
| entity-generator | ECS-based entity generation |
| finance-generator | Bank accounts and payment cards in each country's form |
| id-generator | National identity numbers, passports and identity cards that fit a person and a date |
| interest-generator | Religion, hobbies and favourite media by country, age and sex |
| nickname-generator | Gamer-style nicknames |
| occupation-generator | Employment status, education and occupation by country, age and sex |
| persona-generator | Complete characters composed from the other generators |
| phone-generator | Phone numbers valid in each country's numbering plan |
| property-generator | Homes that fit a household: dwelling type, tenure, rooms, size, age and cost |
| relationship-generator | Families around a person: parents, siblings, partners and children |
| trait-generator | Personality traits with conflicts, synergies and Big Five axes |
| user-generator | Complete user records: account, username, email, phone and address |
| vehicle-generator | Cars and motorcycles with plates and VINs that fit their country and date |
| weather-generator | Daily weather for any place on land and any date |
This library is released under the MIT License.