Module - Accessor: liblangtag Documentation

## Module - Accessor Module - Accessor — A module class to extend features in lt_extension_t. |

## Functions

int | (*lt_ext_module_version_func_t) ()
const lt_ext_module_funcs_t * | (*lt_ext_module_get_funcs_func_t) ()
char | (*lt_ext_module_singleton_func_t) ()
lt_ext_module_data_t * | (*lt_ext_module_data_new_func_t) ()
lt_bool_t | (*lt_ext_module_precheck_func_t) ()
lt_bool_t | (*lt_ext_module_parse_func_t) ()
char * | (*lt_ext_module_get_tag_func_t) ()
lt_bool_t | (*lt_ext_module_validate_func_t) ()
void | lt_ext_modules_load ()
void | lt_ext_modules_unload ()
lt_ext_module_t * | lt_ext_module_ref ()
void | lt_ext_module_unref ()
#define | LT_MODULE_SYMBOL()
#define | LT_MODULE_SYMBOL_()
#define | LT_MODULE_SYMBOL__()
int | module_get_version ()
const lt_ext_module_funcs_t * | module_get_funcs ()

## Types and Values

#define | LT_EXT_MODULE_VERSION
#define | LT_CONST_DECL
struct | lt_ext_module_funcs_t
| lt_ext_module_t

## Description

This class provides functionality to extend features in lt_extension_t, such as validating tags more strictly.

## Functions

### lt_ext_module_version_func_t ()

    int
    (*lt_ext_module_version_func_t) (void);

The type of the `module_get_version()` that is required to implement an extension module.

#### Returns

a version number. this is the same to LT_EXT_MODULE_VERSION when the module was built.

### lt_ext_module_get_funcs_func_t ()

    const lt_ext_module_funcs_t *
    (*lt_ext_module_get_funcs_func_t) (void);

The type of the `module_get_funcs()` that is required to implement an extension module.

#### Returns

a lt_ext_module_funcs_t.

[transfer none]

### lt_ext_module_singleton_func_t ()

    char
    (*lt_ext_module_singleton_func_t) (void);

The type of the callback function used to obtain a singleton character for Extension subtag that the module would support.

#### Returns

a singleton character.

### lt_ext_module_data_new_func_t ()

    lt_ext_module_data_t *
    (*lt_ext_module_data_new_func_t) (void);

The type of the callback function used to create a new instance of lt_ext_module_data_t. This is invoked when new Extension subtag appears and keep data.

#### Returns

a new instance of lt_ext_module_data_t.

### lt_ext_module_precheck_func_t ()

    lt_bool_t
    (*lt_ext_module_precheck_func_t) (lt_ext_module_data_t *data,
                                      const lt_tag_t *tag,
                                      lt_error_t **error);

The type of the callback function used to check `tag` prior to process parsing subtags for the extension.

#### Parameters

data | a lt_ext_module_data_t. |
tag | a lt_tag_t. |
error | a lt_error_t. | [allow-none]

#### Returns

`TRUE` if `tag` is valid to process parsing subtags for the extension. otherwise `FALSE`.

### lt_ext_module_parse_func_t ()

    lt_bool_t
    (*lt_ext_module_parse_func_t) (lt_ext_module_data_t *data,
                                   const char *subtag,
                                   lt_error_t **error);

The type of the callback function used to parse tags.

#### Parameters

data | a lt_ext_module_data_t. |
subtag | a subtag string to parse. |
error | a lt_error_t. | [allow-none]

#### Returns

`TRUE` if the `subtag` is valid for Extension. otherwise `FALSE`.

### lt_ext_module_get_tag_func_t ()

    char *
    (*lt_ext_module_get_tag_func_t) (lt_ext_module_data_t *data);

The type of the callback function used to obtain the tag.

#### Parameters

data | a lt_ext_module_data_t. |

#### Returns

a tag string.

### lt_ext_module_validate_func_t ()

    lt_bool_t
    (*lt_ext_module_validate_func_t) (lt_ext_module_data_t *data);

The type of the callback function used to validate the tags in `data` .

#### Parameters

data | a lt_ext_module_data_t. |

#### Returns

`TRUE` if it's valid, otherwise `FALSE`.

### lt_ext_modules_load ()

    void
    lt_ext_modules_load (void);

Load all of the modules on the system, including the internal accessor. This has to be invoked before processing something with lt_extension_t. or `lt_db_initialize()` does.

### lt_ext_modules_unload ()

    void
    lt_ext_modules_unload (void);

Unload all of the modules already loaded.

### lt_ext_module_ref ()

    lt_ext_module_t *
    lt_ext_module_ref (lt_ext_module_t *module);

Increases the reference count of `module` .

#### Parameters

module | a lt_ext_module_t. |

#### Returns

the same `module` object.

[transfer none]

### lt_ext_module_unref ()

    void
    lt_ext_module_unref (lt_ext_module_t *module);

Decreases the reference count of `module` . when its reference count drops to 0, the object is finalized (i.e. its memory is freed).

#### Parameters

module | a lt_ext_module_t. |

### LT_MODULE_SYMBOL()

    #  define LT_MODULE_SYMBOL(__sym__)		LT_MODULE_SYMBOL_(LT_MODULE_PREFIX, __sym__)

### LT_MODULE_SYMBOL_()

    #define LT_MODULE_SYMBOL_(__prefix__,__sym__) LT_MODULE_SYMBOL__(__prefix__, __sym__)

### LT_MODULE_SYMBOL__()

    #define LT_MODULE_SYMBOL__(__prefix__,__sym__) __prefix__##_module_##__sym__

### module_get_version ()

    int
    module_get_version (void);

Obtains the module version. this must be implemented in a module.

#### Returns

a version number. this is the same to LT_EXT_MODULE_VERSION when the module was built.

### module_get_funcs ()

    const lt_ext_module_funcs_t *
    module_get_funcs (void);

Obtains a lt_ext_module_funcs_t, callback collection structure that the module would process. this must be implemented in the external module.

#### Returns

a lt_ext_module_funcs_t.

## Types and Values

### LT_EXT_MODULE_VERSION

    #define LT_EXT_MODULE_VERSION		1

Static variable for the module version. this is used to ensure if the built module is compatible with the runtime library.

### LT_CONST_DECL

    #define LT_CONST_DECL

### struct lt_ext_module_funcs_t

    struct lt_ext_module_funcs_t {
    	LT_CONST_DECL lt_ext_module_singleton_func_t get_singleton;
    	LT_CONST_DECL lt_ext_module_data_new_func_t  create_data;
    	LT_CONST_DECL lt_ext_module_precheck_func_t  precheck_tag;
    	LT_CONST_DECL lt_ext_module_parse_func_t     parse_tag;
    	LT_CONST_DECL lt_ext_module_get_tag_func_t   get_tag;
    	LT_CONST_DECL lt_ext_module_validate_func_t  validate_tag;
    };

The lt_ext_module_funcs_t struct is a callback collection to provide an accessor between lt_extension_t and lt_ext_module_t and extend features.

#### Members

### lt_ext_module_t

    typedef struct _lt_ext_module_t lt_ext_module_t;

All the fields in the lt_ext_module_t structure are private to the lt_ext_module_t implementation.