Nickname Generator 1.2.1
Gamer-style nickname generation for C++23
Loading...
Searching...
No Matches
dasmig::nng Class Reference

Nickname generator that produces gamer-style nicknames. More...

#include <nicknamegen.hpp>

Public Member Functions

 nng ()=default
 Default constructor — creates an empty generator with no word lists.
 
 nng (const nng &)=delete
 Not copyable.
 
nngoperator= (const nng &)=delete
 Not copyable.
 
 nng (nng &&)=default
 Move constructor.
 
nngoperator= (nng &&)=default
 Move assignment.
 
 ~nng ()=default
 Default destructor.
 
nickname get_nickname (const std::wstring &name=L"")
 Generate a nickname, optionally based on a name.
 
nickname get_nickname (const std::wstring &name, std::uint64_t call_seed) const
 Generate a deterministic nickname using a specific seed.
 
bool has_wordlists () const
 Check whether any word lists have been loaded.
 
void load (const std::filesystem::path &resource_path)
 Load word list files from a directory.
 
Seeding
nngseed (std::uint64_t seed_value)
 Seed the internal random engine for deterministic sequences.
 
nngunseed ()
 Reseed the engine with a non-deterministic source.
 

Static Public Member Functions

static nnginstance ()
 Access the global singleton instance.
 

Friends

struct ::nng_test_access
 

Detailed Description

Nickname generator that produces gamer-style nicknames.

Generates realistic gamer nicknames akin to professional players, optionally based on a player's real name. Applies random "leetifying" transforms and case formatting for variety.

Can be used as a singleton via instance() or constructed independently. Independent instances own their own word lists and random engine, making them safe for concurrent use without shared state.

Thread safety
Each instance is independent. Concurrent calls to get_nickname() on the same instance require external synchronization. load() mutates internal state and must not be called concurrently with get_nickname() on the same instance.

Definition at line 107 of file nicknamegen.hpp.

Constructor & Destructor Documentation

◆ nng()

dasmig::nng::nng ( )
default

Default constructor — creates an empty generator with no word lists.

Call load() to populate word lists before generating nicknames.

Member Function Documentation

◆ get_nickname() [1/2]

nickname dasmig::nng::get_nickname ( const std::wstring &  name,
std::uint64_t  call_seed 
) const
inline

Generate a deterministic nickname using a specific seed.

Given the same name and seed, this method always produces the same nickname. Retrieve the seed from a previous nickname via nickname::seed().

Parameters
nameFull name to base the nickname on (may be empty).
call_seedSeed for reproducible results.
Returns
A nickname object with both transformed and original strings.
Exceptions
std::invalid_argumentIf name is empty and no word lists loaded.

Definition at line 159 of file nicknamegen.hpp.

◆ get_nickname() [2/2]

nickname dasmig::nng::get_nickname ( const std::wstring &  name = L"")
inline

Generate a nickname, optionally based on a name.

Parameters
nameOptional full name to base the nickname on. If empty, a random word from the loaded word lists is used instead.
Returns
A nickname object with both transformed and original strings.
Exceptions
std::invalid_argumentIf name is empty and no word lists loaded.

Definition at line 138 of file nicknamegen.hpp.

◆ has_wordlists()

bool dasmig::nng::has_wordlists ( ) const
inline

Check whether any word lists have been loaded.

Returns
true if at least one word list is available.

Definition at line 200 of file nicknamegen.hpp.

◆ instance()

static nng & dasmig::nng::instance ( )
inlinestatic

Access the global singleton instance.

The singleton auto-probes common resource paths on first access. For independent generators (e.g., inside an entity-generator component), prefer constructing a separate nng instance.

Returns
Reference to the global nng instance.

Definition at line 127 of file nicknamegen.hpp.

◆ load()

void dasmig::nng::load ( const std::filesystem::path &  resource_path)
inline

Load word list files from a directory.

Recursively scans resource_path for .words files and indexes them. Safe to call multiple times to add from different directories.

Parameters
resource_pathDirectory containing .words files.

Definition at line 211 of file nicknamegen.hpp.

◆ seed()

nng & dasmig::nng::seed ( std::uint64_t  seed_value)
inline

Seed the internal random engine for deterministic sequences.

Subsequent get_nickname() calls (without an explicit seed) draw per-call seeds from this engine, producing a reproducible sequence.

Parameters
seed_valueThe seed value.
Returns
*this for chaining.

Definition at line 180 of file nicknamegen.hpp.

◆ unseed()

nng & dasmig::nng::unseed ( )
inline

Reseed the engine with a non-deterministic source.

Subsequent get_nickname() calls will produce non-reproducible results.

Returns
*this for chaining.

Definition at line 190 of file nicknamegen.hpp.

Friends And Related Symbol Documentation

◆ ::nng_test_access

friend struct ::nng_test_access
friend

Definition at line 1045 of file nicknamegen.hpp.


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