File:  [Public] / Amaya / amaya / templates.h
Revision 1.21: download - view: text, annotated - select for diffs
Wed Mar 26 10:34:05 2008 UTC (16 years, 2 months ago) by kia
Branches: MAIN
CVS tags: HEAD
Clean up in template management.

#ifndef TEMPLATE_TEMPLATES
#define TEMPLATE_TEMPLATES

#define THOT_EXPORT extern
#include "amaya.h"
#include "document.h"
#include "containers.h"
#include "MENUconf.h"


#define Template_Current_Version "0.9"


typedef enum _TemplateFlag
{
  templNone = 0,
  templTemplate    = 1 << 0,  // Template
  templLibraryFlag = 1 << 1,   // Library (implies template).
  templLibrary     = templLibraryFlag+templTemplate,
  templInstance    = 1 << 2,  // Instance of template
  
  templloaded      = 1 << 4,  // Template is really loaded.
  
  templInternal    = 1 << 8,  // Internal only, no edited document.
  templPredefined  = 1 << 9   // predefined library (base or html).
}TemplateFlag;


struct _XTigerTemplate;
typedef struct _XTigerTemplate *XTigerTemplate;
struct _XTigerTemplate
{
  int           state;          // Union of TemplateFlag
  char*         uri;            // Template URI (formerly name).
  char*         base_uri;       // URI of template if this is an instance.
  char*         version;        //Version of XTiger language
  char*         templateVersion;//Version of template

  HashMap       libraries;      //Imported libraries (StringHashMap<XTigerTemplate>)
  HashMap       simpleTypes;    //All simple types declared in the document (KeywordHashMap<Declaration>)
  HashMap       elements;       //All element types declared in the document (KeywordHashMap<Declaration>)
  HashMap       components;     //All component types declared in the document (KeywordHashMap<Declaration>)
  HashMap       unions;         //All union types declared in the document (KeywordHashMap<Declaration>)
  HashMap       unknowns;       //All unknown declarations, used in template parsing,

  Document      doc;            //Use to store component structures
  int           users;          //Number of documents using this template
  DLList        errorList;      //Error string list (DLList<char*>)
};


// Notes : 
// All KeywordHashMap<Declaration> must embed their own copy of their keys
// in order to prevent corruption.

// XTiger declaration nature
// Note : the order is very important for user presentation.
typedef enum _TypeNature
{
  SimpleTypeNat,
  UnionNat,
  ComponentNat,
  XmlElementNat,
  UnknownNat
} TypeNature;

// XTiger simple type
typedef enum _SimpleTypeType {XTNumber, XTString, XTBoolean} SimpleTypeType;

/* Structure of a Declaration */

typedef struct _XmlElement
{
	char	*name;
} XmlElement;

typedef struct _SimpleType
{
	SimpleTypeType type;
} SimpleType;

typedef struct _Component
{
	Element        content;
} Component_;

typedef struct _Union
{
	HashMap  include;  //KeywordHashMap<Declaration>
	HashMap  exclude;  //KeywordHashMap<Declaration>
  HashMap  expanded; //KeywordHashMap<Declaration>
} Union;

/* Structure of a declaration */
struct _Declaration;
typedef struct _Declaration *Declaration;

struct _Declaration
{
	char          *name;
	TypeNature     nature;
  ThotBool       blockLevel; // TRUE if the element is a block (not inline)
	XTigerTemplate declaredIn; // The template which declare the decl
  XTigerTemplate usedIn;     // The template which embed the decl
	union
	{
		SimpleType   simpleType;
		Component_   componentType;
		Union        unionType;
		XmlElement   elementType;
	};
};

struct menuType
{
	char        *label;
	TypeNature   type;
};

#endif /* TEMPLATE_TEMPLATES */

Webmaster