Annotation of Amaya/amaya/templates.h, revision 1.25

1.1       francesc    1: #ifndef TEMPLATE_TEMPLATES
                      2: #define TEMPLATE_TEMPLATES
                      3: 
                      4: #define THOT_EXPORT extern
                      5: #include "amaya.h"
                      6: #include "document.h"
1.15      kia         7: #include "containers.h"
1.8       kia         8: #include "MENUconf.h"
                      9: 
1.1       francesc   10: 
1.20      kia        11: #define Template_Current_Version "0.9"
                     12: 
                     13: 
1.21      kia        14: typedef enum _TemplateFlag
                     15: {
                     16:   templNone = 0,
                     17:   templTemplate    = 1 << 0,  // Template
                     18:   templLibraryFlag = 1 << 1,   // Library (implies template).
                     19:   templLibrary     = templLibraryFlag+templTemplate,
                     20:   templInstance    = 1 << 2,  // Instance of template
                     21:   
                     22:   templloaded      = 1 << 4,  // Template is really loaded.
                     23:   
                     24:   templInternal    = 1 << 8,  // Internal only, no edited document.
                     25:   templPredefined  = 1 << 9   // predefined library (base or html).
                     26: }TemplateFlag;
                     27: 
                     28: 
1.5       quint      29: struct _XTigerTemplate;
                     30: typedef struct _XTigerTemplate *XTigerTemplate;
                     31: struct _XTigerTemplate
1.21      kia        32: {
                     33:   int           state;          // Union of TemplateFlag
                     34:   char*         uri;            // Template URI (formerly name).
                     35:   char*         base_uri;       // URI of template if this is an instance.
1.22      kia        36:   char*         version;        // Version of XTiger language
                     37:   char*         templateVersion;// Version of template
1.21      kia        38: 
1.22      kia        39:   HashMap       libraries;      // Imported libraries (StringHashMap<XTigerTemplate>)
                     40:   
                     41:   SearchSet     simpleTypes;    // All simple types declared in the document (SearchSet<Declaration, char*>)
                     42:   SearchSet     elements;       // All element types declared in the document (SearchSet<Declaration, char*>)
                     43:   SearchSet     components;     // All component types declared in the document (SearchSet<Declaration, char*>)
                     44:   SearchSet     unions;         // All union types declared in the document (SearchSet<Declaration, char*>)
                     45:   SearchSet     unknowns;       // All unknown declarations, used in template parsing (SearchSet<Declaration, char*>)
                     46: 
                     47:   Document      doc;            // Use to store component structures
1.23      kia        48:   int           ref;            // Reference counting
1.22      kia        49:   SList         errorList;      // Error string list (DLList<char*>)
1.5       quint      50: };
                     51: 
1.21      kia        52: 
1.15      kia        53: // Notes : 
                     54: // All KeywordHashMap<Declaration> must embed their own copy of their keys
                     55: // in order to prevent corruption.
                     56: 
1.18      kia        57: // XTiger declaration nature
                     58: // Note : the order is very important for user presentation.
                     59: typedef enum _TypeNature
                     60: {
                     61:   SimpleTypeNat,
                     62:   UnionNat,
                     63:   ComponentNat,
1.19      kia        64:   XmlElementNat,
                     65:   UnknownNat
1.18      kia        66: } TypeNature;
1.6       quint      67: 
                     68: // XTiger simple type
                     69: typedef enum _SimpleTypeType {XTNumber, XTString, XTBoolean} SimpleTypeType;
                     70: 
1.5       quint      71: /* Structure of a Declaration */
                     72: typedef struct _XmlElement
                     73: {
                     74:        char    *name;
                     75: } XmlElement;
                     76: 
                     77: typedef struct _SimpleType
                     78: {
                     79:        SimpleTypeType type;
                     80: } SimpleType;
                     81: 
                     82: typedef struct _Component
                     83: {
                     84:        Element        content;
1.10      vatton     85: } Component_;
1.5       quint      86: 
                     87: typedef struct _Union
                     88: {
1.22      kia        89:   SearchSet  include;  // SearchSet<Declaration, char*>
                     90:   SearchSet  exclude;  // SearchSet<Declaration, char*>
                     91:   SearchSet  expanded; // SearchSet<Declaration, char*>
                     92:   char*      includeStr;
                     93:   char*      excludeStr;
1.5       quint      94: } Union;
                     95: 
1.6       quint      96: /* Structure of a declaration */
                     97: struct _Declaration;
                     98: typedef struct _Declaration *Declaration;
                     99: 
1.5       quint     100: struct _Declaration
                    101: {
                    102:        char          *name;
                    103:        TypeNature     nature;
1.25    ! vatton    104:        // TODO Change blockLevel with a triplet (block,inline, both) to use with union
        !           105:   int            blockLevel; // 0=unknown, 1=inline, 2=block, 3 = both
1.15      kia       106:        XTigerTemplate declaredIn; // The template which declare the decl
                    107:   XTigerTemplate usedIn;     // The template which embed the decl
1.5       quint     108:        union
                    109:        {
                    110:                SimpleType   simpleType;
1.10      vatton    111:                Component_   componentType;
1.5       quint     112:                Union        unionType;
                    113:                XmlElement   elementType;
                    114:        };
                    115: };
                    116: 
                    117: struct menuType
                    118: {
1.6       quint     119:        char        *label;
                    120:        TypeNature   type;
1.5       quint     121: };
1.2       francesc  122: 
1.1       francesc  123: #endif /* TEMPLATE_TEMPLATES */

Webmaster