eolian: add APIs to retrieve units from a state
authorDaniel Kolesa <d.kolesa@osg.samsung.com>
Tue, 27 Feb 2018 12:24:05 +0000 (13:24 +0100)
committerWonki Kim <wonki_.kim@samsung.com>
Tue, 10 Apr 2018 11:10:41 +0000 (20:10 +0900)
src/lib/eolian/Eolian.h
src/lib/eolian/eolian_database.c

index ef6cfca..94eb9a0 100644 (file)
@@ -531,6 +531,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.
  *
  * The input can be either a full path to the file or only a filename.
index eb51052..3749e51 100644 (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)
 {