Player12
An open source football management simulator
Loading...
Searching...
No Matches
NamePool Struct Reference

First and last names from assets/user_made_data/names_files. More...

#include <world_generation.h>

Public Member Functions

bool isExcluded (std::string_view full_name) const
 
const std::vector< std::string > & firstNames (Language nationality) const
 
const std::vector< std::string > & lastNames (Language nationality) const
 

Static Public Member Functions

static std::string normalizeName (std::string_view name)
 
static std::uint64_t nameHash (std::string_view name)
 
static const NamePool & instance ()
 

Public Attributes

std::vector< std::string > first_names
 
std::vector< std::string > last_names
 
std::unordered_map< Language, std::vector< std::string > > first_by_nationality
 
std::unordered_map< Language, std::vector< std::string > > last_by_nationality
 
std::unordered_set< std::uint64_t > excluded_name_hashes
 

Detailed Description

First and last names from assets/user_made_data/names_files.

Besides a generic list, every nationality has its own fictional but culture-appropriate names. Full names listed (as hashes) under "excluded_name_hashes" are never generated.

Member Function Documentation

◆ firstNames()

const std::vector< std::string > & NamePool::firstNames ( Language  nationality) const

First names of nationality (the generic list if it has none).

◆ instance()

const NamePool & NamePool::instance ( )
static

Loads the name files once and returns the shared pool.

◆ isExcluded()

bool NamePool::isExcluded ( std::string_view  full_name) const

True when full_name is on the excluded list.

◆ lastNames()

const std::vector< std::string > & NamePool::lastNames ( Language  nationality) const

Last names of nationality (the generic list if it has none).

◆ nameHash()

std::uint64_t NamePool::nameHash ( std::string_view  name)
static

Salted 64-bit FNV-1a hash of normalizeName(name).

◆ normalizeName()

std::string NamePool::normalizeName ( std::string_view  name)
static

Comparable form of a name: lower case ASCII, Latin accents and ligatures folded (e.g. "Ø" -> "o", "ß" -> "ss"), whitespace collapsed to single spaces and trimmed.

Member Data Documentation

◆ excluded_name_hashes

std::unordered_set<std::uint64_t> NamePool::excluded_name_hashes

nameHash() of every full name that must never be generated.

◆ first_by_nationality

std::unordered_map<Language, std::vector<std::string> > NamePool::first_by_nationality

◆ first_names

std::vector<std::string> NamePool::first_names

◆ last_by_nationality

std::unordered_map<Language, std::vector<std::string> > NamePool::last_by_nationality

◆ last_names

std::vector<std::string> NamePool::last_names

The documentation for this struct was generated from the following files: