eolian: add APIs to retrieve units from a state

This commit is contained in:
Daniel Kolesa 2018-02-27 13:24:05 +01:00
parent f5e3734cdd
commit e91ae3984a
2 changed files with 46 additions and 0 deletions

View File

@ -530,6 +530,35 @@ EAPI Eina_Bool eolian_state_directory_add(Eolian_State *state, const char *dir);
*/
EAPI Eina_Bool eolian_state_system_directory_add(Eolian_State *state);
/*
* @brief Get an Eolian unit by file name.
*
* For any .eo or .eot file (must be within a directory previously scanned
* by eolian_state_directory_add or eolian_state_system_directory_add), get
* its corresponding unit.
*
* This only works if the file has been previously parsed.
*
* @param[in] state The Eolian state.
* @param[in] file The file name.
*
* @see eolian_state_units_get
*
* @ingroup Eolian
*/
EAPI const Eolian_Unit *eolian_state_unit_by_file_get(const Eolian_State *state, const char *file_name);
/*
* @brief Get an iterator to all Eolian units in a state.
*
* This means units of all files that have been parsed so far.
*
* @param[in] state The Eolian state.
*
* @ingroup Eolian
*/
EAPI Eina_Iterator *eolian_state_units_get(const Eolian_State *state);
/*
* @brief Parse the given .eo or .eot file and fill the database.
*

View File

@ -660,6 +660,23 @@ eolian_system_directory_scan(Eolian_State *state)
return eolian_state_system_directory_add(state);
}
EAPI const Eolian_Unit *
eolian_state_unit_by_file_get(const Eolian_State *state, const char *file_name)
{
if (!state) return NULL;
Eina_Stringshare *shr = eina_stringshare_add(file_name);
Eolian_Unit *unit = eina_hash_find(state->units, shr);
eina_stringshare_del(shr);
return unit;
}
EAPI Eina_Iterator *
eolian_state_units_get(const Eolian_State *state)
{
if (!state) return NULL;
return eina_hash_iterator_data_new(state->units);
}
char *
database_class_to_filename(const char *cname)
{