Removal of non-Haiku target platform logic from build system (part 1.)
[haiku.git] / src / apps / icon-o-matic / import_export / svg / SVGParser.h
blob7ce6c811837ca5f3417a9d580ceb67e8f24d9a77
1 /*
2 * Copyright 2006, Haiku. All rights reserved.
3 * Distributed under the terms of the MIT License.
5 * Authors:
6 * Stephan Aßmus <superstippi@gmx.de>
7 */
9 //----------------------------------------------------------------------------
10 // Anti-Grain Geometry - Version 2.2
11 // Copyright (C) 2002-2004 Maxim Shemanarev (http://www.antigrain.com)
13 // Permission to copy, use, modify, sell and distribute this software
14 // is granted provided this copyright notice appears in all copies.
15 // This software is provided "as is" without express or implied
16 // warranty, and with no claim as to its suitability for any purpose.
18 //----------------------------------------------------------------------------
19 // Contact: mcseem@antigrain.com
20 // mcseemagg@yahoo.com
21 // http://www.antigrain.com
22 //----------------------------------------------------------------------------
24 #ifndef SVG_PARSER_H
25 #define SVG_PARSER_H
27 #include "PathTokenizer.h"
28 #include "DocumentBuilder.h"
30 namespace agg {
31 namespace svg {
33 class Parser {
34 enum { buf_size = BUFSIZ };
35 public:
37 Parser(DocumentBuilder& builder);
38 virtual ~Parser();
40 void parse(const char* pathToFile);
41 const char* title() const
42 { return fTitle; }
44 bool TagsIgnored() const
45 { return fTagsIgnored; }
47 private:
48 // XML event handlers
49 static void start_element(void* data, const char* el,
50 const char** attr);
51 static void end_element(void* data, const char* el);
52 static void content(void* data, const char* s, int len);
54 void parse_svg(const char** attr);
55 void parse_attr(const char** attr);
56 void parse_path(const char** attr);
57 void parse_poly(const char** attr, bool close_flag);
58 void parse_circle(const char** attr);
59 void parse_ellipse(const char** attr);
60 void parse_rect(const char** attr);
61 void parse_line(const char** attr);
62 void parse_style(const char* str);
63 trans_affine parse_transform(const char* str);
65 void parse_gradient(const char** attr, bool radial);
66 void parse_gradient_stop(const char** attr);
68 unsigned parse_matrix(const char* str, trans_affine& transform);
69 unsigned parse_translate(const char* str, trans_affine& transform);
70 unsigned parse_rotate(const char* str, trans_affine& transform);
71 unsigned parse_scale(const char* str, trans_affine& transform);
72 unsigned parse_skew_x(const char* str, trans_affine& transform);
73 unsigned parse_skew_y(const char* str, trans_affine& transform);
75 bool parse_attr(const char* name,
76 const char* value);
77 bool parse_name_value(const char* nv_start,
78 const char* nv_end);
79 void copy_name(const char* start, const char* end);
80 void copy_value(const char* start, const char* end);
82 private:
83 DocumentBuilder& fBuilder;
84 PathTokenizer fPathTokenizer;
85 char* fBuffer;
86 char* fTitle;
87 unsigned fTitleLength;
89 bool fTitleFlag;
90 bool fPathFlag;
92 char* fAttrName;
93 char* fAttrValue;
94 unsigned fAttrNameLength;
95 unsigned fAttrValueLength;
97 rgba8 fGradientStopColor;
99 bool fTagsIgnored;
102 } // namespace svg
103 } // namespace agg
105 #endif // SVG_PARSER_H