Code

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