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