]> git.cworth.org Git - wordgame/blobdiff - dict.h
Complete the dict layer by adding dict_cursor_t and dict_entry_t
[wordgame] / dict.h
diff --git a/dict.h b/dict.h
index e58c8b4c4e3c992ca82ff67c0c04039af43fc8f1..d87e7659031e3497a1158a94ffde33ed948e82d8 100644 (file)
--- a/dict.h
+++ b/dict.h
 
 /* Only looks opaque. Perfectly stack-allocatable */
 typedef trie_t dict_t;
+typedef trie_t *dict_cursor_t;
+typedef uint32_t dict_entry_t;
 
+/* Initialization and cleanup */
 void
 dict_init (dict_t *dict);
 
+void
+dict_fini (dict_t *dict);
+
+/* Adding new words */
 void
 dict_add_word (dict_t          *dict,
               const char       *word);
@@ -34,7 +41,27 @@ void
 dict_add_words_from_file (dict_t       *dict,
                          const char    *filename);
 
-void
-dict_fini (dict_t *dict);
+/* Looking up an entry in the dictionary */
+dict_entry_t *
+dict_lookup (dict_t    *dict,
+            const char *word);
+
+/* Querying a dictionary entry. The dict interface uses 1 bit.
+ * All of the remaining bits are available for application use.
+ */
+#define DICT_ENTRY_IS_WORD(entry) ((entry) && ((*entry) & 0x01))
+
+/* Character-by-character perusal of the dictionary */
+dict_cursor_t
+dict_root (dict_t *dict);
+
+dict_cursor_t
+dict_cursor_next (dict_cursor_t cursor,
+                 char          next);
+
+dict_entry_t *
+dict_cursor_resolve (dict_cursor_t cursor);
+
+#define DICT_CURSOR_NIL NULL
 
 #endif /* _DICT_H_ */