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 "svg/svg-length.h"
16 #include <vector>
18 struct NArtBpath;
19 struct NRMatrix;
20 namespace NR {
21 class Matrix;
22 }
24 /* Generic */
26 /*
27 * These are very-very simple:
28 * - they accept everything libc strtod accepts
29 * - no valid end character checking
30 * Return FALSE and let val untouched on error
31 */
33 unsigned int sp_svg_number_read_f (const gchar *str, float *val);
34 unsigned int sp_svg_number_read_d (const gchar *str, double *val);
36 /*
37 * No buffer overflow checking is done, so better wrap them if needed
38 */
39 unsigned int sp_svg_number_write_de (gchar *buf, double val, unsigned int tprec, unsigned int padf);
41 /* Length */
43 /*
44 * Parse number with optional unit specifier:
45 * - for px, pt, pc, mm, cm, computed is final value accrding to SVG spec
46 * - for em, ex, and % computed is left untouched
47 * - % is divided by 100 (i.e. 100% is 1.0)
48 * !isalnum check is done at the end
49 * Any return value pointer can be NULL
50 */
52 unsigned int sp_svg_length_read_computed_absolute (const gchar *str, float *length);
53 std::vector<SVGLength> sp_svg_length_list_read (const gchar *str);
54 unsigned int sp_svg_length_read_ldd (const gchar *str, SVGLength::Unit *unit, double *value, double *computed);
56 std::string sp_svg_length_write_with_units(SVGLength const &length);
58 bool sp_svg_transform_read(gchar const *str, NR::Matrix *transform);
60 unsigned sp_svg_transform_write(gchar str[], unsigned size, NR::Matrix const &transform);
61 unsigned sp_svg_transform_write(gchar str[], unsigned size, NRMatrix const *transform);
63 double sp_svg_read_percentage (const char * str, double def);
65 /* NB! As paths can be long, we use here dynamic string */
67 NArtBpath * sp_svg_read_path (const char * str);
68 char * sp_svg_write_path (const NArtBpath * bpath);
71 #endif
73 /*
74 Local Variables:
75 mode:c++
76 c-file-style:"stroustrup"
77 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
78 indent-tabs-mode:nil
79 fill-column:99
80 End:
81 */
82 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :