|
|
| nng ()=default |
| | Default constructor — creates an empty generator with no word lists.
|
| |
|
| nng (const nng &)=delete |
| | Not copyable.
|
| |
|
nng & | operator= (const nng &)=delete |
| | Not copyable.
|
| |
|
| nng (nng &&) noexcept=default |
| | Move constructor.
|
| |
|
nng & | operator= (nng &&) noexcept=default |
| | Move assignment.
|
| |
|
| ~nng ()=default |
| | Default destructor.
|
| |
| nickname | get_nickname (const nickname_request &request) |
| | Generate a random nickname, optionally based on a name.
|
| |
| nickname | get_nickname (const nickname_request &request, std::uint64_t call_seed) const |
| | Generate a deterministic nickname.
|
| |
| std::vector< nickname > | get_nickname_batch (const nickname_request &request, const core::batch_options &options) |
| | Generate a batch of nickname results from a seed drawn like get_nickname() draws its own.
|
| |
| std::vector< nickname > | get_nickname_batch (const nickname_request &request, const core::batch_options &options, std::uint64_t batch_seed) const |
| | Generate a batch of nickname results, deterministically.
|
| |
| template<typename Sink > |
| void | for_each_nickname (const nickname_request &request, const core::batch_options &options, std::uint64_t batch_seed, Sink &&sink) const |
| | Stream a batch of nickname results to a sink without holding the whole batch.
|
| |
| template<typename Sink > |
| void | for_each_nickname (const nickname_request &request, const core::batch_options &options, Sink &&sink) |
| | Stream a batch of nickname results with a batch seed drawn like get_nickname() draws its own.
|
| |
| bool | has_wordlists () const |
| | Check whether any word list is loaded.
|
| |
| void | load (const std::filesystem::path &resource_path) |
| | Load word lists from a directory, replacing all lists and layers loaded before.
|
| |
| bool | load (dataset tier) |
| | Load the shipped word lists, replacing all lists and layers loaded before.
|
| |
| void | extend (const std::filesystem::path &path, core::layer_mode mode=core::layer_mode::override) |
| | Add word list layers from a directory or a file.
|
| |
| const core::layer_info & | extend_from_string (std::string_view list, std::string_view text, std::string source, core::layer_mode mode=core::layer_mode::override) |
| | Add a layer to a word list from TSV text with a word column (and optionally disabled).
|
| |
| std::vector< std::string > | list_names () const |
| | Names of the loaded word lists, in the order they are used.
|
| |
| const std::vector< core::layer_info > & | layers (const std::string &list) const |
| | The layers in effect for one word list.
|
| |
| std::uint64_t | data_hash () const |
| | Hash of the loaded word lists, recorded in each result's signature().
|
| |
Nickname generator that produces gamer-style nicknames.
Generates nicknames either from a person's name (first name, initials, mixed parts, ...) or from word lists, then decorates them (leet speak, suffixes, reversal, ...) and formats their case.
Output is identical on every compiler and platform (dasmig-core): the case changes use a fixed mapping rather than the C locale, and word lists are read as UTF-8 in name order.
Can be used as a singleton via instance() or constructed independently.
- Thread safety
- Each instance is independent. Concurrent calls to get_nickname(request) on the same instance require external synchronisation. Seeded calls are read-only and can run concurrently, provided no word lists are changed.
Definition at line 198 of file nicknamegen.hpp.
| std::vector< nickname > dasmig::nng::get_nickname_batch |
( |
const nickname_request & |
request, |
|
|
const core::batch_options & |
options, |
|
|
std::uint64_t |
batch_seed |
|
) |
| const |
|
inline |
Generate a batch of nickname results, deterministically.
Item i is exactly get_nickname(request, core::item_seed(batch_seed, options.first + i)), so an item replays on its own, a range can be generated directly, two batches that follow each other equal one, and the output does not depend on options.threads.
- Parameters
-
| request | What every item is generated from. |
| options | Count, first index, threads and uniqueness (see core::unique_rule; the rule must be made for nickname). |
| batch_seed | Seed of the whole batch. |
- Returns
- The results, in index order.
- Exceptions
-
| std::invalid_argument | If the request or options are invalid. |
| std::runtime_error | If no data has been loaded, or a unique batch runs out of attempts. |
Definition at line 284 of file nicknamegen.hpp.
| void dasmig::nng::load |
( |
const std::filesystem::path & |
resource_path | ) |
|
|
inline |
Load word lists from a directory, replacing all lists and layers loaded before.
Reads every .words file (one word per line) and .tsv file (a word column) below the directory, in path order. The list name is the file name without extension; files with the same name extend the same list. A path that is not a directory is ignored.
- Parameters
-
| resource_path | Directory such as resources/lite. |
- Exceptions
-
| core::tsv_error | If a file is malformed; the lists are then unchanged. |
Definition at line 346 of file nicknamegen.hpp.
| bool dasmig::nng::load |
( |
dataset |
tier | ) |
|
|
inline |
Load the shipped word lists, replacing all lists and layers loaded before.
The library ships one tier: dataset::full loads the same lists as dataset::lite. Uses the compiled-in copy when built with DASMIG_NICKNAME_EMBED, otherwise searches resources/, ../resources, nickname-generator/resources and ../nickname-generator/resources.
- Parameters
-
- Returns
- False when no word list was found.
- Exceptions
-
| core::tsv_error | If a file is malformed. |
Definition at line 365 of file nicknamegen.hpp.