1 #ifndef __SP_SVG_H__
2 #define __SP_SVG_H__
4 /*
5 * SVG data parser
6 *
7 * Authors:
8 * Lauris Kaplinski <lauris@kaplinski.com>
9 *
10 * Copyright (C) 1999-2002 Lauris Kaplinski
11 *
12 * Released under GNU GPL, read the file 'COPYING' for more information
13 */
14 #include <glib/gtypes.h>
15 #include <vector>
16 #include <cstring>
17 #include <string>
19 #include "svg/svg-length.h"
20 #include "libnr/nr-forward.h"
22 /* Generic */
24 /*
25 * These are very-very simple:
26 * - they accept everything libc strtod accepts
27 * - no valid end character checking
28 * Return FALSE and let val untouched on error
29 */
31 unsigned int sp_svg_number_read_f (const gchar *str, float *val);
32 unsigned int sp_svg_number_read_d (const gchar *str, double *val);
34 /*
35 * No buffer overflow checking is done, so better wrap them if needed
36 */
37 unsigned int sp_svg_number_write_de (gchar *buf, double val, unsigned int tprec, int min_exp, unsigned int padf);
39 /* Length */
41 /*
42 * Parse number with optional unit specifier:
43 * - for px, pt, pc, mm, cm, computed is final value accrding to SVG spec
44 * - for em, ex, and % computed is left untouched
45 * - % is divided by 100 (i.e. 100% is 1.0)
46 * !isalnum check is done at the end
47 * Any return value pointer can be NULL
48 */
50 unsigned int sp_svg_length_read_computed_absolute (const gchar *str, float *length);
51 std::vector<SVGLength> sp_svg_length_list_read (const gchar *str);
52 unsigned int sp_svg_length_read_ldd (const gchar *str, SVGLength::Unit *unit, double *value, double *computed);
54 std::string sp_svg_length_write_with_units(SVGLength const &length);
56 bool sp_svg_transform_read(gchar const *str, NR::Matrix *transform);
58 gchar *sp_svg_transform_write(NR::Matrix const &transform);
59 gchar *sp_svg_transform_write(NR::Matrix const *transform);
61 double sp_svg_read_percentage (const char * str, double def);
63 /* NB! As paths can be long, we use here dynamic string */
65 NArtBpath * sp_svg_read_path (const char * str);
66 char * sp_svg_write_path (const NArtBpath * bpath);
69 #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 :