![]() |
Nickname Generator 1.2.1
Gamer-style nickname generation for C++23
|
This guide covers every feature of the nickname-generator library in detail. For a quick overview, see the README. For the full API reference, run doxygen Doxyfile from the repository root and open doc/api/html/index.html.
dasmig/nicknamegen.hpp and dasmig/random.hpp into your include path.resources/ folder (containing .words files) so it is accessible at runtime.-std=c++23.On first access the singleton constructor probes these relative paths automatically:
| Priority | Path |
|---|---|
| 1 | resources/ |
| 2 | ../resources/ |
| 3 | nickname-generator/resources/ |
If your resources are elsewhere, call load() explicitly:
Calling load() multiple times is safe — each call adds to the existing word lists.
When a name is provided there is a 25 % chance the nickname will be derived from it (using initials, mixing name parts, etc.). Otherwise a random word from the loaded lists is used.
Each generated nickname passes through two stages:
One of these transforms is randomly applied (50 % chance):
| Transform | Example |
|---|---|
| reverse | emankcin |
| duovowel | nicknamee |
| oneleet | n1ckname |
| allleet | n1cknam3 |
| xfy | XnicknameX |
| yfy | nicknamy |
| numify | nickname2000 |
| tracefy | nickname- |
| ingify | nicknaming |
A case format is randomly selected with weighted distribution:
| Format | Weight | Example |
|---|---|---|
| lower_case | 8 | nickname |
| sentence_case | 5 | Nickname |
| upper_case | 4 | NICKNAME |
| bathtub_case | 3 | NicknamE |
| title_case | 2 | NickName |
| camel_case | 2 | nickName |
| reverse_sentence_case | 2 | nicknamE |
| winding_case | 1 | nIcKnAmE |
| random_case | 1 | niCKnaMe |
| random_single_case | 1 | nicknaMe |
There is also a 1 % chance of snake_case being applied first (Nick_Name).
The library ships three word lists in resources/:
| File | Contents |
|---|---|
adjectives.words | English adjectives |
animals.words | Animal names |
japanese.words | Japanese-themed words |
Custom word lists can be added by placing .words files in the resources directory. Each file should contain one word per line.
Each nng instance is independent. The static instance() singleton uses a local static for safe initialization.
| Operation | Thread-safe? |
|---|---|
instance() | Yes (static local) |
get_nickname() on different instances | Yes |
get_nickname() on the same instance | No — requires external synchronization |
load() | No — must not be called concurrently with get_nickname() on the same instance |
Call load() once during initialization before spawning threads. For concurrent generation, give each thread its own nng instance.
Pass an explicit seed to get_nickname() to produce the same nickname every time:
Every nickname records its seed. Retrieve it with nickname::seed() and pass it back to reproduce the exact same result:
Seed the generator's thread-local engine for a reproducible sequence of nicknames:
seed() and unseed() return *this for chaining:
Note:
seed()/unseed()are thread-local — they only affect the calling thread.
Use has_wordlists() before generating to verify resources loaded:
In addition to the singleton instance(), you can construct independent nng objects. Each instance owns its own word lists and random engine, so they operate without shared state — ideal for embedding inside other generators or running multiple configurations side by side.
Each instance maintains its own engine, so seeding one does not affect another:
Instances can be moved (but not copied), which lets you store them in containers or transfer ownership:
| Exception | Thrown by | Condition |
|---|---|---|
std::invalid_argument | nng::get_nickname() | Empty name and no word lists loaded |