![]() |
![]() |
![]() |
liblangtag Documentation | ![]() |
---|---|---|---|---|
Top | Description |
Module - AccessorModule - Accessor — A module class to extend features in lt_extension_t. |
#define LT_EXT_MODULE_VERSION lt_ext_module_data_t * (*lt_ext_module_data_new_func_t) (void
); struct lt_ext_module_funcs_t; const lt_ext_module_funcs_t * (*lt_ext_module_get_funcs_func_t) (void
); gchar * (*lt_ext_module_get_tag_func_t) (lt_ext_module_data_t *data
); gboolean (*lt_ext_module_parse_func_t) (lt_ext_module_data_t *data
,const gchar *subtag
,GError **error
); lt_ext_module_t * lt_ext_module_ref (lt_ext_module_t *module
); gchar (*lt_ext_module_singleton_func_t) (void
); lt_ext_module_t; void lt_ext_module_unref (lt_ext_module_t *module
); gboolean (*lt_ext_module_validate_func_t) (lt_ext_module_data_t *data
); gint (*lt_ext_module_version_func_t) (void
); void lt_ext_modules_load (void
); void lt_ext_modules_unload (void
); const lt_ext_module_funcs_t * module_get_funcs (void
); int module_get_version (void
);
This class provides functionality to extend features in lt_extension_t, such as validating tags more strictly.
#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_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. |
struct lt_ext_module_funcs_t { const lt_ext_module_singleton_func_t get_singleton; const lt_ext_module_data_new_func_t create_data; const lt_ext_module_precheck_func_t precheck_tag; const lt_ext_module_parse_func_t parse_tag; const lt_ext_module_get_tag_func_t get_tag; const 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.
const lt_ext_module_singleton_func_t |
A callback function to obtain the singleton character that are supposed in the module. |
const lt_ext_module_data_new_func_t |
A callback function to create a new instance of lt_ext_module_data_t for the module. |
A callback function to check tags prior to parse subtags. | |
const lt_ext_module_parse_func_t |
A callback function to parse a tag. |
const lt_ext_module_get_tag_func_t |
A callback function to obtain the tag string. |
const lt_ext_module_validate_func_t |
A callback function to validate the tag. |
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] |
gchar * (*lt_ext_module_get_tag_func_t) (lt_ext_module_data_t *data
);
The type of the callback function used to obtain the tag.
|
a lt_ext_module_data_t. |
Returns : |
a tag string. |
gboolean (*lt_ext_module_parse_func_t) (lt_ext_module_data_t *data
,const gchar *subtag
,GError **error
);
The type of the callback function used to parse tags.
|
a lt_ext_module_data_t. |
|
a subtag string to parse. |
|
a GError. [allow-none] |
Returns : |
TRUE if the subtag is valid for Extension. otherwise FALSE . |
lt_ext_module_t * lt_ext_module_ref (lt_ext_module_t *module
);
Increases the reference count of module
.
|
a lt_ext_module_t. |
Returns : |
the same module object. [transfer none]
|
gchar (*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. |
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.
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).
|
a lt_ext_module_t. |
gboolean (*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
.
|
a lt_ext_module_data_t. |
Returns : |
TRUE if it's valid, otherwise FALSE . |
gint (*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. |
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.
void lt_ext_modules_unload (void
);
Unload all of the modules already loaded.
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. |
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. |