1package svg
2
3// uses github.com/tdewolff/hasher
4//go:generate hasher -type=Hash -file=hash.go
5
6// Hash defines perfect hashes for a predefined list of strings
7type Hash uint32
8
9// Identifiers for the hashes associated with the text in the comments.
10const (
11	A                            Hash = 0x101   // a
12	Alignment_Baseline           Hash = 0x2e12  // alignment-baseline
13	BaseProfile                  Hash = 0xb     // baseProfile
14	Baseline_Shift               Hash = 0x380e  // baseline-shift
15	Buffered_Rendering           Hash = 0x5212  // buffered-rendering
16	Clip                         Hash = 0x6404  // clip
17	Clip_Path                    Hash = 0x6409  // clip-path
18	Clip_Rule                    Hash = 0x8009  // clip-rule
19	Color                        Hash = 0xd805  // color
20	Color_Interpolation          Hash = 0xd813  // color-interpolation
21	Color_Interpolation_Filters  Hash = 0xd81b  // color-interpolation-filters
22	Color_Profile                Hash = 0x1f70d // color-profile
23	Color_Rendering              Hash = 0x2320f // color-rendering
24	ContentScriptType            Hash = 0xa011  // contentScriptType
25	ContentStyleType             Hash = 0xb110  // contentStyleType
26	Cursor                       Hash = 0xc106  // cursor
27	D                            Hash = 0x5901  // d
28	Defs                         Hash = 0x36904 // defs
29	Direction                    Hash = 0x30c09 // direction
30	Display                      Hash = 0x9807  // display
31	Dominant_Baseline            Hash = 0x19211 // dominant-baseline
32	Enable_Background            Hash = 0x8811  // enable-background
33	FeImage                      Hash = 0x14507 // feImage
34	Fill                         Hash = 0xc904  // fill
35	Fill_Opacity                 Hash = 0x33d0c // fill-opacity
36	Fill_Rule                    Hash = 0xc909  // fill-rule
37	Filter                       Hash = 0xec06  // filter
38	Flood_Color                  Hash = 0xd20b  // flood-color
39	Flood_Opacity                Hash = 0x1050d // flood-opacity
40	Font                         Hash = 0x11404 // font
41	Font_Family                  Hash = 0x1140b // font-family
42	Font_Size                    Hash = 0x11f09 // font-size
43	Font_Size_Adjust             Hash = 0x11f10 // font-size-adjust
44	Font_Stretch                 Hash = 0x1370c // font-stretch
45	Font_Style                   Hash = 0x14c0a // font-style
46	Font_Variant                 Hash = 0x1560c // font-variant
47	Font_Weight                  Hash = 0x1620b // font-weight
48	ForeignObject                Hash = 0x16d0d // foreignObject
49	G                            Hash = 0x1601  // g
50	Glyph_Orientation_Horizontal Hash = 0x1d31c // glyph-orientation-horizontal
51	Glyph_Orientation_Vertical   Hash = 0x161a  // glyph-orientation-vertical
52	Height                       Hash = 0x6c06  // height
53	Href                         Hash = 0x14204 // href
54	Image                        Hash = 0x17a05 // image
55	Image_Rendering              Hash = 0x17a0f // image-rendering
56	Kerning                      Hash = 0x1bc07 // kerning
57	Letter_Spacing               Hash = 0x90e   // letter-spacing
58	Lighting_Color               Hash = 0x1ee0e // lighting-color
59	Line                         Hash = 0x3c04  // line
60	Marker                       Hash = 0x18906 // marker
61	Marker_End                   Hash = 0x1890a // marker-end
62	Marker_Mid                   Hash = 0x1a30a // marker-mid
63	Marker_Start                 Hash = 0x1ad0c // marker-start
64	Mask                         Hash = 0x1b904 // mask
65	Metadata                     Hash = 0x1c308 // metadata
66	Missing_Glyph                Hash = 0x1cb0d // missing-glyph
67	Opacity                      Hash = 0x10b07 // opacity
68	Overflow                     Hash = 0x26208 // overflow
69	Paint_Order                  Hash = 0x2ae0b // paint-order
70	Path                         Hash = 0x6904  // path
71	Pattern                      Hash = 0x20407 // pattern
72	Pointer_Events               Hash = 0x20b0e // pointer-events
73	Points                       Hash = 0x22706 // points
74	Polygon                      Hash = 0x24107 // polygon
75	Polyline                     Hash = 0x24808 // polyline
76	PreserveAspectRatio          Hash = 0x25013 // preserveAspectRatio
77	Rect                         Hash = 0x30e04 // rect
78	Rx                           Hash = 0x4f02  // rx
79	Ry                           Hash = 0xc602  // ry
80	Script                       Hash = 0xf206  // script
81	Shape_Rendering              Hash = 0x2180f // shape-rendering
82	Solid_Color                  Hash = 0x22c0b // solid-color
83	Solid_Opacity                Hash = 0x36c0d // solid-opacity
84	Stop_Color                   Hash = 0x12d0a // stop-color
85	Stop_Opacity                 Hash = 0x2740c // stop-opacity
86	Stroke                       Hash = 0x28006 // stroke
87	Stroke_Dasharray             Hash = 0x28010 // stroke-dasharray
88	Stroke_Dashoffset            Hash = 0x29011 // stroke-dashoffset
89	Stroke_Linecap               Hash = 0x2a10e // stroke-linecap
90	Stroke_Linejoin              Hash = 0x2b90f // stroke-linejoin
91	Stroke_Miterlimit            Hash = 0x2c811 // stroke-miterlimit
92	Stroke_Opacity               Hash = 0x2d90e // stroke-opacity
93	Stroke_Width                 Hash = 0x2e70c // stroke-width
94	Style                        Hash = 0x15105 // style
95	Svg                          Hash = 0x2f303 // svg
96	Switch                       Hash = 0x2f606 // switch
97	Symbol                       Hash = 0x2fc06 // symbol
98	Text_Anchor                  Hash = 0x450b  // text-anchor
99	Text_Decoration              Hash = 0x710f  // text-decoration
100	Text_Rendering               Hash = 0xf70e  // text-rendering
101	Type                         Hash = 0x11004 // type
102	Unicode_Bidi                 Hash = 0x3020c // unicode-bidi
103	Use                          Hash = 0x31503 // use
104	Vector_Effect                Hash = 0x3180d // vector-effect
105	Version                      Hash = 0x32507 // version
106	ViewBox                      Hash = 0x32c07 // viewBox
107	Viewport_Fill                Hash = 0x3340d // viewport-fill
108	Viewport_Fill_Opacity        Hash = 0x33415 // viewport-fill-opacity
109	Visibility                   Hash = 0x3490a // visibility
110	White_Space                  Hash = 0x2690b // white-space
111	Width                        Hash = 0x2ee05 // width
112	Word_Spacing                 Hash = 0x3530c // word-spacing
113	Writing_Mode                 Hash = 0x35f0c // writing-mode
114	X                            Hash = 0x4701  // x
115	X1                           Hash = 0x5002  // x1
116	X2                           Hash = 0x33202 // x2
117	Xml_Space                    Hash = 0x37909 // xml:space
118	Y                            Hash = 0x1801  // y
119	Y1                           Hash = 0x9e02  // y1
120	Y2                           Hash = 0xc702  // y2
121)
122
123var HashMap = map[string]Hash{
124	"a":                            A,
125	"alignment-baseline":           Alignment_Baseline,
126	"baseProfile":                  BaseProfile,
127	"baseline-shift":               Baseline_Shift,
128	"buffered-rendering":           Buffered_Rendering,
129	"clip":                         Clip,
130	"clip-path":                    Clip_Path,
131	"clip-rule":                    Clip_Rule,
132	"color":                        Color,
133	"color-interpolation":          Color_Interpolation,
134	"color-interpolation-filters":  Color_Interpolation_Filters,
135	"color-profile":                Color_Profile,
136	"color-rendering":              Color_Rendering,
137	"contentScriptType":            ContentScriptType,
138	"contentStyleType":             ContentStyleType,
139	"cursor":                       Cursor,
140	"d":                            D,
141	"defs":                         Defs,
142	"direction":                    Direction,
143	"display":                      Display,
144	"dominant-baseline":            Dominant_Baseline,
145	"enable-background":            Enable_Background,
146	"feImage":                      FeImage,
147	"fill":                         Fill,
148	"fill-opacity":                 Fill_Opacity,
149	"fill-rule":                    Fill_Rule,
150	"filter":                       Filter,
151	"flood-color":                  Flood_Color,
152	"flood-opacity":                Flood_Opacity,
153	"font":                         Font,
154	"font-family":                  Font_Family,
155	"font-size":                    Font_Size,
156	"font-size-adjust":             Font_Size_Adjust,
157	"font-stretch":                 Font_Stretch,
158	"font-style":                   Font_Style,
159	"font-variant":                 Font_Variant,
160	"font-weight":                  Font_Weight,
161	"foreignObject":                ForeignObject,
162	"g":                            G,
163	"glyph-orientation-horizontal": Glyph_Orientation_Horizontal,
164	"glyph-orientation-vertical":   Glyph_Orientation_Vertical,
165	"height":                       Height,
166	"href":                         Href,
167	"image":                        Image,
168	"image-rendering":              Image_Rendering,
169	"kerning":                      Kerning,
170	"letter-spacing":               Letter_Spacing,
171	"lighting-color":               Lighting_Color,
172	"line":                         Line,
173	"marker":                       Marker,
174	"marker-end":                   Marker_End,
175	"marker-mid":                   Marker_Mid,
176	"marker-start":                 Marker_Start,
177	"mask":                         Mask,
178	"metadata":                     Metadata,
179	"missing-glyph":                Missing_Glyph,
180	"opacity":                      Opacity,
181	"overflow":                     Overflow,
182	"paint-order":                  Paint_Order,
183	"path":                         Path,
184	"pattern":                      Pattern,
185	"pointer-events":               Pointer_Events,
186	"points":                       Points,
187	"polygon":                      Polygon,
188	"polyline":                     Polyline,
189	"preserveAspectRatio":          PreserveAspectRatio,
190	"rect":                         Rect,
191	"rx":                           Rx,
192	"ry":                           Ry,
193	"script":                       Script,
194	"shape-rendering":              Shape_Rendering,
195	"solid-color":                  Solid_Color,
196	"solid-opacity":                Solid_Opacity,
197	"stop-color":                   Stop_Color,
198	"stop-opacity":                 Stop_Opacity,
199	"stroke":                       Stroke,
200	"stroke-dasharray":             Stroke_Dasharray,
201	"stroke-dashoffset":            Stroke_Dashoffset,
202	"stroke-linecap":               Stroke_Linecap,
203	"stroke-linejoin":              Stroke_Linejoin,
204	"stroke-miterlimit":            Stroke_Miterlimit,
205	"stroke-opacity":               Stroke_Opacity,
206	"stroke-width":                 Stroke_Width,
207	"style":                        Style,
208	"svg":                          Svg,
209	"switch":                       Switch,
210	"symbol":                       Symbol,
211	"text-anchor":                  Text_Anchor,
212	"text-decoration":              Text_Decoration,
213	"text-rendering":               Text_Rendering,
214	"type":                         Type,
215	"unicode-bidi":                 Unicode_Bidi,
216	"use":                          Use,
217	"vector-effect":                Vector_Effect,
218	"version":                      Version,
219	"viewBox":                      ViewBox,
220	"viewport-fill":                Viewport_Fill,
221	"viewport-fill-opacity":        Viewport_Fill_Opacity,
222	"visibility":                   Visibility,
223	"white-space":                  White_Space,
224	"width":                        Width,
225	"word-spacing":                 Word_Spacing,
226	"writing-mode":                 Writing_Mode,
227	"x":                            X,
228	"x1":                           X1,
229	"x2":                           X2,
230	"xml:space":                    Xml_Space,
231	"y":                            Y,
232	"y1":                           Y1,
233	"y2":                           Y2,
234}
235
236// String returns the text associated with the hash.
237func (i Hash) String() string {
238	return string(i.Bytes())
239}
240
241// Bytes returns the text associated with the hash.
242func (i Hash) Bytes() []byte {
243	start := uint32(i >> 8)
244	n := uint32(i & 0xff)
245	if start+n > uint32(len(_Hash_text)) {
246		return []byte{}
247	}
248	return _Hash_text[start : start+n]
249}
250
251// ToHash returns a hash Hash for a given []byte. Hash is a uint32 that is associated with the text in []byte. It returns zero if no match found.
252func ToHash(s []byte) Hash {
253	if 3 < len(s) {
254		return HashMap[string(s)]
255	}
256	h := uint32(_Hash_hash0)
257	for i := 0; i < len(s); i++ {
258		h ^= uint32(s[i])
259		h *= 16777619
260	}
261	if i := _Hash_table[h&uint32(len(_Hash_table)-1)]; int(i&0xff) == len(s) {
262		t := _Hash_text[i>>8 : i>>8+i&0xff]
263		for i := 0; i < len(s); i++ {
264			if t[i] != s[i] {
265				goto NEXT
266			}
267		}
268		return i
269	}
270NEXT:
271	if i := _Hash_table[(h>>16)&uint32(len(_Hash_table)-1)]; int(i&0xff) == len(s) {
272		t := _Hash_text[i>>8 : i>>8+i&0xff]
273		for i := 0; i < len(s); i++ {
274			if t[i] != s[i] {
275				return 0
276			}
277		}
278		return i
279	}
280	return 0
281}
282
283const _Hash_hash0 = 0x2d0dfdc1
284const _Hash_maxLen = 28
285
286var _Hash_text = []byte("" +
287	"baseProfiletter-spacinglyph-orientation-verticalignment-base" +
288	"line-shiftext-anchorx1buffered-renderingclip-patheightext-de" +
289	"corationclip-rulenable-backgroundisplay1contentScriptTypecon" +
290	"tentStyleTypecursory2fill-ruleflood-color-interpolation-filt" +
291	"erscriptext-renderingflood-opacitypefont-familyfont-size-adj" +
292	"ustop-colorfont-stretchrefeImagefont-stylefont-variantfont-w" +
293	"eightforeignObjectimage-renderingmarker-endominant-baselinem" +
294	"arker-midmarker-startmaskerningmetadatamissing-glyph-orienta" +
295	"tion-horizontalighting-color-profilepatternpointer-eventshap" +
296	"e-renderingpointsolid-color-renderingpolygonpolylinepreserve" +
297	"AspectRatioverflowhite-spacestop-opacitystroke-dasharraystro" +
298	"ke-dashoffsetstroke-linecapaint-orderstroke-linejoinstroke-m" +
299	"iterlimitstroke-opacitystroke-widthsvgswitchsymbolunicode-bi" +
300	"directionusevector-effectversionviewBox2viewport-fill-opacit" +
301	"yvisibilityword-spacingwriting-modefsolid-opacityxml:space")
302
303var _Hash_table = [1 << 7]Hash{
304	0x1:  0x2f303, // svg
305	0x2:  0x2f606, // switch
306	0x3:  0x18906, // marker
307	0x5:  0x1620b, // font-weight
308	0x6:  0x1801,  // y
309	0x7:  0x33d0c, // fill-opacity
310	0x8:  0x2e70c, // stroke-width
311	0x9:  0x33415, // viewport-fill-opacity
312	0xa:  0x9807,  // display
313	0xb:  0xb110,  // contentStyleType
314	0xc:  0x30c09, // direction
315	0xd:  0x20407, // pattern
316	0xf:  0x1f70d, // color-profile
317	0x10: 0xc602,  // ry
318	0x12: 0x1ad0c, // marker-start
319	0x13: 0x1050d, // flood-opacity
320	0x14: 0x36c0d, // solid-opacity
321	0x15: 0x90e,   // letter-spacing
322	0x16: 0x17a05, // image
323	0x17: 0x1890a, // marker-end
324	0x18: 0x2c811, // stroke-miterlimit
325	0x19: 0x20b0e, // pointer-events
326	0x1a: 0x12d0a, // stop-color
327	0x1b: 0x1b904, // mask
328	0x1c: 0xc904,  // fill
329	0x1d: 0xc909,  // fill-rule
330	0x1f: 0x26208, // overflow
331	0x20: 0x1a30a, // marker-mid
332	0x21: 0x1bc07, // kerning
333	0x22: 0xa011,  // contentScriptType
334	0x23: 0x4f02,  // rx
335	0x24: 0x1560c, // font-variant
336	0x25: 0x3020c, // unicode-bidi
337	0x26: 0x2a10e, // stroke-linecap
338	0x27: 0xc106,  // cursor
339	0x28: 0x25013, // preserveAspectRatio
340	0x29: 0x14507, // feImage
341	0x2a: 0x2e12,  // alignment-baseline
342	0x2b: 0x33202, // x2
343	0x2c: 0x450b,  // text-anchor
344	0x2d: 0x1d31c, // glyph-orientation-horizontal
345	0x2e: 0xf206,  // script
346	0x2f: 0x3180d, // vector-effect
347	0x30: 0x1370c, // font-stretch
348	0x31: 0x36904, // defs
349	0x32: 0x29011, // stroke-dashoffset
350	0x33: 0x6c06,  // height
351	0x34: 0xd81b,  // color-interpolation-filters
352	0x36: 0x2ae0b, // paint-order
353	0x37: 0x19211, // dominant-baseline
354	0x38: 0x11404, // font
355	0x39: 0x24808, // polyline
356	0x3a: 0x32c07, // viewBox
357	0x3b: 0x4701,  // x
358	0x3c: 0x11004, // type
359	0x3d: 0x28010, // stroke-dasharray
360	0x3e: 0x5002,  // x1
361	0x3f: 0x5901,  // d
362	0x42: 0x8811,  // enable-background
363	0x43: 0x30e04, // rect
364	0x44: 0x2180f, // shape-rendering
365	0x46: 0x37909, // xml:space
366	0x47: 0x161a,  // glyph-orientation-vertical
367	0x48: 0x31503, // use
368	0x49: 0x3490a, // visibility
369	0x4a: 0x16d0d, // foreignObject
370	0x4b: 0x710f,  // text-decoration
371	0x4c: 0x15105, // style
372	0x4f: 0x17a0f, // image-rendering
373	0x50: 0x24107, // polygon
374	0x51: 0x5212,  // buffered-rendering
375	0x52: 0x1601,  // g
376	0x53: 0x1140b, // font-family
377	0x54: 0x14204, // href
378	0x55: 0xec06,  // filter
379	0x56: 0x1c308, // metadata
380	0x57: 0x1ee0e, // lighting-color
381	0x58: 0xf70e,  // text-rendering
382	0x59: 0x35f0c, // writing-mode
383	0x5a: 0x10b07, // opacity
384	0x5b: 0x9e02,  // y1
385	0x5c: 0xd20b,  // flood-color
386	0x5d: 0x2690b, // white-space
387	0x60: 0x101,   // a
388	0x61: 0xb,     // baseProfile
389	0x62: 0x14c0a, // font-style
390	0x63: 0x3340d, // viewport-fill
391	0x65: 0x8009,  // clip-rule
392	0x67: 0x6904,  // path
393	0x68: 0xd813,  // color-interpolation
394	0x69: 0x2d90e, // stroke-opacity
395	0x6a: 0x2b90f, // stroke-linejoin
396	0x6b: 0x2ee05, // width
397	0x6d: 0x2320f, // color-rendering
398	0x6e: 0xc702,  // y2
399	0x6f: 0x3c04,  // line
400	0x70: 0x1cb0d, // missing-glyph
401	0x71: 0x2740c, // stop-opacity
402	0x72: 0x11f09, // font-size
403	0x73: 0x380e,  // baseline-shift
404	0x74: 0x3530c, // word-spacing
405	0x75: 0x2fc06, // symbol
406	0x76: 0x11f10, // font-size-adjust
407	0x77: 0xd805,  // color
408	0x79: 0x28006, // stroke
409	0x7b: 0x22706, // points
410	0x7c: 0x32507, // version
411	0x7d: 0x6409,  // clip-path
412	0x7e: 0x22c0b, // solid-color
413	0x7f: 0x6404,  // clip
414}
415