Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
3584 sourcerer 1
/*
2
 * This file is part of Hubbub.
3
 * Licensed under the MIT License,
4
 *                http://www.opensource.org/licenses/mit-license.php
5
 * Copyright 2007 John-Mark Bell 
6
 */
7
 
8
#ifndef hubbub_types_h_
9
#define hubbub_types_h_
10
 
11
#ifdef __cplusplus
12
extern "C"
13
{
14
#endif
15
 
16
#include 
17
#include 
18
 
19
/** Source of charset information, in order of importance
20
 * A client-dictated charset will override all others.
21
 * A document-specified charset will override autodetection or the default */
22
typedef enum hubbub_charset_source {
23
	HUBBUB_CHARSET_UNKNOWN		= 0,	/**< Unknown */
24
	HUBBUB_CHARSET_TENTATIVE	= 1,	/**< Charset may be changed
25
						 * with further data */
26
	HUBBUB_CHARSET_CONFIDENT	= 2	/**< Charset definite */
27
} hubbub_charset_source;
28
 
29
/**
30
 * Content model flag
31
 */
32
typedef enum hubbub_content_model {
33
	HUBBUB_CONTENT_MODEL_PCDATA,
34
	HUBBUB_CONTENT_MODEL_RCDATA,
35
	HUBBUB_CONTENT_MODEL_CDATA,
36
	HUBBUB_CONTENT_MODEL_PLAINTEXT
37
} hubbub_content_model;
38
 
39
/**
40
 * Quirks mode flag
41
 */
42
typedef enum hubbub_quirks_mode {
43
	HUBBUB_QUIRKS_MODE_NONE,
44
	HUBBUB_QUIRKS_MODE_LIMITED,
45
	HUBBUB_QUIRKS_MODE_FULL
46
} hubbub_quirks_mode;
47
 
48
/**
49
 * Type of an emitted token
50
 */
51
typedef enum hubbub_token_type {
52
	HUBBUB_TOKEN_DOCTYPE,
53
	HUBBUB_TOKEN_START_TAG,
54
	HUBBUB_TOKEN_END_TAG,
55
	HUBBUB_TOKEN_COMMENT,
56
	HUBBUB_TOKEN_CHARACTER,
57
	HUBBUB_TOKEN_EOF
58
} hubbub_token_type;
59
 
60
/**
61
 * Possible namespaces
62
 */
63
typedef enum hubbub_ns {
64
	HUBBUB_NS_NULL,
65
	HUBBUB_NS_HTML,
66
	HUBBUB_NS_MATHML,
67
	HUBBUB_NS_SVG,
68
	HUBBUB_NS_XLINK,
69
	HUBBUB_NS_XML,
70
	HUBBUB_NS_XMLNS
71
} hubbub_ns;
72
 
73
/**
74
 * Tokeniser string type
75
 */
76
typedef struct hubbub_string {
77
	const uint8_t *ptr;		/**< Pointer to data */
78
	size_t len;			/**< Byte length of string */
79
} hubbub_string;
80
 
81
/**
82
 * Tag attribute data
83
 */
84
typedef struct hubbub_attribute {
85
	hubbub_ns ns;			/**< Attribute namespace */
86
	hubbub_string name;		/**< Attribute name */
87
	hubbub_string value;		/**< Attribute value */
88
} hubbub_attribute;
89
 
90
/**
91
 * Data for doctype token
92
 */
93
typedef struct hubbub_doctype {
94
	hubbub_string name;		/**< Doctype name */
95
 
96
	bool public_missing;		/**< Whether the public id is missing */
97
	hubbub_string public_id;	/**< Doctype public identifier */
98
 
99
	bool system_missing;		/**< Whether the system id is missing */
100
	hubbub_string system_id;	/**< Doctype system identifier */
101
 
102
	bool force_quirks;		/**< Doctype force-quirks flag */
103
} hubbub_doctype;
104
 
105
/**
106
 * Data for a tag
107
 */
108
typedef struct hubbub_tag {
109
	hubbub_ns ns;			/**< Tag namespace */
110
	hubbub_string name;		/**< Tag name */
111
	uint32_t n_attributes;		/**< Count of attributes */
112
	hubbub_attribute *attributes;	/**< Array of attribute data */
113
	bool self_closing;		/**< Whether the tag can have children */
114
} hubbub_tag;
115
 
116
/**
117
 * Token data
118
 */
119
typedef struct hubbub_token {
120
	hubbub_token_type type;		/**< The token type */
121
 
122
	union {
123
		hubbub_doctype doctype;
124
 
125
		hubbub_tag tag;
126
 
127
		hubbub_string comment;
128
 
129
		hubbub_string character;
130
	} data;				/**< Type-specific data */
131
} hubbub_token;
132
 
133
#ifdef __cplusplus
134
}
135
#endif
136
 
137
#endif