1
/****************************************************************************
5
* Copyright (C) 2007-08 Marc Kerbiquet *
7
****************************************************************************/
19
//-----------------------------------------------------------------------------
21
//-----------------------------------------------------------------------------
22
#define RC_OK 0 // everything is ok
23
#define RC_MEMORY 1 // out of memory
25
#define RC_EMPTY_NAME 10 // name empty or not defined
26
#define RC_ATTR_DEFINED 11 // attribute already defined
27
#define RC_ELEM_DEFINED 12 // element already defined
28
#define RC_SCHEMA_EMPTY 13 // schema does not contains a document
29
#define RC_DOCUMENT_DEFINED 14 // schema contains more than one document
30
#define RC_UNDEFINED_CLASS 15 // can't find collection in reference
31
#define RC_UNDEFINED_GROUP 16 // can't find a group in include
32
#define RC_INVALID_ID 17 // id is not a valid number
33
#define RC_INVALID_IGNORE 18 // ignore is not 'yes' or 'no'
35
#define RC_INVALID_ENTITY_REFERENCE 20 // must be amp, quot, lt, gt, or apos
36
#define RC_UNEXPECTED_END 21 // found last char too early
37
#define RC_INVALID_CHAR 22 // wrong char
38
#define RC_OVERFLOW 23 // number to big in char reference
39
#define RC_NO_START_TAG 24 // xml does not start with a tag
40
#define RC_TAG_MISMATCH 25 // invalid close tag
41
#define RC_INVALID_TAG 26 // invalid root element
42
#define RC_INVALID_ATTRIBUTE 27 // unknown attribute
43
#define RC_INVALID_PI 28 // invalid processing instruction (<?xml)
44
#define RC_INVALID_DOCTYPE 29 // duplicate doctype or after main element
45
#define RC_VERSION_EXPECTED 30 // version is missing in xml declaration
47
//-----------------------------------------------------------------------------
49
//-----------------------------------------------------------------------------
50
typedef struct AXElement AXElement ;
51
typedef struct AXAttribute AXAttribute ;
52
typedef struct AXElementClass AXElementClass ;
53
typedef struct AXParseContext AXParseContext ;
54
typedef struct AXClassContext AXClassContext ;
58
int offset ; // Offset of the element in attribute list
59
char* name ; // Name of the element (not zero terminated)
60
char* nameLimit ; // End of the name of the element
61
unsigned int size ; // size in bytes of an element of this class
62
unsigned int id ; // container, text or mixed
63
unsigned int type ; // container, text or mixed
64
unsigned int propertyCount ; // number of attributes and text elements
65
unsigned int childCount ; // number of child classes
66
int* attributes ; // (internal) attribute map
67
int* elements ; // (internal) element map
68
AXElementClass** children ; // The list of child classes.
69
// The order is the one defined in the class
84
AXElementClass** classes ; // all global classes
85
AXElementClass* rootClass ; // the root class
86
AXElement* rootElement ;
91
const char* begin ; // the value (not zero terminated)
92
// This slot can also contain an element if
93
// a <element> has been defined in schema;
94
// use ax_getElement() to retrieve it.
95
const char* limit ; // the end of the value
100
int id ; // the class of the element
101
AXElement* nextSibling ; // the next sibling element
102
AXElement* firstChild ; // the first child element
103
AXElement* lastChild ; // the last child element
104
AXAttribute reserved ; // do not use
105
AXAttribute attributes[1] ; // the array of attributes - there is
106
// no bound checking in C
109
struct AXParseContext
117
const char* current ;
121
AXAttribute version ;
122
AXAttribute encoding ;
125
AXElement reserved2 ;
128
//-----------------------------------------------------------------------------
130
//-----------------------------------------------------------------------------
133
void ACC ax_initialize (void* mallocFun,
136
int ACC ax_initializeParser (AXParseContext* context,
137
unsigned int chunkSize);
139
int ACC ax_releaseParser (AXParseContext* context);
141
AXElement* ACC ax_parse (AXParseContext* context,
143
AXElementClass* type,
146
int ACC ax_initializeClassParser (AXClassContext* context);
148
int ACC ax_releaseClassParser (AXClassContext* context);
150
AXElementClass* ACC ax_classFromElement (AXElement* e,
151
AXClassContext* context);
153
AXElementClass* ACC ax_classFromString (const char* source,
154
AXClassContext* context);
156
#define ax_getElement(element, index) ((AXElement*)element->attributes[index].begin)
157
#define ax_getAttribute(element, index) (&element->attributes[index])