#include <name_generator_factory.hpp>
Public Member Functions | |
name_generator_factory (const config &config, std::vector< std::string > ids) | |
Creates a new name generator factory. More... | |
std::shared_ptr< name_generator > | get_name_generator () |
Gets the default name generator. More... | |
std::shared_ptr< name_generator > | get_name_generator (const std::string &name) |
Gets a specific name generator or the default name generator, if the specific name generator is not found. More... | |
Private Member Functions | |
void | add_name_generator_from_config (const config &config, const std::string &id, const std::string &prefix) |
Determines a name generator from WML data. More... | |
Private Attributes | |
std::map< std::string, std::shared_ptr< name_generator > > | name_generators_ |
Definition at line 23 of file name_generator_factory.hpp.
name_generator_factory::name_generator_factory | ( | const config & | config, |
std::vector< std::string > | ids | ||
) |
Creates a new name generator factory.
config | the WML data to be parsed for name generators |
ids | a list of generator ids, e.g. genders or terrain types |
Definition at line 29 of file name_generator_factory.cpp.
References add_name_generator_from_config().
|
private |
Determines a name generator from WML data.
Tries first to load a context-free generator, then falls back to Markov.
config | the WML data to be parsed for name generators |
id | the generator id to use |
prefix | the prefix to look for |
Definition at line 38 of file name_generator_factory.cpp.
References config_attribute_value::blank(), ERR_WML, config::has_attribute(), id, lg::log_to_chat(), name_generators_, utils::split(), and name_generator_invalid_exception::what().
Referenced by name_generator_factory().
std::shared_ptr< name_generator > name_generator_factory::get_name_generator | ( | ) |
Gets the default name generator.
Definition at line 62 of file name_generator_factory.cpp.
References name_generators_.
Referenced by get_name_generator(), and unit_race::unit_race().
std::shared_ptr< name_generator > name_generator_factory::get_name_generator | ( | const std::string & | name | ) |
Gets a specific name generator or the default name generator, if the specific name generator is not found.
name | generator id, e.g. a gender or a terrain type |
Definition at line 72 of file name_generator_factory.cpp.
References get_name_generator(), and name_generators_.
|
private |
Definition at line 48 of file name_generator_factory.hpp.
Referenced by add_name_generator_from_config(), and get_name_generator().