< index < 16. Name generator | ===================================== 16.1 Creating a generator ===================================== | > 16.2 Generating a name

### TCODNamegen::parse

In order to be able to generate names, the name generator needs to be fed proper data. It will then be ready to generate one specific type of names. You can achieve that by telling it what files it should parse in search for proper syllable sets:

    C++ : static void TCODNamegen::parse(const char * filename, TCODRandom * random = NULL)
    C   : void TCOD_namegen_parse(const char * filename, TCOD_random_t random)
    Py  : namegen_parse(filename,random=0)

Parameter | Description
--- | ---
filename | The file where the desired syllable set is saved, along with its relative parh, for instance, "data/names.txt".
random | A random number generator object. Use NULL for the default random number generator

Note 1: The filename may contain various structures with syllable sets, but the generator will only use one such structure. Each file will be parsed once only. If, for some reason, you would like to parse the same file twice, you will need to destroy the generator first, which will empty the list of parsed files along with erasing all the data retrieved from those files.
Note 2: The generator can be fed data multiple times if you have it in separate files. Just make sure the structure names in them aren't duplicated, otherwise they will be silently ignored.
Note 3: In the C++ version, you are not obliged to specify the random number generator. If you skip it in the function call, the generator will assume you would like to use an instance of the default generator.
Example :

    C++ : TCODNamegen::parse("data/names.txt",TCODRandom::getInstance());
          TCODNamegen::parse("data/names2.txt");
    C   : TCOD_namegen_parse("data/names.txt",TCOD_random_get_instance());
    Py  : libtcod.namegen_parse('data/names.txt')