1 #define INKSCAPE_LIVEPATHEFFECT_PARAMETER_ARRAY_CPP
3 /*
4 * Copyright (C) Johan Engelen 2008 <j.b.c.engelen@utwente.nl>
5 *
6 * Released under GNU GPL, read the file 'COPYING' for more information
7 */
9 #include "live_effects/parameter/array.h"
11 #include "svg/svg.h"
12 #include "svg/stringstream.h"
14 #include <2geom/coord.h>
15 #include <2geom/point.h>
17 namespace Inkscape {
19 namespace LivePathEffect {
21 template <>
22 double
23 ArrayParam<double>::readsvg(const gchar * str)
24 {
25 double newx = Geom::infinity();
26 sp_svg_number_read_d(str, &newx);
27 return newx;
28 }
30 template <>
31 float
32 ArrayParam<float>::readsvg(const gchar * str)
33 {
34 float newx = Geom::infinity();
35 sp_svg_number_read_f(str, &newx);
36 return newx;
37 }
39 template <>
40 Geom::Point
41 ArrayParam<Geom::Point>::readsvg(const gchar * str)
42 {
43 gchar ** strarray = g_strsplit(str, ",", 2);
44 double newx, newy;
45 unsigned int success = sp_svg_number_read_d(strarray[0], &newx);
46 success += sp_svg_number_read_d(strarray[1], &newy);
47 g_strfreev (strarray);
48 if (success == 2) {
49 return Geom::Point(newx, newy);
50 }
51 return Geom::Point(Geom::infinity(),Geom::infinity());
52 }
54 } /* namespace LivePathEffect */
56 } /* namespace Inkscape */
58 /*
59 Local Variables:
60 mode:c++
61 c-file-style:"stroustrup"
62 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
63 indent-tabs-mode:nil
64 fill-column:99
65 End:
66 */
67 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :