1 /*
2 * parse SVG path specifications
3 *
4 * Copyright 2007 MenTaLguY <mental@rydia.net>
5 * Copyright 2007 Aaron Spike <aaron@ekips.org>
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it either under the terms of the GNU Lesser General Public
9 * License version 2.1 as published by the Free Software Foundation
10 * (the "LGPL") or, at your option, under the terms of the Mozilla
11 * Public License Version 1.1 (the "MPL"). If you do not alter this
12 * notice, a recipient may use your version of this file under either
13 * the MPL or the LGPL.
14 *
15 * You should have received a copy of the LGPL along with this library
16 * in the file COPYING-LGPL-2.1; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 * You should have received a copy of the MPL along with this library
19 * in the file COPYING-MPL-1.1
20 *
21 * The contents of this file are subject to the Mozilla Public License
22 * Version 1.1 (the "License"); you may not use this file except in
23 * compliance with the License. You may obtain a copy of the License at
24 * http://www.mozilla.org/MPL/
25 *
26 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
27 * OF ANY KIND, either express or implied. See the LGPL or the MPL for
28 * the specific language governing rights and limitations.
29 *
30 */
32 #ifndef SEEN_SVG_PATH_PARSER_H
33 #define SEEN_SVG_PATH_PARSER_H
35 #include <vector>
36 #include <iterator>
37 #include <stdexcept>
38 #include "exception.h"
39 #include "point.h"
40 #include "svg-path.h"
42 namespace Geom {
44 void parse_svg_path(char const *str, SVGPathSink &sink) throw(SVGPathParseError);
46 inline std::vector<Path> parse_svg_path(char const *str) throw(SVGPathParseError) {
47 /*PathBuilder b;
48 parse_svg_path(str, b);
49 return b.peek();*/
50 std::vector<Path> subpaths;
51 std::back_insert_iterator<std::vector<Path> > iter(subpaths);
52 SVGPathGenerator<std::back_insert_iterator<std::vector<Path> > > generator(iter);
53 parse_svg_path(str, generator);
54 return subpaths;
55 }
57 inline std::vector<Path> read_svgd(char const * name) throw(SVGPathParseError) {
58 FILE* fi = fopen(name, "r");
59 if(fi == NULL) throw(std::runtime_error("Error opening file"));
60 char input[1024 * 10];
61 fgets(input, 1024 * 10, fi);
62 fclose(fi);
63 return parse_svg_path(input);
64 }
66 }
68 #endif
69 /*
70 Local Variables:
71 mode:c++
72 c-file-style:"stroustrup"
73 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
74 indent-tabs-mode:nil
75 fill-column:99
76 End:
77 */
78 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :