summaryrefslogtreecommitdiff
path: root/core/XML_Parser/asm-xml.h
diff options
context:
space:
mode:
Diffstat (limited to 'core/XML_Parser/asm-xml.h')
-rw-r--r--core/XML_Parser/asm-xml.h162
1 files changed, 162 insertions, 0 deletions
diff --git a/core/XML_Parser/asm-xml.h b/core/XML_Parser/asm-xml.h
new file mode 100644
index 00000000..38dcb639
--- /dev/null
+++ b/core/XML_Parser/asm-xml.h
@@ -0,0 +1,162 @@
1/****************************************************************************
2* *
3* asm-xml.h *
4* *
5* Copyright (C) 2007-08 Marc Kerbiquet *
6* *
7****************************************************************************/
8
9#ifdef WIN32
10 #define ACC __cdecl
11#else
12 #define ACC
13#endif
14
15#ifdef __cplusplus
16extern "C" {
17#endif
18
19//-----------------------------------------------------------------------------
20// Error Codes
21//-----------------------------------------------------------------------------
22#define RC_OK 0 // everything is ok
23#define RC_MEMORY 1 // out of memory
24
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'
34
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
46
47//-----------------------------------------------------------------------------
48// Structures
49//-----------------------------------------------------------------------------
50typedef struct AXElement AXElement ;
51typedef struct AXAttribute AXAttribute ;
52typedef struct AXElementClass AXElementClass ;
53typedef struct AXParseContext AXParseContext ;
54typedef struct AXClassContext AXClassContext ;
55
56struct AXElementClass
57{
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
70 // definition file.
71 int reserved ;
72 void* reserved2 ;
73};
74
75struct AXClassContext
76{
77 void* base ;
78 void* limit ;
79 void* chunks ;
80 int chunkSize ;
81 int errorCode ;
82 int line ;
83 int column ;
84 AXElementClass** classes ; // all global classes
85 AXElementClass* rootClass ; // the root class
86 AXElement* rootElement ;
87};
88
89struct AXAttribute
90{
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
96};
97
98struct AXElement
99{
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
107};
108
109struct AXParseContext
110{
111 void* base ;
112 void* limit ;
113 void* chunks ;
114 int chunkSize ;
115 int errorCode ;
116 const char* source ;
117 const char* current ;
118 int line ;
119 int column ;
120 AXElement* root ;
121 AXAttribute version ;
122 AXAttribute encoding ;
123 int strict ;
124 int reserved1 ;
125 AXElement reserved2 ;
126};
127
128//-----------------------------------------------------------------------------
129// Functions
130//-----------------------------------------------------------------------------
131
132extern
133void ACC ax_initialize (void* mallocFun,
134 void* freeFun);
135extern
136int ACC ax_initializeParser (AXParseContext* context,
137 unsigned int chunkSize);
138extern
139int ACC ax_releaseParser (AXParseContext* context);
140extern
141AXElement* ACC ax_parse (AXParseContext* context,
142 const char* source,
143 AXElementClass* type,
144 int strict);
145extern
146int ACC ax_initializeClassParser (AXClassContext* context);
147extern
148int ACC ax_releaseClassParser (AXClassContext* context);
149extern
150AXElementClass* ACC ax_classFromElement (AXElement* e,
151 AXClassContext* context);
152extern
153AXElementClass* ACC ax_classFromString (const char* source,
154 AXClassContext* context);
155
156#define ax_getElement(element, index) ((AXElement*)element->attributes[index].begin)
157#define ax_getAttribute(element, index) (&element->attributes[index])
158
159
160#ifdef __cplusplus
161}
162#endif