aboutsummaryrefslogtreecommitdiff
path: root/include/ctemplates.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/ctemplates.h')
-rw-r--r--include/ctemplates.h21
1 files changed, 19 insertions, 2 deletions
diff --git a/include/ctemplates.h b/include/ctemplates.h
index df41085..ca77391 100644
--- a/include/ctemplates.h
+++ b/include/ctemplates.h
@@ -16,31 +16,48 @@
//Length of error messages
#define ERR_MSG_LEN 500
+/* A variable list, holds key-value pairs as (string -> (string | loop)) */
struct TMPL_varlist;
+/* A list structure, holds an array of varlists to be looped over*/
struct TMPL_loop;
/* Holdes all the data needed for a template*/
struct TMPL_templates;
+/* Adds a variable to a variable list under a certain name */
void TMPL_add_var_to_varlist(struct TMPL_varlist* vl, const char* name, const char* value);
+
+/* Adds a loop to a variable list under a certain name */
void TMPL_add_loop_to_varlist(struct TMPL_varlist* vl, const char* name, struct TMPL_loop* loop);
-void TMPL_add_varlist_to_loop(struct TMPL_loop* l, struct TMPL_varlist* vl);
+/* Adds a variable list as one of the varlists in a loop */
+void TMPL_add_varlist_to_loop(struct TMPL_loop* l, struct TMPL_varlist* vl);
+/* Create a new varlist. If allocation fails, the struct retuned will be NULL */
struct TMPL_varlist* TMPL_alloc_varlist(void);
+/* Frees a varlist (and recursively, any loops under it, any varlists under those loops, ect.) */
void TMPL_free_varlist(struct TMPL_varlist* t);
+/* Allocate a new template. If allocation fails, the struct retunred will be NULL */
struct TMPL_templates* TMPL_alloc_template(const char* t);
+/* Free a template. Do not use the string returned by TMPL_render() the template is freed */
void TMPL_free_template(struct TMPL_templates* t);
+/* Create a new loop. If allocation fails, the struct returned will be NULL */
struct TMPL_loop* TMPL_alloc_loop(void);
+/* Free a loop. If the loop is added to a varlist, just call free on the varlist
+and any loops that have been added to it will automatically be freed.*/
void TMPL_free_loop(struct TMPL_loop* tl);
+/* Takes a template and varlist, and collapses it into a string.
+If size_p is non-null, the size of the resulting string will be placed in it.
+If any errors happened the t->error will be non-zero and the error can be
+retreived with TMPL_err(t,&size)*/
char* TMPL_render(struct TMPL_templates* t, struct TMPL_varlist* varlist, size_t* size_p);
const char* TMPL_err(struct TMPL_templates* t,size_t* size);
-/*A debug function*/
+/* A debug functions */
void print_varlist(struct TMPL_varlist* vl);
void print_ast(struct TMPL_templates* root);