Database: liblangtag Documentation

## Database Database — convenient function sets to deal with the language tags database |

## Functions

void | lt_db_set_datadir ()
const char * | lt_db_get_datadir ()
void | lt_db_set_val ()
void | lt_db_initialize ()
void | lt_db_finalize ()
lt_lang_db_t * | lt_db_get_lang ()
lt_extlang_db_t * | lt_db_get_extlang ()
lt_script_db_t * | lt_db_get_script ()
lt_region_db_t * | lt_db_get_region ()
lt_variant_db_t * | lt_db_get_variant ()
lt_grandfathered_db_t * | lt_db_get_grandfathered ()
lt_redundant_db_t * | lt_db_get_redundant ()
lt_relation_db_t * | lt_db_get_relation ()

## Types and Values

struct | lt_db_val_t

## Description

This section describes convenient functions to obtain the database instance.

## Functions

### lt_db_set_datadir ()

    void
    lt_db_set_datadir (const char *path);

Set `path` as the default location of the database files. This has to be called before `lt_db_initialize()` or any initialization for each databases.

#### Parameters

path | the directory where database files are installed. |

### lt_db_get_datadir ()

    const char *
    lt_db_get_datadir (void);

Obtain the directory where database files are installed.

#### Returns

the directory name.

### lt_db_set_val ()

    void
    lt_db_set_val (lt_db_val_t *val);

Set `val` as the primary place of the database instance. This is useful if you don't want to held them into the global variable.

#### Parameters

val | a lt_db_val_t. |

### lt_db_initialize ()

    void
    lt_db_initialize (void);

Initialize all of the language tags database instance. If the databases are already initialized, it won't do nothing.

### lt_db_finalize ()

    void
    lt_db_finalize (void);

Decreases the reference count of the language tags database, which was increased with `lt_db_initialize()`.

### lt_db_get_lang ()

    lt_lang_db_t *
    lt_db_get_lang (void);

Obtains the instance of lt_lang_db_t. This still allows to use without `lt_db_initialize()`. but it will takes some time to load the database on the memory every time.

#### Returns

The instance of lt_lang_db_t.

### lt_db_get_extlang ()

    lt_extlang_db_t *
    lt_db_get_extlang (void);

Obtains the instance of lt_extlang_db_t. This still allows to use without `lt_db_initialize()`. but it will takes some time to load the database on the memory every time.

#### Returns

The instance of lt_extlang_db_t.

### lt_db_get_script ()

    lt_script_db_t *
    lt_db_get_script (void);

Obtains the instance of lt_script_db_t. This still allows to use without `lt_db_initialize()`. but it will takes some time to load the database on the memory every time.

#### Returns

The instance of lt_script_db_t.

### lt_db_get_region ()

    lt_region_db_t *
    lt_db_get_region (void);

Obtains the instance of lt_region_db_t. This still allows to use without `lt_db_initialize()`. but it will takes some time to load the database on the memory every time.

#### Returns

The instance of lt_region_db_t.

### lt_db_get_variant ()

    lt_variant_db_t *
    lt_db_get_variant (void);

Obtains the instance of lt_variant_db_t. This still allows to use without `lt_db_initialize()`. but it will takes some time to load the database on the memory every time.

#### Returns

The instance of lt_variant_db_t.

### lt_db_get_grandfathered ()

    lt_grandfathered_db_t *
    lt_db_get_grandfathered (void);

Obtains the instance of lt_grandfathered_db_t. This still allows to use without `lt_db_initialize()`. but it will takes some time to load the database on the memory every time.

#### Returns

The instance of lt_grandfathered_db_t.

### lt_db_get_redundant ()

    lt_redundant_db_t *
    lt_db_get_redundant (void);

Obtains the instance of lt_redundant_db_t. This still allows to use without `lt_db_initialize()`. but it will takes some time to load the database on the memory every time.

#### Returns

The instance of lt_redundant_db_t.

### lt_db_get_relation ()

    lt_relation_db_t *
    lt_db_get_relation (void);

Obtains the instance of lt_relation_db_t. This still allows to use without `lt_db_initialize()`. but it will takes some time to load the database on the memory every time.

#### Returns

The instance of lt_relation_db_t.

## Types and Values

### struct lt_db_val_t

    struct lt_db_val_t {
    	lt_lang_db_t          *lang;
    	lt_extlang_db_t       *extlang;
    	lt_script_db_t        *script;
    	lt_region_db_t        *region;
    	lt_variant_db_t       *variant;
    	lt_grandfathered_db_t *grandfathered;
    	lt_redundant_db_t     *redundant;
    	lt_relation_db_t      *relation;
    };

The database set of structure to peek instances of them. this is useful for the debugging purpose only.

#### Members

lt_lang_db_t *`lang`; | The placeholder to store the object of lt_lang_db_t. |
lt_extlang_db_t *`extlang`; | The placeholder to store the object of lt_extlang_db_t. |
lt_script_db_t *`script`; | The placeholder to sthre the object of lt_script_db_t. |
lt_region_db_t *`region`; | The placeholder to store the object of lt_region_db_t. |
lt_variant_db_t *`variant`; | The placeholder to store the object of lt_variant_db_t. |
lt_grandfathered_db_t *`grandfathered`; | The placeholder to store the object of lt_grandfathered_db_t. |
lt_redundant_db_t *`redundant`; | The placeholder to store the object of lt_redundant_db_t. |
lt_relation_db_t *`relation`; | The placeholder to store the object of lt_relation_db_t. |