Back to main librea page
This API is not yet stable. Backward compatibility is not yet maintained in librea development. This document describes librea svn revision 19.

Names

There's just two properties attached to each name; the actual name, and the weight affecting how likely that name gets picked.

Namepools

Central concept in librea is namepool. Each namepool contains one or more names.

In librea pool is usually referred as rea_pool *. In librea++ pool is the central class reapp_pool.

Typical program flow

Minimum librea using program would:
  1. Initialize library
  2. Create suitable namepool
  3. Pick random name from the pool
  4. Deinitialize library

Common librea functions

void rea_init(void)

Initialize librea. Needs to be called once before any other library calls.

void rea_deinit(void)

Deinitializes librea. No library functions may be called after this.

const char *rea_get_name(rea_pool *pool)

Get random name from the pool.

Pool creation in librea

void rea_pool_init(rea_pool *pool, const char *name)

If you want to create empty pool, use this function to initialize it. Name parameter is name of the pool, not any name within it.

rea_pool *rea_get_default_pool(enum rea_default_pool)

Create pool that has one of the default namelists.

rea_pool *rea_pool_from_file(const char *filename)

Create pool from xml-file.

rea_pool *rea_pool_copy(rea_pool *pool)

Create new pool as copy of existing pool.

Operations on pools in librea

void rea_pool_merge(rea_pool *dest, rea_pool *src)

Add names from src pool to dest pool.

void rea_pool_deinit(rea_pool *pool)

No matter how you created the pool, you should free resources allocated for it with this function once you no longer need the pool.

Common librea++ functions

void reapp_init()

Initialize librea++. Needs to be called once before any other library calls.

void reapp_deinit()

Deinitializes librea++. No library functions may be called after this.

Getting random name in librea++

reapp_pool::random_name()

Method returns random name from the pool.

Pool constructors

reapp_pool::reapp_pool()

Create empty pool.

reapp_pool::reapp_pool(enum rea_default_pool)

Create pool that has one of the default namelists.

reapp_pool::reapp_pool(const reapp_pool &from)

Create new pool as copy of existing pool.

librea++ pool operators

= reapp_pool

Make pool identical to another.

+= reapp_pool

Add names from another pool.

reapp_pool + reapp_pool

Return pool that combines names from two other.

Default namelists

These are the default namelist types. There's builtin list of names associated with each of these.