version 1.1, 2006/04/27 15:51:47
|
version 1.2, 2006/04/28 10:18:50
|
Line 2
|
Line 2
|
#define TEMPLATE_DECLARATIONS |
#define TEMPLATE_DECLARATIONS |
|
|
#define PREDEFINED_LIB "-Predefined-" |
#define PREDEFINED_LIB "-Predefined-" |
|
#define COMPONENT 0 |
|
#define SIMPLE_TYPE 1 |
|
#define ELEMENT 2 |
|
#define UNION 3 |
|
|
|
#define XTIGER_NUMBER 0 |
|
#define XTIGER_STRING 1 |
|
#define XTIGER_BOOLEAN 2 |
|
#define XTIGER_CUSTOM 3 |
|
|
#define THOT_EXPORT extern |
#define THOT_EXPORT extern |
#include "amaya.h" |
#include "amaya.h" |
#include "document.h" |
#include "document.h" |
#include "mydictionary.h" |
#include "mydictionary.h" |
|
|
/*---------------------------------------------------------------------- |
/* Structure of a template */ |
Structure of a template |
|
----------------------------------------------------------------------*/ |
|
struct _XTigerTemplate; |
struct _XTigerTemplate; |
typedef struct _XTigerTemplate *XTigerTemplate; |
typedef struct _XTigerTemplate *XTigerTemplate; |
|
|
struct _XTigerTemplate { |
struct _XTigerTemplate |
bool isLibrary; //Is this a library? (otherway it's a template) |
{ |
DicDictionary libraries; //Imported libraries |
ThotBool isLibrary; //Is this a library? (otherway it's a template) |
DicDictionary declaredTypes; //All types declared in the document |
DicDictionary libraries; //Imported libraries |
int documentUsingMe; //How many documents are using this template or library? |
DicDictionary declaredTypes; //All types declared in the document |
|
int documentUsingMe; //How many documents are using this template or library? |
}; |
}; |
|
|
/*---------------------------------------------------------------------- |
/* Structure of a Declaration */ |
Structure of a Declaration |
typedef int TypeNature; |
----------------------------------------------------------------------*/ |
typedef int SimpleTypeType; |
typedef enum TypeNatureEnum { SIMPLE_TYPE, COMPONENT, UNION } TypeNature; |
|
typedef enum SimpleTypeEnum { XTIGER_INTEGER, XTIGER_STRING, XTIGER_BOOLEAN, XTIGER_CUSTOM } SimpleTypeType; |
|
|
|
typedef struct _SimpleType { |
typedef struct _SimpleType |
|
{ |
SimpleTypeType type; |
SimpleTypeType type; |
} SimpleType; |
} SimpleType; |
|
|
typedef struct _Component { |
typedef struct _Component |
Element content; |
{ |
|
Element content; |
} Component; |
} Component; |
|
|
typedef struct _Union { |
typedef struct _Union |
DicDictionary include; //Dictionary<Declaration> |
{ |
DicDictionary exclude; //Dictionary<Declaration> |
DicDictionary include; //Dictionary<Declaration> |
|
DicDictionary exclude; //Dictionary<Declaration> |
} Union; |
} Union; |
|
|
typedef struct _Declaration { |
typedef struct _Declaration |
char *name; |
{ |
TypeNature nature; |
char *name; |
|
TypeNature nature; |
XTigerTemplate declaredIn; |
XTigerTemplate declaredIn; |
union { |
union |
SimpleType simpleType; |
{ |
Component componentType; |
SimpleType simpleType; |
Union unionType; |
Component componentType; |
|
Union unionType; |
}; |
}; |
} *Declaration; |
} *Declaration; |
|
|
|
THOT_EXPORT DicDictionary templates; |
|
|
/*---------------------------------------------------------------------- |
/*---------------------------------------------------------------------- |
Initializing the template environment |
Returns a library with the predefined types |
----------------------------------------------------------------------*/ |
----------------------------------------------------------------------*/ |
|
extern XTigerTemplate CreatePredefinedTypesLibrary ( void ); |
|
|
DicDictionary InitializeTemplateEnvironment(); |
/*---------------------------------------------------------------------- |
|
Initializing the template environment |
|
----------------------------------------------------------------------*/ |
|
extern DicDictionary InitializeTemplateEnvironment ( void ); |
|
|
/*---------------------------------------------------------------------- |
/*---------------------------------------------------------------------- |
Creation and freeing of declarations |
|
----------------------------------------------------------------------*/ |
----------------------------------------------------------------------*/ |
Declaration NewDeclaration(const XTigerTemplate t, const char *name, TypeNature type); |
extern Declaration NewSimpleType ( const XTigerTemplate t, |
|
const char *name, |
|
TypeNature xtype ); |
|
|
Declaration NewSimpleType(const XTigerTemplate t, const char *name, SimpleTypeType type); |
/*---------------------------------------------------------------------- |
|
----------------------------------------------------------------------*/ |
|
extern Declaration NewComponent ( const XTigerTemplate t, |
|
const char *name, |
|
const Element el ); |
|
|
Declaration NewComponent(const XTigerTemplate t, const char *name, const Element el); |
/*---------------------------------------------------------------------- |
|
----------------------------------------------------------------------*/ |
|
extern Declaration NewUnion ( const XTigerTemplate t, |
|
const char *name, |
|
DicDictionary include, |
|
DicDictionary exclude ); |
|
|
Declaration NewUnion(const XTigerTemplate t, const char *name, DicDictionary include, DicDictionary exclude); |
/*---------------------------------------------------------------------- |
|
----------------------------------------------------------------------*/ |
|
extern void FreeDeclaration ( Declaration dec ); |
|
|
void FreeDeclaration(Declaration dec); |
/*---------------------------------------------------------------------- |
|
Creates a new template with its dictionaries |
|
----------------------------------------------------------------------*/ |
|
extern XTigerTemplate NewXTigerTemplate ( ThotBool addPredefined ); |
|
|
/*---------------------------------------------------------------------- |
/*---------------------------------------------------------------------- |
Creates a new template with its dictionaries |
Free all the space used by a template (also its dictionaries) |
----------------------------------------------------------------------*/ |
----------------------------------------------------------------------*/ |
XTigerTemplate NewXTigerTemplate(bool addPredefined = true); |
extern void FreeXTigerTemplate ( XTigerTemplate t ); |
|
|
void FreeXTigerTemplate(XTigerTemplate t); |
/*---------------------------------------------------------------------- |
|
Imports all declarations in a library lib to a template t |
|
----------------------------------------------------------------------*/ |
|
extern void AddLibraryDeclarations (XTigerTemplate t, XTigerTemplate lib); |
|
|
#endif //TEMPLATE_DECLARATIONS |
|
|
|
|
#endif //TEMPLATE_DECLARATIONS |