Add some comments, fix cleanup, improve tests
[tedtools.git] / template.h
index 6f88989..7953de4 100644 (file)
@@ -38,7 +38,7 @@
  *      for all other. Currently, bool values have only "true"/"false"
  *      string values
  * <@IF EXPRESSION @>
- * <@ELSE@>
+ * [ <@ELSE@> ] 
  * <@ENDIF@>
  *
  * Expression is classical with support following:
@@ -63,7 +63,7 @@
  *      C-level.
  *
  * <@LOOP MARKNAME@>
- *             <@ SELF @>
+ *             [ <@ SELF @> ]
  * <@ENDLOOP@>
  * Loop has predefined variables:
  *    __FIRST   - true for first iteration
  *  setTemplateValueBool("outerLoop.var1");
  *     addTemplateRow("innerLoop");
  *  setTemplateValueBool("outerLoop.innerLoop.var2");
+ * - addTemplateNestedLoop
+ *   returnTemplateNestedLoop
+ *   Manage self-nested loops ( ie tree-like structures ).
+ *      Loop's template should contains one <@ SELF @> pointer.
+ *
+ * Examplaes of usage are in data/template.html used for test.
  *
  ******************************************************************************
  *                               Memory management                            * 
  * Unfortunatly, I'm too lazy to unify memory usage by several pieces
  * in library. So, library uses mixed plain malloc and memory context
  * concepts (tmalloc.h).
- * To work with library it's needed to allocate persitent memory context
- * for initTemplate() call and temprorary memory context for usual work.
+ * To work with library it's needed to allocate persistent memory context
+ * for initTemplate() call and provide temporary memory context for usual work.
  * after printTemplate is called it's needed to call resetTemplate() and 
  * then resetMemoryContext() for second context. 
  * 
@@ -251,7 +257,7 @@ typedef struct  TemplateNodeData {
                struct {
                        TemplateNode    loop;
                        LoopRow                 savedRowData;
-                       GList                   *childrenLoopAfterSelf;
+                       GList                   *childrenLoopAfterSelf; 
                } nest;
 
                /* LoopNode */
@@ -259,7 +265,7 @@ typedef struct  TemplateNodeData {
                        char                    *varName;
                        int                     varNameLength;
                        TemplateNode    bodyNode;
-                       TemplateNode    selfNode;
+                       TemplateNode    selfNode; /* pointer to self-nested plase to insert */
                        GList                   *childrenLoop;  /* to reset loop's instance  */
                        GList                   *listVarValues; /* list of loop variables */
                        GList                   *listInstance;
@@ -268,7 +274,7 @@ typedef struct  TemplateNodeData {
                                                                                 +->row
                                                                                 |
                                                                                 |
-                                                                                +->row->nestedinstance
+                                                                                +->row->currentInstance
                         */
                        LoopRow                 lastRow;
                        LoopInstance    currentInstance;